bluefin 0.6.0.0 → 0.10.1.0
raw patch · 18 files changed
Files
- CHANGELOG.md +51/−0
- bluefin.cabal +3/−4
- src/Bluefin.hs +2/−2
- src/Bluefin/Capability/AskCapability.hs +3/−1
- src/Bluefin/Capability/Await.hs +1/−1
- src/Bluefin/Capability/ThrowCatch.hs +33/−0
- src/Bluefin/Capability/Yield.hs +1/−0
- src/Bluefin/CloneableHandle.hs +7/−7
- src/Bluefin/Compound.hs +39/−38
- src/Bluefin/DslBuilder.hs +9/−9
- src/Bluefin/DslBuilderEff.hs +1/−0
- src/Bluefin/GadtEffect.hs +4/−4
- src/Bluefin/HandleReader.hs +3/−1
- src/Bluefin/Jump.hs +1/−1
- src/Bluefin/Pipes.hs +0/−51
- src/Bluefin/Pipes/Prelude.hs +0/−51
- src/Bluefin/Prim.hs +11/−11
- src/Bluefin/StateSource.hs +3/−3
CHANGELOG.md view
@@ -1,3 +1,54 @@+# 0.10.1.0++* Add `Bluefin.DslBuilderEff.runDslBuilderEffMappedArgs`++* Add `Bluefin.Capability.ThrowCatch`++# 0.10.0.0++* Make `Ask`, `AskCapability`, `Await`, `JumpTo`, `Modify`, `Request`,+ `ReturnEarly`, `Tell`, `Throw`, and `Yield` the canonical capability+ types; `Reader`, `HandleReader`, `Consume`, `Jump`, `State`, `Coroutine`,+ `EarlyReturn`, `Writer`, `Exception`, and `Stream` are now type synonyms.++* Move `Bluefin.Pipes` and `Bluefin.Pipes.Prelude` to `bluefin-examples`++* Breaking change: separate `Prim`'s primitive state and capability+ scope type parameters++# 0.9.1.0++* Add `yieldToPureList`++# 0.9.0.0++* Add quantified constraint `forall e es. (e <: es) => OneWayCoercible+ (h e) (h es)` as a superclass of `Handle h`++* Improve performance of `mapHandle` by using `unsafeOneWayCoerce`.+ This can violate type safety if a `OneWayCoercibleInstance` is+ invalid, so do not define or use invalid `OneWayCoercible`+ instances!++# 0.7.1.0++* Add `Bluefin.Compound.oneWayCoercibleNewtypeHandle`++# 0.7.0.1++* Update `Bluefin.Compound` documentation++* Restrict Reader type tag to Effects. This is technically a breaking+ change, but it is extremely unlikely any consumers will be broken by+ it.++# 0.7.0.0++* Fix `Reader` bug that caused incorrect scoping in+ `awaitYield`/`connectRequests`/`streamConsume`/`connectCoroutines`++ <https://github.com/tomjaguarpaw/bluefin/issues/98>+ # 0.6.0.0 * Changed type of `runEff` to match `runEff_`
bluefin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: bluefin-version: 0.6.0.0+version: 0.10.1.0 license: MIT license-file: LICENSE author: Tom Ellis@@ -25,6 +25,7 @@ Bluefin.Capability.Ask, Bluefin.Capability.AskCapability, Bluefin.Capability.Await,+ Bluefin.Capability.ThrowCatch, Bluefin.Capability.JumpTo, Bluefin.Capability.Modify, Bluefin.Capability.Request,@@ -46,8 +47,6 @@ Bluefin.HandleReader, Bluefin.IO, Bluefin.Jump,- Bluefin.Pipes,- Bluefin.Pipes.Prelude, Bluefin.Prim, Bluefin.Reader, Bluefin.State,@@ -56,6 +55,6 @@ Bluefin.System.IO, Bluefin.Writer, build-depends:- bluefin-internal >= 0.6 && < 0.7+ bluefin-internal >= 0.11 && < 0.12 hs-source-dirs: src default-language: Haskell2010
src/Bluefin.hs view
@@ -743,7 +743,7 @@ -- IOE e3 -> -- Eff es () -- incrementReadLine state exception io = do- -- 'Bluefin.Jump.withJump' $ \\break -> 'Control.Monad.forever' $ do+ -- 'Bluefin.Capability.JumpTo.withJumpTo' $ \\break -> 'Control.Monad.forever' $ do -- line <- 'Bluefin.IO.effIO' io getLine -- i <- case 'Text.Read.readMaybe' line of -- Nothing ->@@ -752,7 +752,7 @@ -- pure i -- -- when (i == 0) $- -- 'Bluefin.Jump.jumpTo' break+ -- 'Bluefin.Capability.JumpTo.jumpTo' break -- -- 'Bluefin.Capability.Modify.modify' state (+ i) -- @
src/Bluefin/Capability/AskCapability.hs view
@@ -20,9 +20,11 @@ runAskCapability, -- * Effectful operations- askCapability, asksCapability, localCapability,++ -- * Deprecated versions+ askCapability, ) where
src/Bluefin/Capability/Await.hs view
@@ -4,7 +4,7 @@ -- @await@ from Conduit or Pipes. -- -- For information about prompt finalization/resource safety when- -- using Bluefin @Consume@s, see "Bluefin.Coroutine".+ -- using Bluefin @Await@s, see "Bluefin.Capability.Request". -- * Capability Await,
+ src/Bluefin/Capability/ThrowCatch.hs view
@@ -0,0 +1,33 @@+-- | You probably don't want to use this module, rather you'll want+-- "Bluefin.Capability.Throw" for most exception use+-- cases. @ThrowCatch@ exists mainly to support @MonadError@+-- instances.+module Bluefin.Capability.ThrowCatch+ ( -- * Capability+ ThrowCatch,++ -- * Handlers+ try,+ handle,+ catch,++ -- * Effectful operations+ throw,++ -- * Local handling+ localTry,+ localCatch,+ localHandle,+ )+where++import Bluefin.Internal.Capability.ThrowCatch+ ( ThrowCatch,+ handle,+ catch,+ localCatch,+ localHandle,+ localTry,+ throw,+ try,+ )
src/Bluefin/Capability/Yield.hs view
@@ -15,6 +15,7 @@ -- * Handlers forEach, yieldToList,+ yieldToPureList, yieldToReverseList, withYieldToList, ignoreYield,
src/Bluefin/CloneableHandle.hs view
@@ -38,28 +38,28 @@ -- -- @ -- example :: IO ()- -- example = 'Bluefin.Eff.runEff' $ \\io -> 'Bluefin.State.evalState' 0 $ \\st -> do- -- r \<- 'Bluefin.Exception.try' $ \\ex -> do+ -- example = 'Bluefin.Eff.runEff' $ \\io -> 'Bluefin.Capability.Modify.evalModify' 0 $ \\st -> do+ -- r \<- 'Bluefin.Capability.Throw.try' $ \\ex -> do -- bluefinRace -- io -- (MkMyHandle ('Bluefin.Handle.mapHandle' ex) (mapHandle st)) -- ( \\_ (MkMyHandle ex' st') -> do- -- 'Bluefin.State.modify' st' (subtract 2000)- -- 'Bluefin.Exception.throw' ex' "Aborting from branch 1"+ -- 'Bluefin.Capability.Modify.modify' st' (subtract 2000)+ -- 'Bluefin.Capability.Throw.throw' ex' "Aborting from branch 1" -- ) -- ( \\_ (MkMyHandle _ st') -> do -- modify st' (+ 3000) -- pure (2 :: Int) -- ) --- -- s <- 'Bluefin.State.get' st+ -- s <- 'Bluefin.Capability.Modify.get' st -- 'Bluefin.IO.effIO' io (print r) -- effIO io (putStrLn ("State started at 0 and was cloned. Now: " <> show s)) -- @ -- -- You can see from the output that the actions were raced as- -- expected, and the @State@ was cloned so that changes to it in- -- the branches of @race@ did not affect the original @State@.+ -- expected, and the @Modify@ capability was cloned so that changes to it+ -- in the branches of @race@ did not affect the original capability. -- -- @ -- -- Run one time (the first thread was faster)
src/Bluefin/Compound.hs view
@@ -14,7 +14,7 @@ -- newtype Counter1 e = MkCounter1 ('Bluefin.Capability.Modify.Modify' Int e) -- -- incCounter1 :: (e \<: es) => Counter1 e -> 'Bluefin.Eff.Eff' es ()- -- incCounter1 (MkCounter1 st) = 'Bluefin.Capability.Modify..modify' st (+ 1)+ -- incCounter1 (MkCounter1 st) = 'Bluefin.Capability.Modify.modify' st (+ 1) -- -- runCounter1 :: -- (forall e. Counter1 e -> Eff (e :& es) r) ->@@ -30,7 +30,7 @@ -- -- @ -- exampleCounter1 :: Int- -- exampleCounter1 = 'Bluefin.Eff.runPureEff' $ runCounter1 $ \\c ->+ -- exampleCounter1 = 'Bluefin.Eff.runPureEff' $ runCounter1 $ \\c -> do -- incCounter1 c -- incCounter1 c -- incCounter1 c@@ -47,7 +47,7 @@ -- normal approach we use to wrap multiple values into a single -- value: define a new data type with multiple fields. There's a -- caveat to this approach, but before we address the caveat let's- -- see the approach in action. Here we define a new capabiilty,+ -- see the approach in action. Here we define a new capability, -- @Counter2@, that contains a 'Bluefin.Capability.Modify.Modify' and 'Bluefin.Capability.Throw.Throw' capability -- within it. That allows us to increment the counter and throw -- an exception when we hit a limit.@@ -57,7 +57,7 @@ -- -- incCounter2 :: (e1 \<: es, e2 \<: es) => Counter2 e1 e2 -> 'Bluefin.Eff.Eff' es () -- incCounter2 (MkCounter2 st ex) = do- -- count <- 'Bluefin.Capabiilty.Modify.get' st+ -- count <- 'Bluefin.Capability.Modify.get' st -- when (count >= 10) $ -- 'Bluefin.Capability.Throw.throw' ex () -- 'Bluefin.Capability.Modify.put' st (count + 1)@@ -72,7 +72,7 @@ -- 'Bluefin.Capability.Modify.get' st -- @ --- -- We can see that attempting to increment the counter fovever+ -- We can see that attempting to increment the counter forever -- bails out when we reach the limit. -- -- @@@ -97,7 +97,7 @@ -- expose a single one. To make this work we have to define our -- handler in a slightly different way. Firstly we apply -- 'useImplIn' to the effectful operation @k@ and secondly we- -- apply 'mapHandle' to each of the capabiilties out of which we create+ -- apply 'mapHandle' to each of the capabilities out of which we create -- our compound capability. Everything else remains the same. -- -- @@@ -183,7 +183,7 @@ -- | We can wrap multiple effects, handle some of them and leave -- the others to be handled later. Let's extend @Counter3@ with a- -- 'Bluefin.Stream.Stream' effect. Whenever we ask to+ -- 'Bluefin.Capability.Yield.Yield' effect. Whenever we ask to -- increment the counter, and it is currently an even number, then -- we yield a message about that. Additionally, there's a new -- operation @getCounter4@ which allows us to yield a message@@ -191,14 +191,14 @@ -- -- @ -- data Counter4 e- -- = MkCounter4 ('Bluefin.Capability.Modify.Modify' Int e) ('Bluefin.Capability.Throw.Throw' () e) ('Bluefin.Stream.Stream' String e)+ -- = MkCounter4 ('Bluefin.Capability.Modify.Modify' Int e) ('Bluefin.Capability.Throw.Throw' () e) ('Bluefin.Capability.Yield.Yield' String e) -- -- incCounter4 :: (e \<: es) => Counter4 e -> Eff es () -- incCounter4 (MkCounter4 st ex y) = do -- count <- 'Bluefin.Capability.Modify.get' st -- -- when (even count) $- -- 'Bluefin.Stream.yield' y "Count was even"+ -- 'Bluefin.Capability.Yield.yield' y "Count was even" -- -- when (count >= 10) $ -- 'Bluefin.Capability.Throw.throw' ex ()@@ -212,7 +212,7 @@ -- -- runCounter4 :: -- (e1 \<: es) =>- -- Stream String e1 ->+ -- Yield String e1 -> -- (forall e. Counter4 e -> Eff (e :& es) r) -> -- Eff es Int -- runCounter4 y k =@@ -224,7 +224,7 @@ -- -- @ -- exampleCounter4 :: ([String], Int)- -- exampleCounter4 = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Stream.yieldToList' $ \\y -> do+ -- exampleCounter4 = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Capability.Yield.yieldToList' $ \\y -> do -- runCounter4 y $ \\c -> do -- incCounter4 c -- incCounter4 c@@ -249,7 +249,7 @@ -- define the record in the handler. Here @incCounter5Impl@ and -- @getCounter5Impl@ are exactly the same as @incCounter4@ and -- @getCounter4@ were, they're just defined in the handler. In- -- order to be used polymorphically, the actually effectful+ -- order to be used polymorphically, the actual effectful -- functions we call, @incCounter5@ and @getCounter5@ are derived -- from the record fields. --@@ -272,7 +272,7 @@ -- -- runCounter5 :: -- (e1 \<: es) =>- -- Stream String e1 ->+ -- Yield String e1 -> -- (forall e. Counter5 e -> Eff (e :& es) r) -> -- Eff es Int -- runCounter5 y k =@@ -285,7 +285,7 @@ -- count <- 'Bluefin.Capability.Modify.get' st -- -- when (even count) $- -- 'Bluefin.Stream.yield' y "Count was even"+ -- 'Bluefin.Capability.Yield.yield' y "Count was even" -- -- when (count >= 10) $ -- 'Bluefin.Capability.Throw.throw' ex ()@@ -303,13 +303,13 @@ -- -- @ -- exampleCounter5 :: ([String], Int)- -- exampleCounter5 = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Stream.yieldToList' $ \\y -> do+ -- exampleCounter5 = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Capability.Yield.yieldToList' $ \\y -> do -- runCounter5 y $ \\c -> do -- incCounter5 c -- incCounter5 c -- n <- getCounter5 c "I'm getting the counter" -- when (n == 2) $- -- pyield y "n was 2, as expected"+ -- yield y "n was 2, as expected" -- @ -- -- @@@ -322,13 +322,13 @@ -- | We can also freely combine concrete and dynamic effects. In -- the following example, the @incCounter6@ effect is left -- dynamic, and defined in the handler, whilst @getCounter6@ is- -- implemented in terms of concrete 'Bluefin.Capability.Modify.Modify' and 'Bluefin.Stream.Stream' effects.+ -- implemented in terms of concrete 'Bluefin.Capability.Modify.Modify' and 'Bluefin.Capability.Yield.Yield' effects. -- -- @ -- data Counter6 e = MkCounter6 -- { incCounter6Impl :: 'Bluefin.Eff.Eff' e (),- -- counter6State :: 'Bluefin.Capability.Modify.Modify' Int e,- -- counter6Stream :: 'Bluefin.Stream.Stream' String e+ -- counter6Modify :: 'Bluefin.Capability.Modify.Modify' Int e,+ -- counter6Yield :: 'Bluefin.Capability.Yield.Yield' String e -- } -- deriving (Generic) -- deriving (Handle) via 'OneWayCoercibleHandle' Counter6@@ -346,7 +346,7 @@ -- -- runCounter6 :: -- (e1 \<: es) =>- -- Stream String e1 ->+ -- Yield String e1 -> -- (forall e. Counter6 e -> Eff (e :& es) r) -> -- Eff es Int -- runCounter6 y k =@@ -359,14 +359,14 @@ -- count <- 'Bluefin.Capability.Modify.get' st -- -- when (even count) $- -- 'Bluefin.Stream.yield' y "Count was even"+ -- 'Bluefin.Capability.Yield.yield' y "Count was even" -- -- when (count >= 10) $ -- 'Bluefin.Capability.Throw.throw' ex () -- -- 'Bluefin.Capability.Modify.put' st (count + 1),- -- counter6State = mapHandle st,- -- counter6Stream = mapHandle y+ -- counter6Modify = mapHandle st,+ -- counter6Yield = mapHandle y -- } -- ) -- get st@@ -376,7 +376,7 @@ -- -- @ -- exampleCounter6 :: ([String], Int)- -- exampleCounter6 = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Stream.yieldToList' $ \\y -> do+ -- exampleCounter6 = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Capability.Yield.yieldToList' $ \\y -> do -- runCounter6 y $ \\c -> do -- incCounter6 c -- incCounter6 c@@ -399,8 +399,8 @@ -- @ -- data Counter7 e = MkCounter7 -- { incCounter7Impl :: forall e'. 'Bluefin.Capability.Throw.Throw' () e' -> 'Bluefin.Eff.Eff' (e' :& e) (),- -- counter7State :: 'Bluefin.Capability.Modify.Modify' Int e,- -- counter7Stream :: 'Bluefin.Stream.Stream' String e+ -- counter7Modify :: 'Bluefin.Capability.Modify.Modify' Int e,+ -- counter7Yield :: 'Bluefin.Capability.Yield.Yield' String e -- } -- deriving (Handle) via OneWayCoercibleHandle Counter7 --@@ -412,8 +412,8 @@ -- oneWayCoercibleImpl = oneWayCoercibleTrustMe $ \\c -> -- MkCounter7 -- { incCounter7Impl = \\ex -> 'useImplUnder' (incCounter7Impl c ex),- -- counter7State = 'mapHandle' (counter7State c),- -- counter7Stream = mapHandle (counter7Stream c)+ -- counter7Modify = 'mapHandle' (counter7Modify c),+ -- counter7Yield = mapHandle (counter7Yield c) -- } -- -- incCounter7 ::@@ -427,7 +427,7 @@ -- -- runCounter7 :: -- (e1 \<: es) =>- -- Stream String e1 ->+ -- Yield String e1 -> -- (forall e. Counter7 e -> Eff (e :& es) r) -> -- Eff es Int -- runCounter7 y k =@@ -440,14 +440,14 @@ -- count \<- 'Bluefin.Capability.Modify.get' st -- -- when (even count) $- -- 'Bluefin.Stream.yield' y "Count was even"+ -- 'Bluefin.Capability.Yield.yield' y "Count was even" -- -- when (count >= 10) $ -- 'Bluefin.Capability.Throw.throw' ex () -- -- 'Bluefin.Capability.Modify.put' st (count + 1),- -- counter7State = mapHandle st,- -- counter7Stream = mapHandle y+ -- counter7Modify = mapHandle st,+ -- counter7Yield = mapHandle y -- } -- ) -- get st@@ -457,7 +457,7 @@ -- -- @ -- exampleCounter7A :: ([String], Int)- -- 'exampleCounter7A = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Stream.yieldToList' $ \\y -> do+ -- exampleCounter7A = 'Bluefin.Eff.runPureEff' $ 'Bluefin.Capability.Yield.yieldToList' $ \\y -> do -- handle (\\() -> pure (-42)) $ \\ex -> -- runCounter7 y $ \\c -> do -- incCounter7 c ex@@ -490,7 +490,7 @@ -- effectful operations as arguments, by giving the effectful -- operation the effect tag @e'@. Here's an example of a dynamic -- reader effect, and one handler for the effect, which runs it in- -- terms of the existing 'Bluefin.Reader' effect.+ -- terms of the existing 'Bluefin.Capability.Ask' effect. -- -- @ -- data DynamicReader r e = DynamicReader@@ -517,7 +517,7 @@ -- (e \<: es) => -- DynamicReader r e -> -- Eff es r- -- askLR c = 'makeOp' (askLRImpl ('mapHandle' c))+ -- askLR c = askLRImpl ('mapHandle' c) -- -- localLR :: -- (e \<: es) =>@@ -536,8 +536,8 @@ -- 'useImplIn' -- k -- DynamicReader- -- { askLRImpl = 'Bluefin.Reader.ask' h,- -- localLRImpl = \\f k' -> makeOp ('Bluefin.Reader.local' h f ('useImpl' k'))+ -- { askLRImpl = 'Bluefin.Capability.Ask.ask' h,+ -- localLRImpl = \\f k' -> 'Bluefin.Capability.Ask.local' h f ('useImpl' k') -- } -- @ @@ -677,9 +677,9 @@ OneWayCoercible.OneWayCoercible (OneWayCoercible.oneWayCoercibleImpl), OneWayCoercibleHandle (MkOneWayCoercibleHandle), handleOneWayCoercible,- withHandle, OneWayCoercible.gOneWayCoercible, oneWayCoercibleTrustMe,+ oneWayCoercibleNewtypeHandle, -- | Bluefin re-exports @Generic@ for convenience. OneWayCoercible.Generic, @@ -696,6 +696,7 @@ runCompound, withCompound, useImplWithin,+ withHandle, ) where
src/Bluefin/DslBuilder.hs view
@@ -181,7 +181,7 @@ -- @ArenaH@? It is defined like this: -- -- @- -- data ArenaH e = MkArenaH ('Bluefin.Stream.Stream' RobotEntry e) (Stream ObstacleEntry e)+ -- data ArenaH e = MkArenaH ('Bluefin.Capability.Yield.Yield' RobotEntry e) (Yield ObstacleEntry e) -- deriving t'Bluefin.Compound.Generic' -- deriving t'Bluefin.Compound.Handle' via t'Bluefin.Compound.OneWayCoercibleHandle' ArenaH --@@ -191,7 +191,7 @@ -- -- What does that mean? Well, @ArenaH@ is defined according to one -- of the recipes from "Bluefin.Compound", and gives the ability- -- to yield to a @Stream@ of @RobotEntry@s and a stream of+ -- to yield to a @Yield@ of @RobotEntry@s and a yield of -- @ObstacleEntry@s, i.e. the components that make up an @Arena@. -- The only things we can do with the @ArenaH@ then are to give it -- @RobotEntry@s or @ObstacleEntry@s. How do we get them?@@ -213,7 +213,7 @@ -- @ -- obstacle o coord = -- MkArenaBuilder $ 'dslBuilder' $ \(MkArenaH _ yobstacle) -> do- -- 'Bluefin.Stream.yield' yobstacle (o, coord)+ -- 'Bluefin.Capability.Yield.yield' yobstacle (o, coord) -- @ -- *** @robot@ and @InstructionsBuilder@@@ -244,7 +244,7 @@ -- capability, this time @InstructionsH@: -- -- @- -- data InstructionsH e = MkInstructionsH ('Bluefin.Stream.Stream' Instruction e)+ -- data InstructionsH e = MkInstructionsH ('Bluefin.Capability.Yield.Yield' Instruction e) -- deriving t'Bluefin.Compound.Generic' -- deriving t'Bluefin.Compound.Handle' via t'Bluefin.Compound.OneWayCoercibleHandle' InstructionsH --@@ -256,15 +256,15 @@ -- @Instruction@s, i.e. the type of robot instructions defined -- above and used in @Arena@ via @RobotEntry@. In fact, the job -- of @robot@ is exactly to allow us to define a @RobotEntry@ and- -- yield it to the @Stream RobotEntry@ of @Arena@:+ -- yield it to the @Yield RobotEntry@ of @Arena@: -- -- @ -- robot name coords dir (MkInstructionsBuilder ibuilder) = -- MkArenaBuilder $ 'dslBuilder' $ \\(MkArenaH yrobot _) -> do- -- (insns, ()) \<- 'Bluefin.Stream.yieldToList' $ \\yinsns -> do+ -- (insns, ()) \<- 'Bluefin.Capability.Yield.yieldToList' $ \\yinsns -> do -- 'runDslBuilder' (MkInstructionsH ('Bluefin.Compound.mapHandle' yinsns)) ibuilder --- -- 'Bluefin.Stream.yield' yrobot (name, coords, dir, insns)+ -- 'Bluefin.Capability.Yield.yield' yrobot (name, coords, dir, insns) -- @ -- *** Creating @InstructionsBuilder@s@@ -305,7 +305,7 @@ -- *** Implementing @buildArena@ -- | We're now ready to implement @buildArena@. We create a- -- @Stream RobotEntry@ and a @Stream ObstacleEntry@ to pass to the+ -- @Yield RobotEntry@ and a @Yield ObstacleEntry@ to pass to the -- @MkArenaH@ constructor, and use @runDslBuilder@ to run the -- @ArenaBuilder@ provided. (This is a lot like some of the approaches -- in "Bluefin.Compound".)@@ -313,7 +313,7 @@ -- @ -- buildArena :: ArenaBuilder -> Arena -- buildArena (MkArenaBuilder arenaBuilder) = runPureEff $ do- -- (robots, obstacles) \<- 'Bluefin.Stream.yieldToList' $ \\yrobots -> do+ -- (robots, obstacles) \<- 'Bluefin.Capability.Yield.yieldToList' $ \\yrobots -> do -- (obstacles, ()) \<- yieldToList $ \\yobstacles -> do -- 'runDslBuilder' -- (MkArenaH ('Bluefin.Compound.mapHandle' yrobots) (mapHandle yobstacles))
src/Bluefin/DslBuilderEff.hs view
@@ -4,6 +4,7 @@ ( DslBuilderEff, dslBuilderEff, runDslBuilderEff,+ runDslBuilderEffMappedArgs, ) where
src/Bluefin/GadtEffect.hs view
@@ -98,7 +98,7 @@ -- forall es e1 e2 r. -- (e1 \<: es, e2 \<: es) => -- t'Bluefin.IO.IOE' e1 ->- -- t'Bluefin.Exception.Exception' t'Control.Exception.IOException' e2 ->+ -- t'Bluefin.Capability.Throw.Throw' t'Control.Exception.IOException' e2 -> -- (forall e. 'Send' FileSystem e -> Eff (e :& es) r) -> -- Eff es r -- runFileSystem io ex = 'interpret' $ \\case@@ -186,7 +186,7 @@ -- augmentOp2Interpose :: -- (e1 \<: es, e2 \<: es) => -- IOE e2 ->- -- t'Bluefin.HandleReader.HandleReader' (Send E) e1 ->+ -- t'Bluefin.Capability.AskCapability.AskCapability' (Send E) e1 -> -- Eff es r -> -- Eff es r -- augmentOp2Interpose io = 'interpose' $ \\fc -> \\case@@ -209,8 +209,8 @@ -- augmentOp2Interpret io fc $ \\fc' -> action fc' -- -- effIO io (putStrLn "-- interpose:")- -- runE io $ \\fc -> 'Bluefin.HandleReader.runHandleReader' fc $ \\hr -> do- -- augmentOp2Interpose io hr $ 'Bluefin.HandleReader.asksHandle' hr action+ -- runE io $ \\fc -> 'Bluefin.Capability.AskCapability.runAskCapability' fc $ \\hr -> do+ -- augmentOp2Interpose io hr $ 'Bluefin.Capability.AskCapability.asksCapability' hr action -- @ -- -- @
src/Bluefin/HandleReader.hs view
@@ -24,9 +24,11 @@ runHandleReader, -- * Effectful operations- askHandle, asksHandle, localHandle,++ -- ** Deprecated+ askHandle, ) where
src/Bluefin/Jump.hs view
@@ -1,5 +1,5 @@ -- | This is an old interface and will be deprecated in the--- future. You are encouraged to use "Bluefin.Capability.Jump" instead.+-- future. You are encouraged to use "Bluefin.Capability.JumpTo" instead. module Bluefin.Jump ( -- | 'Jump' allows you to jump back to a previously-set location. -- A "jump" is equivalent to an untyped early return, or more
− src/Bluefin/Pipes.hs
@@ -1,51 +0,0 @@--- | Reimplementation of the @pipes@ (@Pipes@) ecosystem in Bluefin.------ You should not use this module. It will be deprecated and removed--- in future versions.------ This module is just an example of what you can do with Bluefin and--- as such it should be obtained from--- [@bluefin-examples@](https://github.com/tomjaguarpaw/bluefin/tree/master/bluefin-examples)--- if you want it. Instead of using it directly you are recommended--- to use------ * t'Bluefin.Capability.Yield.Yield', 'Bluefin.Capability.Yield.yield'--- * t'Bluefin.Capability.Await.Await', 'Bluefin.Capability.Await.await'--- * 'Bluefin.Capability.Yield.awaitYield'--- * For advanced cases only, t'Bluefin.Capability.Request.Request',--- 'Bluefin.Capability.Request.request' and--- 'Bluefin.Capability.Request.connectRequests'------ See also "Bluefin.Pipes.Prelude".-module Bluefin.Pipes- ( -- * The Proxy handle- Proxy,- Effect,- runEffect,-- -- ** Producers- Producer,- yield,- for,- (~>),- (<~),-- -- ** Consumers- Consumer,- await,- (>~),- (~<),-- -- ** Pipes- Pipe,- cat,- (>->),- (<-<),-- -- * Utilities- next,- each,- )-where--import Bluefin.Internal.Pipes
− src/Bluefin/Pipes/Prelude.hs
@@ -1,51 +0,0 @@--- | Reimplementation of the @pipes@ (@Pipes@) ecosystem in Bluefin.------ You should not use this module. It will be deprecated and removed--- in future versions.------ This module is just an example of what you can do with Bluefin and--- as such it should be obtained from--- [@bluefin-examples@](https://github.com/tomjaguarpaw/bluefin/tree/master/bluefin-examples)--- if you want it. Instead of using it directly you are recommended--- to use------ * t'Bluefin.Capability.Yield.Yield', 'Bluefin.Capability.Yield.yield'--- * t'Bluefin.Capability.Await.Await', 'Bluefin.Capability.Await.await'--- * 'Bluefin.Capability.Yield.awaitYield'--- * For advanced cases only, t'Bluefin.Capability.Request.Request',--- 'Bluefin.Capability.Request.request' and--- 'Bluefin.Capability.Request.connectRequests'------ See also "Bluefin.Pipes".------ @--- >>> 'Bluefin.Eff.runEff' $ \\io -> 'runEffect' $ do--- 'stdinLn' io >-> 'takeWhile'' (/= "quit") >-> 'stdoutLn' io--- Test--- Test--- ABC--- ABC--- quit--- "quit"--- @-module Bluefin.Pipes.Prelude- ( -- * Producers- stdinLn,- repeatM,- replicateM,- unfoldr,-- -- * Consumers- stdoutLn,- mapM_,- print,- drain,-- -- * Pipes- map,- mapM,- takeWhile',- )-where--import Bluefin.Internal.Pipes
src/Bluefin/Prim.hs view
@@ -2,33 +2,33 @@ -- -- @ -- -- Define a capability which includes Prim--- data ExAndPrim e = MkExAndPrim (Exception String e) (P.Prim e)+-- data ExAndPrim e1 e2 = MkExAndPrim (Throw String e2) (P.Prim e1 e2) -- -- Give it a Handle instance, as per Bluefin.Compound--- deriving (Handle) via OneWayCoercibleHandle ExAndPrim+-- deriving (Handle) via OneWayCoercibleHandle (ExAndPrim e1) -- deriving stock (Generic) ----- instance (e \<: es) => OneWayCoercible (ExAndPrim e) (ExAndPrim es) where+-- instance (e2 \<: es) => OneWayCoercible (ExAndPrim e1 e2) (ExAndPrim e1 es) where -- oneWayCoercibleImpl = gOneWayCoercible -- -- -- Define a monad M containing the Prim capability--- newtype M e es a = MkM (ReaderT (ExAndPrim e) (Eff es) a)+-- newtype M e a = MkM (DslBuilder (ExAndPrim e) a) -- deriving newtype (Functor, Applicative, Monad) -- -- -- Define a way of running M -- runM :: -- (e1 \<: es, e2 \<: es) =>--- Exception String e1 ->--- P.Prim e2 ->--- M es es r ->+-- Throw String e1 ->+-- P.Prim e e2 ->+-- M e r -> -- Eff es r -- runM ex prim (MkM m) =--- runReaderT m (MkExAndPrim (mapHandle ex) (mapHandle prim))+-- runDslBuilder (MkExAndPrim (mapHandle ex) (mapHandle prim)) m -- -- -- Give M a PrimMonad instance--- instance (e \<: es) => PrimMonad (M e es) where--- type PrimState (M e es) = P.PrimStateEff e+-- instance PrimMonad (M e) where+-- type PrimState (M e) = P.PrimStateEff e -- primitive f =--- MkM (ReaderT (\\(MkExAndPrim _ prim) -> P.'primitive' prim f))+-- MkM (dslBuilder (\\(MkExAndPrim _ prim) -> P.'primitive' prim f)) -- -- -- ghci> example -- -- Right [\"Hello\",\"World\"]
src/Bluefin/StateSource.hs view
@@ -1,9 +1,9 @@ module Bluefin.StateSource ( -- | A 'StateSource' allows you to allocate new- -- t'Bluefin.State.State' handles, much like t'Control.Monad.ST'+ -- t'Bluefin.Capability.Modify.Modify' handles, much like t'Control.Monad.ST' -- allows you to allocate new 'Data.STRef.STRef's. This can be- -- useful when you want to avoid nested 'Bluefin.State.runState'- -- (or `Bluefin.State.evalState') blocks, or you need a number+ -- useful when you want to avoid nested 'Bluefin.Capability.Modify.runModify'+ -- (or `Bluefin.Capability.Modify.evalModify') blocks, or you need a number -- of mutable states that is only dynamically known. -- * Handle