unison/unison-src/transcripts/fix2027.output.md

95 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

``` unison
2021-08-24 21:33:27 +03:00
structural ability Exception where raise : Failure -> x
reraise = cases
Left e -> raise e
Right a -> a
2021-08-24 21:33:27 +03:00
structural type Either a b = Left a | Right b
putBytes h bs = reraise (putBytes.impl h bs)
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)
bugFail = cases
Failure typ _ _ -> bug (Failure typ "problem" (Any ()))
Exception.unsafeRun! : '{Exception, g} a -> '{g} a
Exception.unsafeRun! e _ =
h : Request {Exception} a -> a
h = cases
{Exception.raise fail -> _ } ->
bugFail fail
{a} -> a
handle !e with h
socketSend s bytes = reraise (socketSend.impl s bytes)
closeSocket s = reraise (closeSocket.impl s)
2024-04-02 09:12:34 +03:00
serverSocket host port = reraise (IO.serverSocket.impl host port)
hello : Text -> Text -> {IO, Exception} ()
hello host port =
socket = serverSocket (Some host) port
msg = toUtf8 "Hello there"
socketSend socket msg
closeSocket socket
myServer = unsafeRun! '(hello "127.0.0.1" "0")
```
``` 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`:
2021-08-24 21:33:27 +03:00
structural type Either a b
(also named builtin.Either)
2024-04-15 03:01:39 +03:00
structural ability Exception
(also named builtin.Exception)
2022-01-25 09:27:16 +03:00
Exception.unsafeRun! : '{g, Exception} a -> '{g} a
2024-04-15 03:01:39 +03:00
bugFail : Failure -> r
2022-01-25 09:27:16 +03:00
closeSocket : Socket ->{IO, Exception} ()
2024-04-15 03:01:39 +03:00
hello : Text -> Text ->{IO, Exception} ()
myServer : '{IO} ()
2022-01-25 09:27:16 +03:00
putBytes : Handle
-> Bytes
->{IO, Exception} ()
2024-04-15 03:01:39 +03:00
putText : Handle -> Text ->{IO, Exception} ()
reraise : Either Failure b ->{Exception} b
2022-01-25 09:27:16 +03:00
serverSocket : Optional Text
-> Text
->{IO, Exception} Socket
2024-04-15 03:01:39 +03:00
socketSend : Socket
-> Bytes
->{IO, Exception} ()
toException : Either Failure a ->{Exception} a
```
``` ucm
scratch/main> run myServer
💔💥
I've encountered a call to builtin.bug with the following
value:
2022-02-13 08:20:06 +03:00
Failure (typeLink IOFailure) "problem" (Any ())
Stack trace:
bug
2023-08-18 00:55:28 +03:00
#8ppr1tt4q2
```