- Use
use x = obj
rest
// Equivalent to:
let x = obj
open x
rest
- May
may x = obj abort k
rest
// Equivalent to:
case obj as x {
none: k
some:
let x = x.value
rest
}
- List comprehension
[x * 10 for x in [1, 2, 3]]
// Returns:
[10, 20, 30]
- Map for-in:
for key,val in map with state:
loop
rest
let state = for key:val in map:
loop
rest
- Function composition:
f . g
// Equivalent to:
Function.comp!!!(f, g)
Generic derivers: stringifier, parser, serializer, deserializer. Example:
```
type MyType {
foo(n: List<Nat>, s: String, m: MyType)
bar
} deriving (stringifier, parser, serializer, deserializer)
Test: _
IO {
let val = MyType.foo([1,2,3], "Hello", MyType.bar)
// Converts to string
let str = Stringifier.run!(MyType.stringifier, val)
IO.print("str: " | str)
// Parses string to a value
let val = Parser.run!(MyType.parser, str) <> MyType.bar
// Serializes to bits
let bts = Serializer.run!(MyType.serializer, val)
IO.print("bts: " | Bits.show(bts))
// Deserializes to a value
let val = Deserializer.run!(MyType.deserializer, bts) <> MyType.bar
// Converts to string again
let str = Stringifier.run!(MyType.stringifier, val)
IO.print("str: " | str)
}
```