diff options
| -rw-r--r-- | spec.md | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -5,7 +5,7 @@ - Boolean functions marked with ? (convention) - Loops implemented with recursion -## Value types +## Values and types Integer 3 Float -3.14 @@ -17,6 +17,12 @@ Hash map { a 1 b 2 } Function (\[x y] (+ x y)) +Functions generally only accept monomorphic values, but some builtins are polymorphic, either expecting any arbitrary type (as is the case in e.g. `match` and `fmt`), or only a range of types (type classes). User defined functions can be made "polymorphic" by matching on the return value of `(type arg)`, where `arg` is the argument of the user defined function. + +There are 2 language defined "type classes": `Num` and `Seq`. Integers and floats are instances of `Num`, while Strings and Vectors are instances of `Seq`. Type classes are not a thing per se in the interpreter, but they are a useful concept to "formalize" some builtin functions and their inputs. `Num` values can be e.g. added together with `+`. `Seq` values can be used to call functions like `head` and `tail` and `len`. + +Collections (vectors, hash maps) are heterogenous, which means that a single collection can contains values of multiple types. + ## Syntax ### Function calls |
