# Types ## Axioms The syntax described only applies within this document. - All defined things below are values, all values have a type, all types have a definition which is itself a value. - A type definition is displayed as a value wrapped in angle brackets, like ``. - A type definition with no value, `<>`, is the empty type - A type definition may have more than one type, as in ``, to indicate that a value with that type is actually a combination of each type in sequence (i.e. a tuple) - Tuples can be wrapped in parenthesis to indicate sub-groupings. I.e. `` is a tuple of 2 sub-types, the first being a `` and the second being a tuple of 2 ``. - Any type definition can be used in place of ``. - `1` is an example of a value of type ``. - The type of value `` is ``. - - Any `lowercaseAlphaNumeric` string is an atom value, of type ``. - `V` is a placeholder for a value of type ``. It is used when matching a pattern. - `(declareType, V)` is understood to declare a type definition. A type definition can then be used as ``. - `(declareFunction, V, , )` is a tuple understood to declare a function, named after the atom, where the type definitions of the input and output are also given. ## Type declarations. ``` (declareType, atom) (declareType, bool) (declareType, int) // general purpose functions for working with all types. (declareFunction, concat, , ) (declareFunction, slice, , ) (declareFunction, len, , ) (declareFunction, eq, , ) // functions for working with integers (declareFunction, plus, , ) (declareFunction, mult, , ) (declareFunction, minus, , ) // these two may return false if divide by zero (declareFunction, div, , ) (declareFunction, mod, , ) // a general iterator (declareType, (iter,any)) (declareFunction, next, , <(iter,any),any,bool>) // TODO structurally, what's the difference between `` and // ``? the latter's first element isn't a valid typedef on its own, // but other than that there seems to be no difference? //(declareCompound, graph, T) //(declareFunction, addEdge, (tup,(graph,T),T,T), (tup,graph,T)) //(declareFunction, rmEdge, (tup,(graph,T),T,T), (tup,graph,T)) //// the order of elements returned by parents/children is the same as the order //// the edges between the nodes were added. //(declareFunction, parents, (tup,(graph,T),T), (tup,(iter,T))) //(declareFunction, children, (tup,(graph,T),T), (tup,(iter,T))) //(declareFunction, has, (tup,(graph,T),T), bool) //```