Move DataType into internal/datatype, aliased by the root, and what a proof knows of a value into internal/proven
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Package datatype names what a record column holds.
|
||||
package datatype
|
||||
|
||||
import "fmt"
|
||||
|
||||
// DataType is what a record column holds, which decides how a record writes its value.
|
||||
type DataType int
|
||||
|
||||
// The datatypes a column declares with "datatype"; a column without one is a string.
|
||||
const (
|
||||
String DataType = iota
|
||||
Integer
|
||||
Number
|
||||
Boolean
|
||||
)
|
||||
|
||||
// Count is the number of datatypes, for an array indexed by one.
|
||||
const Count = len(names)
|
||||
|
||||
var (
|
||||
names = [...]string{"string", "integer", "number", "boolean"}
|
||||
nouns = [...]string{"text", "an integer", "a number", "a boolean"}
|
||||
)
|
||||
|
||||
// String is the datatype as data spells it.
|
||||
func (d DataType) String() string {
|
||||
if d < 0 || int(d) >= len(names) {
|
||||
return fmt.Sprintf("DataType(%d)", int(d))
|
||||
}
|
||||
return names[d]
|
||||
}
|
||||
|
||||
// Noun is the datatype as an error names what a value is.
|
||||
func Noun(d DataType) string { return nouns[d] }
|
||||
Reference in New Issue
Block a user