packages feed

bluefin 0.9.1.0 → 0.10.1.0

raw patch · 15 files changed

Files

CHANGELOG.md view
@@ -1,3 +1,21 @@+# 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`
bluefin.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               bluefin-version:            0.9.1.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.9.1.0 && < 0.10+      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/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/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
@@ -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@@ -536,8 +536,8 @@     --     'useImplIn'     --       k     --       DynamicReader-    --         { askLRImpl = 'Bluefin.Reader.ask' h,-    --           localLRImpl = \\f k' -> 'Bluefin.Reader.local' h f ('useImpl' k')+    --         { askLRImpl = 'Bluefin.Capability.Ask.ask' h,+    --           localLRImpl = \\f k' -> 'Bluefin.Capability.Ask.local' h f ('useImpl' k')     --         }     -- @ 
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/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