Skip to content

Instantly share code, notes, and snippets.

@jfdm
Last active June 17, 2022 09:56
Show Gist options
  • Select an option

  • Save jfdm/6885c20f67ba6606eaf1fa1abbe88e83 to your computer and use it in GitHub Desktop.

Select an option

Save jfdm/6885c20f67ba6606eaf1fa1abbe88e83 to your computer and use it in GitHub Desktop.
Not Quite Four but Hello World
module Example
import Ola
public export
example : Prog Nil Nil UNIT
example
= DefType TyStr
$ DefFunc (TyFunc TyUnit (TyVar Here))
(Fun (Return (S "Hello World")
))
$ Main
$ Let TyStr
(Call (Var Here) U)
$ Print (Var Here)
$ Return U
public export
example1 : Prog Nil Nil UNIT
example1
= DefFunc (TyFunc (TyUnion TyStr TyInt)
TyStr)
(Fun (Return $ Match (Var Here)
(Var Here)
(S "Hello")
))
$ Main
$ Let (TyUnion TyStr TyInt)
(Left (S "AA"))
$ Print (Call (Var (There Here))
(Var Here))
$ Return U
public export
example2 : Prog Nil Nil UNIT
example2
= Main
$ Let (TyRef TyStr)
(Alloc (S "HelloWorld"))
$ Print (Fetch $ Var Here)
$ Discard (Mutate (Var Here)
(S "Goodbye World"))
$ Print (Fetch $ Var Here)
$ Return U
module Main
import Ola
import Example
main : IO ()
main
= do Ola.run (exec example)
Ola.run (exec example1)
Ola.run (exec example2)
$ idris2 --build ola.ipkg
$ ./build/exec/ola
"Hello World"
"AA"
"HelloWorld"
"Goodbye World"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment