Something went wrong. Try again.
Define datatypes once, get polyglot results
Something went wrong. Try again.
2.9 kB
Markdown
at main
Here are a list of basic types you can use in your *.type files:
-
Str
- The basic string type.
- Str values must be contained within double-quotation-marks
""
-
Int
- The basic integer type.
- May have a leading + or -
- May have underscores for readability
- Int values must only contain characters [
+-0123456789_]
-
Float
- The basic float type.
- May have a leading + or -
- May have underscores for readability
- Must have a decimal point
- Float values must only contain characters [
+-0123456789_.]
-
Bool
- The basic boolean type.
- Bool values must be
TrueorFalse
-
Nullable a
- Defines an Option/Maybe type. Denotes that this value can be Null/Nil/None/Nothing, or Some/Just a type.
- Must be supplied one type for the case where this value is Some/Just.
- It's internally treated similar to an
enum, so the membersNotNull aandNullmay be used as values/defaults for things likeconstantsormodels. - Nullable values must either be the keyword
NotNullfollowed by the appropriate inner value, or be just the keywordNull- Example:
NotNull "I'm not null!"
- Example:
-
Dict a
- The dictionary/object/map type.
- Must be supplied one types for the values, and they must be of the same type.
- Due to JSON requirements, the key must be a string type. Since we aim to make serializable types, we have to comply with this restriction.
- If, for whatever reason, you need to bypass this, maybe consider a literal
ListofTuples2's.
- If, for whatever reason, you need to bypass this, maybe consider a literal
- Dict values must be written within brackets
[]prepended with the wordDict. Inside the brackets should be key-value pairs within braces{}and separated by a comma.- Example:
Dict [{"key", 50}]would be a value for aDict Int
- Example:
-
List a
- The list/array type.
- Must be supplied one type for each value, and they must be of the same type
- List values must be written within brackets
[]prepended with the wordList
-
Set a
- The set type
- Must be supplied one type for each value, and they must be of the same type
- Set values must be written within brackets
[]prepended with the wordSet
-
Tuple
- Comes in 4 flavors:
- Tuple2 a b
- Tuple3 a b c
- Tuple4 a b c d
- Tuple5 a b c d e
- Must be supplied a quantity of types equal to the number on the tuple, for the type of that value.
- Tuple values are written within braces
{}prepended with the name of the type of tuple (Tuple2, for example)
- Comes in 4 flavors:
-
Any type you've defined in a
*.typefile.- It would only make sense that anything you've defined as a type could be used as a type.
- This includes in other
*.typefiles too, you'll just need aref-erence to that file so we know to generate import statements when we generate the resulting file(s)