packages feed

bluefin-internal 0.1.2.0 → 0.2.0.0

raw patch · 5 files changed

+52/−6 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Bluefin.Internal: effTag :: forall (es :: Effects). Eff es (Proxy es)
+ Bluefin.Internal: handleTag :: forall {k} h (e :: k) (es :: Effects). h e -> Eff es (Proxy e)
+ Bluefin.Internal: subset :: forall (e1 :: Effects) (es :: Effects) m. (Monad m, e1 :> es) => m ()
+ Bluefin.Internal.Examples: example :: ()

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+## 0.2.0.0++* Choose different incoherent instance for `:>` for better type+  inference.  This is very unlikely to break existing code, but if it+  does happen then please [open an+  issue](https://github.com/tomjaguarpaw/bluefin/issues/new).+ ## 0.1.2.0  * Fix strictness of `Bluefin.State.put`. It was accidentally made lazy
bluefin-internal.cabal view
@@ -1,6 +1,6 @@ cabal-version:      3.0 name:               bluefin-internal-version:            0.1.2.0+version:            0.2.0.0 license:            MIT license-file:       LICENSE author:             Tom Ellis
src/Bluefin/Internal.hs view
@@ -23,6 +23,7 @@ import Data.Foldable (for_) import Data.IORef (IORef, newIORef, readIORef, writeIORef) import Data.Kind (Type)+import Data.Proxy (Proxy (Proxy)) import Data.Type.Coercion (Coercion (Coercion)) import GHC.Exts (Proxy#, proxy#) import System.IO.Unsafe (unsafePerformIO)@@ -449,11 +450,11 @@ class (es1 :: Effects) :> (es2 :: Effects)  -- | A set of effects @e@ is a subset of itself-instance {-# INCOHERENT #-} e :> e+instance e :> e  -- | If @e@ is subset of @es@ then @e@ is a subset of a larger set, @x -- :& es@-instance (e :> es) => e :> (x :& es)+instance {-# INCOHERENT #-} (e :> es) => e :> (x :& es)  -- Do we want this? -- instance {-# incoherent #-} (e :> es) => (e' :& e) :> (e' :> es)@@ -461,8 +462,21 @@ -- This seems a bit wobbly  -- | @e@ is a subset of a larger set @e :& es@-instance {-# INCOHERENT #-} e :> (e :& es)+instance e :> (e :& es) +subset ::+  forall e1 es m.+  (Monad m) =>+  (e1 :> es) =>+  m ()+subset = pure ()++effTag :: Eff es (Proxy es)+effTag = pure Proxy++handleTag :: h e -> Eff es (Proxy e)+handleTag _ = pure Proxy+ -- | -- @ -- >>> runPureEff $ try $ \\e -> do@@ -792,7 +806,7 @@ -- -- @ -- >>> runPureEff $ yieldToList $ \\y -> do---       for_ [0 .. 4] $ \\i -> do+--       forEach (inFoldable [0 .. 3]) $ \\i -> do --         yield y i --         yield y (i * 10) -- ([0, 0, 1, 10, 2, 20, 3, 30], ())
src/Bluefin/Internal/Examples.hs view
@@ -19,6 +19,7 @@ import Control.Monad.IO.Class (liftIO) import Data.Foldable (for_) import Data.Monoid (Any (Any, getAny))+import Data.Proxy (Proxy (Proxy)) import Text.Read (readMaybe) import Prelude hiding   ( break,@@ -90,7 +91,7 @@  forEachExample :: ([Int], ()) forEachExample = runPureEff $ yieldToList $ \y -> do-  for_ [0 .. 4] $ \i -> do+  forEach (inFoldable [0 .. 4]) $ \i -> do     yield y i     yield y (i * 10) @@ -1082,3 +1083,22 @@         { askLRImpl = ask h,           localLRImpl = \f k' -> makeOp (local h f (useImpl k'))         }++-- Fails to compile unless '(e :> es) => e :> (x :& es)' is incoherent+-- (otherwise I guess it "commits to it too soon")+example :: ()+example = runPureEff $+  evalState () $ \st1 ->+    evalState () $ \st2 -> do+      Proxy :: Proxy es <- effTag+      subset @es @es++      Proxy :: Proxy e1 <- handleTag st1+      Proxy :: Proxy e2 <- handleTag st2++      subset @e1 @e1+      subset @e2 @e2+      subset @e1 @(e1 :& e2)+      subset @e2 @(e1 :& e2)++      subset @(e1 :& e2) @(e1 :& e2)
src/Bluefin/Internal/Exception/Scoped.hs view
@@ -21,8 +21,12 @@ throw :: Exception e -> e -> IO a throw ex e = throwIO (MkInFlight ex e) +-- Corresponds to what Bluefin calls an "Exception", i.e. "a handle to+-- an exception" or "the capability to throw an exception". newtype Exception (e :: Type) = MkException (Key e) +-- InFlight is like Locker from vault.  MkInflight is like lock from+-- vault. data InFlight = forall e. MkInFlight !(Exception e) !e  instance Show InFlight where@@ -30,5 +34,6 @@  instance Control.Exception.Exception InFlight +-- Like unlock from vault check :: Key a -> InFlight -> Maybe a check k1 (MkInFlight (MkException k2) e) = fmap (\HRefl -> e) (k1 `eqKey` k2)