mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 10:35:57 +03:00
This is for consistency with the `cmark` style. Now the blocks we still pretty-print ourselves will match the bulk of them that `cmark` produces.
1.8 KiB
1.8 KiB
printLine : Text ->{IO} ()
printLine msg =
_ = putBytes.impl (stdHandle StdOut) (Text.toUtf8 (msg ++ "\n"))
()
-- An unannotated main function
main1 = '(printLine "\nhello world!")
-- Another variation
main2 _ = printLine "🌹"
-- An annotated main function
main3 : '{IO} ()
main3 _ = printLine "🦄 ☁️ 🌈"
Testing a few variations here:
- Should be able to run annotated and unannotated main functions in the current file.
- Should be able to run annotated and unannotated main functions from the codebase.
scratch/main> run main1
()
scratch/main> run main2
()
scratch/main> run main3
()
scratch/main> add
⍟ I've added these definitions:
main1 : '{IO} ()
main2 : ∀ _. _ ->{IO} ()
main3 : '{IO} ()
printLine : Text ->{IO} ()
scratch/main> rename.term main1 code.main1
Done.
scratch/main> rename.term main2 code.main2
Done.
scratch/main> rename.term main3 code.main3
Done.
The renaming just ensures that when running code.main1
, it has to get that main from the codebase rather than the scratch file:
scratch/main> run code.main1
()
scratch/main> run code.main2
()
scratch/main> run code.main3
()
Now testing a few variations that should NOT typecheck.
main4 : Nat ->{IO} Nat
main4 n = n
main5 : Nat ->{IO} ()
main5 _ = ()
This shouldn't work since main4
and main5
don't have the right type.
scratch/main> run main4
😶
I found this function:
main4 : Nat ->{IO} Nat
but in order for me to `run` it needs to be a subtype of:
main4 : '{IO, Exception} result
scratch/main> run main5
😶
I found this function:
main5 : Nat ->{IO} ()
but in order for me to `run` it needs to be a subtype of:
main5 : '{IO, Exception} result