ea `shouldBe` (["Starting A", "A", "A2", "B", "lhs", "rhs", "Post-finally", "Post-finally", "Post-finally", "Post-finally", "Last one"], Right [(), (), (), ()])
describe "Raise" do
it "throws no errors when used simply" do
"s" === runEff $ runReader "s" $ runA (pure "a") $ raise do
ask
it "throws no errors when combined with other computations" do
"a" === runEff $ runReader "s" $ runA (pure "a") $ do
_ <- send A
_ <- raise $ ask @String
send A
runGauntlet :: Eff Traversable Traversable '[Choice, Throw (), Output [String], Collect] () -> ([String], Either () [()])
runGauntlet = runEff @([String], Either () [()]) . unrestrict @Traversable @Traversable implying . runCollect . runOutput @[String] . runThrow @() . collect
data A :: Effect where
A :: A m String
runA :: lb Identity => Eff lb ub es String -> Eff lb ub (A : es) a -> Eff lb ub es a
runA string = interpret_ \A -> string
data A2 :: Effect where
A2 :: A2 m ()
B2 :: A2 m ()
runA2 :: (Output [String] :> es, lb Identity) => Eff lb ub (A2 : es) a -> Eff lb ub es a
runA2 = interpret_ \case
A2 -> output ["A"]
B2 -> output ["B"]
runA2Throw :: (Throw () :> es, Output [String] :> es, lb Identity) => Eff lb ub (A2 : es) a -> Eff lb ub es a
runA2Throw = interpret_ \case
A2 -> output ["A"] >> throw ()
B2 -> output ["B"]
runA2Choice :: (Choice :> es, Output [String] :> es, lb Identity) => Eff lb ub (A2 : es) a -> Eff lb ub es a
runA2Choice = interpret_ \case
A2 -> output ["Starting A"] >> (output ["A"] <|> output ["A2"])
B2 -> output ["B"]