8. Basic Types and Constructors
TBoS p.213, Types
The basic datatypes and types of Shen are;
- symbols
- strings
- booleans
- numbers
- lists
- tuples
- vectors
- exceptions
- lazy objects
- abstractions
Typing (tc +) to the REPL activates type checking. Here are a few examples.
a
a : symbol
"hello world"
"hello world" : string
(= 4 5)
false : boolean
(* 2.3 2)
4.6 : number
[1 2 3]
[1 2 3] : (list number)
(@v 1 2 3 <>)
<1 2 3> : (vector number)
(@p 1 2 a)
(@p 1 (@p 2 a)) : (number * (number * symbol))
(@s "10" " green" " bottles")
"10 green bottles" : string
(freeze (* 7 8))
# : (lazy number)
(10 +) (* 7)
# : (number --> number)
|
|