Last active
June 17, 2022 09:56
-
-
Save jfdm/6885c20f67ba6606eaf1fa1abbe88e83 to your computer and use it in GitHub Desktop.
Not Quite Four but Hello World
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Main | |
| import Ola | |
| import Example | |
| main : IO () | |
| main | |
| = do Ola.run (exec example) | |
| Ola.run (exec example1) | |
| Ola.run (exec example2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 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