Skip to content

Commit

Permalink
No LEff
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjaguarpaw committed Sep 1, 2024
1 parent b0c6229 commit ae0e212
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions bluefin-internal/src/Bluefin/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ yieldLinearly ::
(e :> es) =>
Linearly a b r e %1 ->
a ->
LEff es (Either (Ur b, Linearly a b r e) (Ur r))
Eff es (Either (Ur b, Linearly a b r e) (Ur r))
yieldLinearly (UnsafeMkLinearly (Ur (av, bv))) a = UnsafeMkEff $ do
putMVar av a
takeMVar bv >>= \case
Expand All @@ -185,40 +185,38 @@ instance L.Applicative (Eff es) where
instance L.Monad (Eff es) where
(>>=) = unsafeCoerce ((>>=) @IO)

type LEff = Eff

newtype Wrap1 a b es r
= Wrap1 (forall e. a -> Coroutine b a e -> Eff (e :& es) r)

newtype Wrap2 a b es r r'
= Wrap2 (forall e. Linearly a b r e %1 -> LEff (e :& es) r')
= Wrap2 (forall e. Linearly a b r e %1 -> Eff (e :& es) r')

linearly ::
forall es a b r r'.
(forall e. a -> Coroutine b a e -> Eff (e :& es) r) ->
(forall e. Linearly a b r e %1 -> LEff (e :& es) r') %1 ->
LEff es r'
(forall e. Linearly a b r e %1 -> Eff (e :& es) r') %1 ->
Eff es r'
linearly x y = linearlyWrapL (Wrap1 x) (Wrap2 y)

linearlyWrapL ::
forall es a b r r'.
Wrap1 a b es r ->
Wrap2 a b es r r' %1 ->
LEff es r'
Eff es r'
linearlyWrapL x = Unsafe.Linear.toLinear (linearlyWrap x)

linearlyWrap ::
forall es a b r r'.
Wrap1 a b es r ->
Wrap2 a b es r r' ->
LEff es r'
Eff es r'
linearlyWrap (Wrap1 w1) (Wrap2 w2_) = linearlyImpl w1 w2_

linearlyImpl ::
forall es a b r r'.
(forall e. a -> Coroutine b a e -> Eff (e :& es) r) ->
(forall e. Linearly a b r e %1 -> LEff (e :& es) r') ->
LEff es r'
(forall e. Linearly a b r e %1 -> Eff (e :& es) r') ->
Eff es r'
linearlyImpl m1 m2 = unsafeProvideIO $ \io -> do
av <- effIO io newEmptyMVar
bv <- effIO io newEmptyMVar
Expand Down
4 changes: 2 additions & 2 deletions bluefin-internal/src/Bluefin/Internal/Examples.hs
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ alternate ::
Stream String e3 ->
Linearly () a1 () e1 %1 ->
Linearly () a2 () e2 %1 ->
LEff es ()
Eff es ()
alternate y l1 l2 =
yieldLinearly l1 () L.>>= \case
Right (Ur r) -> L.do
Expand All @@ -707,7 +707,7 @@ yieldAll ::
(e1 :> es, e2 :> es, Show a) =>
Stream String e1 ->
Linearly () a () e2 %1 ->
LEff es ()
Eff es ()
yieldAll y l =
yieldLinearly l () L.>>= \case
Right (Ur r) -> L.do
Expand Down

0 comments on commit ae0e212

Please sign in to comment.