mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-26 11:07:48 +03:00
1.0 KiB
1.0 KiB
Tests an issue with a lack of generality of handlers.
In general, a set of cases:
{ e ... -> k }
should be typed in the following way:
- The scrutinee has type
Request {E, g} r -> s
whereE
is all the abilities being handled.g
is a slack variable, because all abilities that are used in the handled expression pass through the handler. Previously this was being inferred as merelyRequest {E} r -> s
- The continuation variable
k
should have typeo ->{E, g} r
, matching the above types (o
is the result type ofe
). Previously this was being checked aso ->{E0} r
, whereE0
is the ability that containse
.
scratch/main> builtins.merge
structural ability Stream a where
emit : a -> ()
Stream.uncons : '{Stream a, g} r ->{g} Either r (a, '{Stream a, g} r)
Stream.uncons s =
go : Request {Stream a,g} r -> Either r (a, '{Stream a,g} r)
go = cases
{ r } -> Left r
{ Stream.emit a -> tl } -> Right (a, tl : '{Stream a,g} r)
handle !s with go