mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-26 02:55:19 +03:00
75c228f4e1
The bulk of this updates transcripts to put spaces around the language name in code blocks. E.g., ```` markdown ```ucm:hide ```` becomes ```` markdown ``` ucm :hide ```` This corresponds to https://share.unison-lang.org/@unison/website/contributions/11, which updates the docs in the same way. This is effectively a fix for #5214, but that issue also has good recommendations for future changes to info strings, so I don’t know that it should be closed.
72 lines
1.9 KiB
Markdown
72 lines
1.9 KiB
Markdown
``` unison
|
||
structural ability Exception where raise : Failure -> x
|
||
|
||
ex = unsafeRun! '(printLine "hello world")
|
||
|
||
printLine : Text ->{IO, Exception} ()
|
||
printLine t =
|
||
putText stdOut t
|
||
putText stdOut "\n"
|
||
|
||
stdOut : Handle
|
||
stdOut = stdHandle StdOut
|
||
|
||
compose2 : (c ->{𝕖1} d) -> (a ->{𝕖2} b ->{𝕖3} c) -> a -> b ->{𝕖1,𝕖2,𝕖3} d
|
||
compose2 f g x y = f (g x y)
|
||
|
||
putBytes : Handle -> Bytes ->{IO, Exception} ()
|
||
putBytes = compose2 toException putBytes.impl
|
||
|
||
toException : Either Failure a ->{Exception} a
|
||
toException = cases
|
||
Left e -> raise e
|
||
Right a -> a
|
||
|
||
putText : Handle -> Text ->{IO, Exception} ()
|
||
putText h t = putBytes h (toUtf8 t)
|
||
|
||
Exception.unsafeRun! : '{Exception, g} a -> '{g} a
|
||
Exception.unsafeRun! e _ =
|
||
h : Request {Exception} a -> a
|
||
h = cases
|
||
{Exception.raise fail -> _ } ->
|
||
bug fail
|
||
{a} -> a
|
||
handle !e with h
|
||
```
|
||
|
||
``` ucm
|
||
|
||
Loading changes detected in scratch.u.
|
||
|
||
I found and typechecked these definitions in scratch.u. If you
|
||
do an `add` or `update`, here's how your codebase would
|
||
change:
|
||
|
||
⍟ These new definitions are ok to `add`:
|
||
|
||
structural ability Exception
|
||
(also named builtin.Exception)
|
||
Exception.unsafeRun! : '{g, Exception} a -> '{g} a
|
||
compose2 : (c ->{𝕖1} d)
|
||
-> (a ->{𝕖2} b ->{𝕖3} c)
|
||
-> a
|
||
-> b
|
||
->{𝕖1, 𝕖2, 𝕖3} d
|
||
ex : '{IO} ()
|
||
printLine : Text ->{IO, Exception} ()
|
||
putBytes : Handle
|
||
-> Bytes
|
||
->{IO, Exception} ()
|
||
putText : Handle -> Text ->{IO, Exception} ()
|
||
stdOut : Handle
|
||
toException : Either Failure a ->{Exception} a
|
||
|
||
```
|
||
``` ucm
|
||
scratch/main> run ex
|
||
|
||
()
|
||
|
||
```
|