bluefin-internal 0.3.4.0 → 0.3.5.0
raw patch · 10 files changed
+60/−23 lines, 10 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Bluefin.Internal.CloneableHandle: instance (Bluefin.Internal.Handle h1, Bluefin.Internal.Handle h2) => Bluefin.Internal.OneWayCoercible.OneWayCoercible ((Bluefin.Internal.CloneableHandle.:~>) h1 h2 e) ((Bluefin.Internal.CloneableHandle.:~>) h1 h2 es)
+ Bluefin.Internal: oneWayCoercibleTrustMe :: forall (e :: Effects) (es :: Effects) h. e :> es => (forall (e' :: Effects) (es' :: Effects). e' :> es' => h e' -> h es') -> OneWayCoercibleD (h e) (h es)
+ Bluefin.Internal.CloneableHandle: instance (Bluefin.Internal.Handle h1, Bluefin.Internal.Handle h2, e Bluefin.Internal.:> es) => Bluefin.Internal.OneWayCoercible.OneWayCoercible ((Bluefin.Internal.CloneableHandle.:~>) h1 h2 e) ((Bluefin.Internal.CloneableHandle.:~>) h1 h2 es)
+ Bluefin.Internal.OneWayCoercible: instance forall k (h :: k -> *) (e :: k) (es :: k) i (t :: GHC.Generics.Meta). Bluefin.Internal.OneWayCoercible.OneWayCoercible (h e) (h es) => Bluefin.Internal.OneWayCoercible.OneWayCoercible (GHC.Generics.M1 i t h e) (GHC.Generics.M1 i t h es)
+ Bluefin.Internal.OneWayCoercible: instance forall k (h :: k -> *) (e :: k) (es :: k). Bluefin.Internal.OneWayCoercible.OneWayCoercible (h e) (h es) => Bluefin.Internal.OneWayCoercible.OneWayCoercible (GHC.Generics.Rec1 h e) (GHC.Generics.Rec1 h es)
+ Bluefin.Internal.OneWayCoercible: instance forall k (h1 :: k -> *) (e :: k) (es :: k) (h2 :: k -> *). (Bluefin.Internal.OneWayCoercible.OneWayCoercible (h1 e) (h1 es), Bluefin.Internal.OneWayCoercible.OneWayCoercible (h2 e) (h2 es)) => Bluefin.Internal.OneWayCoercible.OneWayCoercible ((GHC.Generics.:*:) h1 h2 e) ((GHC.Generics.:*:) h1 h2 es)
Files
- CHANGELOG.md +6/−0
- bluefin-internal.cabal +1/−1
- src/Bluefin/Internal.hs +22/−9
- src/Bluefin/Internal/CloneableHandle.hs +1/−1
- src/Bluefin/Internal/Examples.hs +3/−3
- src/Bluefin/Internal/Exception/Scoped.hs +2/−2
- src/Bluefin/Internal/Key.hs +0/−1
- src/Bluefin/Internal/OneWayCoercible.hs +17/−0
- src/Bluefin/Internal/Pipes.hs +3/−3
- src/Bluefin/Internal/System/IO.hs +5/−3
CHANGELOG.md view
@@ -1,3 +1,9 @@+# 0.3.5.0++* Add `Bluefin.Internal.oneWayCoercibleTrustMe`++* Add `OneWayCoercible` instances for Generic types+ # 0.3.4.0 * Add `Bluefin.Internal.Exception` and tests, thanks to Shea Levy
bluefin-internal.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: bluefin-internal-version: 0.3.4.0+version: 0.3.5.0 license: MIT license-file: LICENSE author: Tom Ellis
src/Bluefin/Internal.hs view
@@ -12,9 +12,10 @@ module Bluefin.Internal where -import qualified Bluefin.Internal.Exception.Scoped as ScopedException+import Bluefin.Internal.Exception.Scoped qualified as ScopedException import Bluefin.Internal.OneWayCoercible ( OneWayCoercible (oneWayCoercibleImpl),+ OneWayCoercibleD, OneWayCoercion, gOneWayCoercible, oneWayCoerce,@@ -22,15 +23,15 @@ oneWayCoercible, unsafeOneWayCoercible, )-import qualified Control.Concurrent.Async as Async+import Control.Concurrent.Async qualified as Async import Control.Concurrent.MVar (newEmptyMVar, putMVar, takeMVar)-import qualified Control.Exception+import Control.Exception qualified import Control.Monad (forever) import Control.Monad.Base (MonadBase (liftBase)) import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.IO.Unlift (MonadUnliftIO, withRunInIO) import Control.Monad.Trans.Control (MonadBaseControl, StM, liftBaseWith, restoreM)-import qualified Control.Monad.Trans.Reader as Reader+import Control.Monad.Trans.Reader qualified as Reader import Data.Coerce (coerce) import Data.Foldable (for_) import Data.IORef (IORef, newIORef, readIORef, writeIORef)@@ -400,6 +401,7 @@ -- @ class Handle (h :: Effects -> Type) where {-# MINIMAL handleImpl | mapHandle #-}+ -- | Define @handleImpl@ using 'handleMapHandle'. handleImpl :: HandleD h handleImpl = MkHandleD mapHandle@@ -414,7 +416,7 @@ -- -- @ -- instance Handle MyHandle where- -- mapHandle h = \<definition\>+ -- mapHandle h = \<mapHandle definition\> -- @ -- -- you should change it to@@ -422,10 +424,10 @@ -- @ -- data MyHandle e = ... -- deriving (Generic)- -- deriving (Handle) via OneWayCoercibleHandle MyHandle+ -- deriving (Handle) via 'OneWayCoercibleHandle' MyHandle --- -- instance (e :> es) => OneWayCoercible (MyHandle e) (MyHandle es) where- -- oneWayCoercibleImpl = gOneWayCoercible+ -- instance (e :> es) => 'OneWayCoercible' (MyHandle e) (MyHandle es) where+ -- 'oneWayCoercibleImpl' = 'gOneWayCoercible' -- @ -- -- If that doesn't work for any reason you can always reuse your old@@ -437,13 +439,14 @@ -- -- @ -- instance Handle MyHandle where- -- handleImpl = handleMapHandle $ \\h -> \<definition\>+ -- handleImpl = handleMapHandle $ \\h -> \<mapHandle definition\> -- @ mapHandle :: (e :> es) => h e -> h es mapHandle = case handleImpl of MkHandleD f -> f -- | The type of the 'handleImpl' method of the 'Handle' class. -- Create a @HandleD@ using 'handleMapHandle'.+type HandleD :: (Effects -> Type) -> Type newtype HandleD h = MkHandleD (forall e es. (e :> es) => h e -> h es) -- | For defining the 'handleImpl' method of the 'Handle' class.@@ -454,6 +457,7 @@ handleMapHandle = MkHandleD handleOneWayCoercible ::+ forall h. (forall e es. (e :> es) => OneWayCoercible (h e) (h es)) => -- | ͘ HandleD h@@ -473,6 +477,15 @@ instance (Handle h1, Handle h2) => Handle (h1 :*: h2) where handleImpl = handleMapHandle $ \(h1 :*: h2) -> mapHandle h1 :*: mapHandle h2++oneWayCoercibleTrustMe ::+ (e :> es) =>+ (forall e' es'. (e' :> es') => h e' -> h es') ->+ -- | ͘+ OneWayCoercibleD (h e) (h es)+-- Forcing the argument doesn't do much of a check, but it is+-- something+oneWayCoercibleTrustMe !_ = unsafeOneWayCoercible -- { OneWayCoercibleHandle
src/Bluefin/Internal/CloneableHandle.hs view
@@ -142,7 +142,7 @@ handleImpl = handleOneWayCoercible instance- (Handle h1, Handle h2) =>+ (Handle h1, Handle h2, e :> es) => OneWayCoercible ((h1 :~> h2) e) ((h1 :~> h2) es)
src/Bluefin/Internal/Examples.hs view
@@ -17,9 +17,9 @@ takeWhile', (>->), )-import qualified Bluefin.Internal.Pipes as P+import Bluefin.Internal.Pipes qualified as P import Control.Exception (IOException)-import qualified Control.Exception+import Control.Exception qualified import Control.Monad (forever, replicateM_, unless, when) import Control.Monad.IO.Class (liftIO) import Data.Foldable (for_)@@ -36,7 +36,7 @@ return, writeFile, )-import qualified Prelude+import Prelude qualified monadIOExample :: IO () monadIOExample = runEff_ $ \io -> withMonadIO io $ liftIO $ do
src/Bluefin/Internal/Exception/Scoped.hs view
@@ -10,9 +10,9 @@ import Bluefin.Internal.Key (Key, eqKey, newKey) import Control.Exception (throwIO, tryJust)-import qualified Control.Exception-import Data.Type.Equality ((:~~:) (HRefl))+import Control.Exception qualified import Data.Kind (Type)+import Data.Type.Equality ((:~~:) (HRefl)) try :: (Exception e -> IO a) -> IO (Either e a) try k = do
src/Bluefin/Internal/Key.hs view
@@ -5,7 +5,6 @@ -- and Tag from prim-uniq: -- -- https://hackage.haskell.org/package/prim-uniq-0.2/docs/Data-Unique-Tag.html- {-# LANGUAGE RoleAnnotations #-} module Bluefin.Internal.Key
src/Bluefin/Internal/OneWayCoercible.hs view
@@ -120,3 +120,20 @@ MkOneWayCoercion Coercion -> case oneWayCoercion @b @b' of MkOneWayCoercion Coercion -> MkOneWayCoercibleD (MkOneWayCoercion Coercion)++instance+ OneWayCoercible (h e) (h es) =>+ OneWayCoercible (Rec1 h e) (Rec1 h es)+ where+ oneWayCoercibleImpl = gOneWayCoercible++instance+ OneWayCoercible (h e) (h es) =>+ OneWayCoercible (M1 i t h e) (M1 i t h es)+ where+ oneWayCoercibleImpl = gOneWayCoercible++instance+ (OneWayCoercible (h1 e) (h1 es), OneWayCoercible (h2 e) (h2 es)) =>+ OneWayCoercible ((h1 :*: h2) e) ((h1 :*: h2) es)+ where oneWayCoercibleImpl = gOneWayCoercible
src/Bluefin/Internal/Pipes.hs view
@@ -1,12 +1,12 @@ module Bluefin.Internal.Pipes where -import Bluefin.Internal hiding (yield, await)-import qualified Bluefin.Internal+import Bluefin.Internal hiding (await, yield)+import Bluefin.Internal qualified import Control.Monad (forever) import Data.Foldable (for_) import Data.Void (Void, absurd) import Prelude hiding (break, print, takeWhile)-import qualified Prelude+import Prelude qualified data Proxy a' a b' b e = MkProxy (Coroutine a' a e) (Coroutine b b' e)
src/Bluefin/Internal/System/IO.hs view
@@ -9,20 +9,22 @@ IOE, bracket, effIO,+ handleMapHandle, mapHandle, useImplIn, (:&), (:>), )-import qualified Bluefin.Internal-import qualified System.IO+import Bluefin.Internal qualified+import System.IO qualified -- We can probably get away without the IOE and just use -- unsafeProvideIO on all Handle functions data Handle e = UnsafeMkHandle System.IO.Handle (IOE e) instance Bluefin.Internal.Handle Handle where- mapHandle (UnsafeMkHandle h io) = UnsafeMkHandle h (mapHandle io)+ handleImpl = handleMapHandle $ \(UnsafeMkHandle h io) ->+ UnsafeMkHandle h (mapHandle io) withFile :: (e1 :> es) =>