diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-10 23:59:14 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-11 01:37:50 +0200 |
| commit | d0614dd946baf05375172d7a50f5eb250b9a7b00 (patch) | |
| tree | 7b25433d3276fe6a782b77231272e9f9a01502f5 | |
| parent | f522e39756ae0aef5e49585fc735c475cf3ff9e4 (diff) | |
Update spec.md
| -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 |
