Define datatypes once, get polyglot results
datatypetool docs datatypetool_types.md
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 True or False
  • 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 members NotNull a and Null may be used as values/defaults for things like constants or models.
    • Nullable values must either be the keyword NotNull followed by the appropriate inner value, or be just the keyword Null
      • Example: NotNull "I'm not null!"
  • 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 List of Tuples2's.
    • Dict values must be written within brackets [] prepended with the word Dict. Inside the brackets should be key-value pairs within braces {} and separated by a comma.
      • Example: Dict [{"key", 50}] would be a value for a Dict Int
  • 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 word List
  • 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 word Set
  • 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)
  • Any type you've defined in a *.type file.

    • It would only make sense that anything you've defined as a type could be used as a type.
    • This includes in other *.type files too, you'll just need a ref-erence to that file so we know to generate import statements when we generate the resulting file(s)