👋 Hello World
The classic Hello World program in Unison is as simple as a call to printLine.
{IO, Exception}
indicates which abilities the program needs to do I/O and throw exceptions.
'
Distributed map-reduce
With a few lines of code, you can perform a distributed map-reduce using thelib.distributed.Remote
ability.
distributedEx :
lib.distributed.Seq k Nat ->{lib.distributed.Remote} Nat
distributedEx dseq =
dseq
|> lib.distributed.Seq.map (x -> x + 1)
|> lib.distributed.Seq.filter (x -> mod x 7 == 0)
|> lib.distributed.Seq.reduce 0 (+)
Learn more about Remote and working withdistributed datasets in Unison.
HTTP request
Perform effectful code, like HTTP requests withAbilitiesandAbility handlers.
Checkout more HTTP examples in thehttp library.
home.examples.httpEx : '{IO, Exception} Response
home.examples.httpEx _ =
host = HostName "unison-lang.org"
web = Authority None host None
path = Path.root / "docs"
uri = Uri.Uri Scheme.https (Some web) path http.Query.empty None
req = Request.get uri
handle http.Http.request req with http.Http.handler