Unison language preview
1. Doubling a list
an ability declaration, a function, and a test
horizon-dark
-- doubles every element of a list
structural ability Stream where
emit : Nat -> ()
use List map
double : [Nat] -> [Nat]
double xs = map (n -> n * 2) xs
test> double.tests.ex1 =
match double [1, 2, 3] with
[2, 4, 6] -> ok "matched"
_ -> fail "no match" atom-one-dark
-- doubles every element of a list
structural ability Stream where
emit : Nat -> ()
use List map
double : [Nat] -> [Nat]
double xs = map (n -> n * 2) xs
test> double.tests.ex1 =
match double [1, 2, 3] with
[2, 4, 6] -> ok "matched"
_ -> fail "no match" github-dark
-- doubles every element of a list
structural ability Stream where
emit : Nat -> ()
use List map
double : [Nat] -> [Nat]
double xs = map (n -> n * 2) xs
test> double.tests.ex1 =
match double [1, 2, 3] with
[2, 4, 6] -> ok "matched"
_ -> fail "no match" dracula
-- doubles every element of a list
structural ability Stream where
emit : Nat -> ()
use List map
double : [Nat] -> [Nat]
double xs = map (n -> n * 2) xs
test> double.tests.ex1 =
match double [1, 2, 3] with
[2, 4, 6] -> ok "matched"
_ -> fail "no match" nord
-- doubles every element of a list
structural ability Stream where
emit : Nat -> ()
use List map
double : [Nat] -> [Nat]
double xs = map (n -> n * 2) xs
test> double.tests.ex1 =
match double [1, 2, 3] with
[2, 4, 6] -> ok "matched"
_ -> fail "no match" github
-- doubles every element of a list
structural ability Stream where
emit : Nat -> ()
use List map
double : [Nat] -> [Nat]
double xs = map (n -> n * 2) xs
test> double.tests.ex1 =
match double [1, 2, 3] with
[2, 4, 6] -> ok "matched"
_ -> fail "no match" 2. Ability sets
an ability set in a function signature
horizon-dark
main : '{IO, Exception} ()
main = do
printLine "hello" atom-one-dark
main : '{IO, Exception} ()
main = do
printLine "hello" github-dark
main : '{IO, Exception} ()
main = do
printLine "hello" dracula
main : '{IO, Exception} ()
main = do
printLine "hello" nord
main : '{IO, Exception} ()
main = do
printLine "hello" github
main : '{IO, Exception} ()
main = do
printLine "hello" 3. Doc literals
the {{ }} doc literal syntax
horizon-dark
## double
{{ Doubles the given number. }}
double : Nat -> Nat
double n = n * 2 atom-one-dark
## double
{{ Doubles the given number. }}
double : Nat -> Nat
double n = n * 2 github-dark
## double
{{ Doubles the given number. }}
double : Nat -> Nat
double n = n * 2 dracula
## double
{{ Doubles the given number. }}
double : Nat -> Nat
double n = n * 2 nord
## double
{{ Doubles the given number. }}
double : Nat -> Nat
double n = n * 2 github
## double
{{ Doubles the given number. }}
double : Nat -> Nat
double n = n * 2