packages feed

bluefin-internal 0.9.0.0 → 0.9.1.0

raw patch · 4 files changed

+44/−1 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Bluefin.Internal: yieldToPureList :: (forall (e :: Effects). () => Yield a e -> Eff e r) -> ([a], r)

Files

CHANGELOG.md view
@@ -1,3 +1,17 @@+# 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.8.2.0  * Improve performance of `Reader` and `DslBuilderEff`
bluefin-internal.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               bluefin-internal-version:            0.9.0.0+version:            0.9.1.0 license:            MIT license-file:       LICENSE author:             Tom Ellis
src/Bluefin/Internal.hs view
@@ -1334,6 +1334,12 @@   (as, r) <- yieldToReverseList f   pure (reverse as, r) +-- | Gather all yielded elements into a list, purely.  Can be used+-- when only when there are no other capabilities in scope, besides+-- the 'Yield'.+yieldToPureList :: (forall e. Yield a e -> Eff e r) -> ([a], r)+yieldToPureList f = runPureEff $ yieldToList $ \y -> useImpl (f y)+ -- | -- @ -- >>> runPureEff $ withYieldToList $ \\y -> do@@ -2051,6 +2057,8 @@   Eff es r runAskCapability = runHandleReader +-- | Do not use @askCapability@.  It is unsafe and will be removed in+-- a future version.  Use 'asksCapability' instead. askCapability ::   (e <: es, Handle h) =>   HandleReader h e ->
test/Main.hs view
@@ -34,12 +34,21 @@       "List"       (runPureEff (yieldToList (listEff ([20, 30, 40], "Hello"))))       ([20, 30, 40], "Hello")+    assertEqual'+      "Pure list"+      ( yieldToPureList $ \y -> do+          yield y 20+          yield y 30+          pure "Hello"+      )+      ([20, 30], "Hello")      test_localInHandler y     test_generalBracket io y     test_streamConsumeReader y     test_streamConsumeHandleReader y     test_unliftIOReader io y+    test_askCapabilityEscape y  (!?) :: [a] -> Int -> Maybe a xs !? i = runPureEff $@@ -175,3 +184,15 @@             assertEqual spech "myLocal" i i'         )         (\x -> effToIO . local r (const x) . effIO io)++test_askCapabilityEscape :: (e <: es) => SpecH e -> Eff es ()+test_askCapabilityEscape y = runConstEffect False $ \cFalse ->+  runAskCapability cFalse $ \(ac :: HandleReader (ConstEffect Bool) e) -> do+    -- We should not be allowed to escape `escaped` like this.  A+    -- future version of Bluefin should fix this by removing+    -- `askCapability`.+    escaped <- runConstEffect True $ \cTrue -> do+      localCapability ac (const (mapHandle cTrue)) $ do+        useImpl (askCapability @_ @e ac)+    let MkConstEffect escapedValue = escaped+    assertEqual y "askCapability escape" True escapedValue