bluefin 0.7.0.0 → 0.7.0.1
raw patch · 4 files changed
+46/−38 lines, 4 filesdep ~bluefin-internalPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: bluefin-internal
API changes (from Hackage documentation)
- Bluefin.Capability.Ask: type Ask = Reader :: Type -> k -> Type
+ Bluefin.Capability.Ask: type Ask = Reader
- Bluefin.Capability.AskCapability: type AskCapability = HandleReader :: k -> Type -> k -> Type
+ Bluefin.Capability.AskCapability: type AskCapability = HandleReader
- Bluefin.HandleReader: data HandleReader (h :: k -> Type) (e :: k)
+ Bluefin.HandleReader: data HandleReader (h :: Effects -> Type) (e :: Effects)
- Bluefin.Reader: data Reader r (e :: k)
+ Bluefin.Reader: data Reader r (e :: Effects)
Files
- CHANGELOG.md +8/−0
- bluefin.cabal +2/−2
- src/Bluefin/Compound.hs +35/−35
- src/Bluefin/Jump.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,11 @@+# 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
bluefin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: bluefin-version: 0.7.0.0+version: 0.7.0.1 license: MIT license-file: LICENSE author: Tom Ellis@@ -56,6 +56,6 @@ Bluefin.System.IO, Bluefin.Writer, build-depends:- bluefin-internal >= 0.7 && < 0.8+ bluefin-internal >= 0.7 && < 0.9 hs-source-dirs: src default-language: Haskell2010
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@@ -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) =>@@ -537,7 +537,7 @@ -- k -- DynamicReader -- { askLRImpl = 'Bluefin.Reader.ask' h,- -- localLRImpl = \\f k' -> makeOp ('Bluefin.Reader.local' h f ('useImpl' k'))+ -- localLRImpl = \\f k' -> 'Bluefin.Reader.local' h f ('useImpl' k') -- } -- @
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