packages feed

in-other-words 0.2.0.0 → 0.2.1.0

raw patch · 10 files changed

+143/−37 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Effect.BaseControl: threadBaseControlViaUnlift :: forall b t m a. (Monad m, MonadTrans t, forall z. Monad z => Monad (t z), forall z. Coercible z m => Coercible (t z) (t m), forall z. Monad z => ThreadsEff t (Unlift z)) => (forall x. BaseControl b m x -> m x) -> BaseControl b (t m) a -> t m a
+ Control.Effect.Carrier.Internal.Stepped: hoistSteps :: Functor n => (forall x. m x -> n x) -> Steps e m a -> Steps e n a
+ Control.Effect.Stepped: hoistSteps :: Functor n => (forall x. m x -> n x) -> Steps e m a -> Steps e n a
+ Control.Effect.Type.Unlift: instance (Control.Monad.Base.MonadBase b m, Control.Monad.Trans.Class.MonadTrans t, GHC.Base.Monad (t m)) => Control.Monad.Base.MonadBase b (Control.Effect.Type.Unlift.Unlifted t m)
+ Control.Effect.Type.Unlift: instance (Control.Monad.Trans.Control.MonadBaseControl b m, Control.Monad.Trans.Class.MonadTrans t, Control.Effect.Internal.Union.ThreadsEff t (Control.Effect.Type.Unlift.Unlift m), GHC.Base.Monad (t m)) => Control.Monad.Trans.Control.MonadBaseControl b (Control.Effect.Type.Unlift.Unlifted t m)
+ Control.Effect.Type.Unlift: instance Control.Monad.Trans.Class.MonadTrans t => Control.Monad.Trans.Class.MonadTrans (Control.Effect.Type.Unlift.Unlifted t)
+ Control.Effect.Type.Unlift: instance forall k (t :: k -> * -> *) (m :: k). GHC.Base.Applicative (t m) => GHC.Base.Applicative (Control.Effect.Type.Unlift.Unlifted t m)
+ Control.Effect.Type.Unlift: instance forall k (t :: k -> * -> *) (m :: k). GHC.Base.Functor (t m) => GHC.Base.Functor (Control.Effect.Type.Unlift.Unlifted t m)
+ Control.Effect.Type.Unlift: instance forall k (t :: k -> * -> *) (m :: k). GHC.Base.Monad (t m) => GHC.Base.Monad (Control.Effect.Type.Unlift.Unlifted t m)
+ Control.Effect.Type.Unlift: threadBaseControlViaUnlift :: forall b t m a. (Monad m, MonadTrans t, forall z. Monad z => Monad (t z), forall z. Coercible z m => Coercible (t z) (t m), forall z. Monad z => ThreadsEff t (Unlift z)) => (forall x. BaseControl b m x -> m x) -> BaseControl b (t m) a -> t m a

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog for `in-other-words` +## 0.2.1.0 (2021-11-05)+### Non-breaking Changes+* Added `hoistSteps`+* Added `threadBaseControlViaUnlift`+* GHC 9.0.1 compatiblity (thanks @berberman!)+ ## 0.2.0.0 (2021-01-30) ### Breaking Changes * `-Fast` interpretations of every continuation-related effect have been removed due
README.md view
@@ -3,6 +3,7 @@ [![build GHC 8.6](https://github.com/KingoftheHomeless/in-other-words/workflows/build%20GHC%208.6/badge.svg)](https://github.com/KingoftheHomeless/in-other-words/actions?query=workflow%3A%22build+GHC+8.6%22) [![build GHC 8.8](https://github.com/KingoftheHomeless/in-other-words/workflows/build%20GHC%208.8/badge.svg)](https://github.com/KingoftheHomeless/in-other-words/actions?query=workflow%3A%22build+GHC+8.8%22) [![build GHC 8.10](https://github.com/KingoftheHomeless/in-other-words/workflows/build%20GHC%208.10/badge.svg)](https://github.com/KingoftheHomeless/in-other-words/actions?query=workflow%3A%22build+GHC+8.10%22)+[![build GHC 9.0.1](https://github.com/KingoftheHomeless/in-other-words/workflows/build%20GHC%209.0.1/badge.svg)](https://github.com/KingoftheHomeless/in-other-words/actions?query=workflow%3A%22build+GHC+9.0.1%22)  - [Overview][] - [Features][]
in-other-words.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12
 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack ----- hash: 94e61819ea6e924b216d8fa7fe755ab80100afa6a3ebf73d3da409a983481ce9+-- hash: 63c053f88fc44761f95d97eedcd3be8a6130b0202778be539bab361549d74523  name:           in-other-words-version:        0.2.0.0+version:        0.2.1.0 synopsis:       A higher-order effect system where the sky's the limit description:    A low-boilerplate effect system with easy higher-order effects and very high expressive power category:       Control@@ -109,15 +109,35 @@       Paths_in_other_words   hs-source-dirs:       src-  default-extensions: BangPatterns ConstraintKinds DataKinds DerivingStrategies EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving LambdaCase PolyKinds QuantifiedConstraints RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UndecidableInstances+  default-extensions:+      BangPatterns+      ConstraintKinds+      DataKinds+      DerivingStrategies+      EmptyCase+      FlexibleContexts+      FlexibleInstances+      FunctionalDependencies+      GADTs+      GeneralizedNewtypeDeriving+      LambdaCase+      PolyKinds+      QuantifiedConstraints+      RankNTypes+      ScopedTypeVariables+      StandaloneDeriving+      TypeApplications+      TypeOperators+      TypeFamilies+      UndecidableInstances   ghc-options: -Wall -haddock   build-depends:-      async >=2.2 && <2.3+      async ==2.2.*     , base >=4.7 && <5-    , exceptions >=0.10 && <0.11-    , monad-control >=1.0 && <1.1-    , mtl >=2.2 && <2.3-    , stm >=2.5 && <2.6+    , exceptions ==0.10.*+    , monad-control ==1.0.*+    , mtl ==2.2.*+    , stm ==2.5.*     , transformers >=0.5.6 && <0.6     , transformers-base >=0.4.5 && <0.5   default-language: Haskell2010@@ -134,19 +154,39 @@       Paths_in_other_words   hs-source-dirs:       test-  default-extensions: BangPatterns ConstraintKinds DataKinds DerivingStrategies EmptyCase FlexibleContexts FlexibleInstances FunctionalDependencies GADTs GeneralizedNewtypeDeriving LambdaCase PolyKinds QuantifiedConstraints RankNTypes ScopedTypeVariables StandaloneDeriving TypeApplications TypeOperators TypeFamilies UndecidableInstances+  default-extensions:+      BangPatterns+      ConstraintKinds+      DataKinds+      DerivingStrategies+      EmptyCase+      FlexibleContexts+      FlexibleInstances+      FunctionalDependencies+      GADTs+      GeneralizedNewtypeDeriving+      LambdaCase+      PolyKinds+      QuantifiedConstraints+      RankNTypes+      ScopedTypeVariables+      StandaloneDeriving+      TypeApplications+      TypeOperators+      TypeFamilies+      UndecidableInstances   ghc-options: -threaded -rtsopts -with-rtsopts=-N -O0   build-tool-depends:       hspec-discover:hspec-discover >=2.0   build-depends:-      async >=2.2 && <2.3+      async ==2.2.*     , base >=4.7 && <5-    , exceptions >=0.10 && <0.11+    , exceptions ==0.10.*     , hspec >=2.6.0 && <3     , in-other-words-    , monad-control >=1.0 && <1.1-    , mtl >=2.2 && <2.3-    , stm >=2.5 && <2.6+    , monad-control ==1.0.*+    , mtl ==2.2.*+    , stm ==2.5.*     , transformers >=0.5.6 && <0.6     , transformers-base >=0.4.5 && <0.5   default-language: Haskell2010
src/Control/Effect/BaseControl.hs view
@@ -17,6 +17,7 @@     -- * Threading utilities   , threadBaseControlViaClass+  , threadBaseControlViaUnlift      -- * Combinators for 'Algebra's     -- Intended to be used for custom 'Carrier' instances when@@ -40,6 +41,7 @@ import Control.Effect.Type.Internal.BaseControl import Control.Effect.Internal.BaseControl import Control.Effect.Internal.Itself+import Control.Effect.Type.Unlift  import Control.Effect.Internal.Utils 
src/Control/Effect/Bracket.hs view
@@ -103,7 +103,7 @@ type BracketToIOC = InterpretPrimC BracketToIOH Bracket  --- | Run a 'Bracket' by effect that protects against+-- | Run a 'Bracket' effect that protects against -- any abortive computation of any effect, as well -- as any IO exceptions and asynchronous exceptions. --@@ -131,7 +131,7 @@  type BracketToIOUnsafeC = InterpretPrimC BracketToIOUnsafeH Bracket --- | Run a 'Bracket' by effect that protects against+-- | Run a 'Bracket' effect that protects against -- any abortive computation of any effect, as well -- as any IO exceptions and asynchronous exceptions. --
src/Control/Effect/Carrier/Internal/Interpret.hs view
@@ -45,7 +45,7 @@ instance (Carrier m, r ~ Derivs m, p ~ Prims m)       => Reifies (CarrierReform m)                  (ReifiedReformulation r p m) where-  reflect = ReifiedReformulation reformulate+  reflect = ReifiedReformulation $ \n alg -> reformulate n alg   {-# INLINE reflect #-}  @@ -280,14 +280,16 @@ instance ( RepresentationalEff e          , Carrier m          , Reifies s (ReifiedHandler e m)-         ) => Handler (ViaReifiedH s) e m where+         )+        => Handler (ViaReifiedH s) e m where   effHandler = getReifiedHandler (reflect @s)   {-# INLINE effHandler #-}  instance ( RepresentationalEff e          , Carrier m          , Reifies s (ReifiedPrimHandler e m)-         ) => PrimHandler (ViaReifiedH s) e m where+         )+      => PrimHandler (ViaReifiedH s) e m where   effPrimHandler = getReifiedPrimHandler (reflect @s)   {-# INLINE effPrimHandler #-} 
src/Control/Effect/Carrier/Internal/Stepped.hs view
@@ -95,6 +95,10 @@ liftSteps (Done a) = Done a liftSteps (More e c) = More e (lift . fmap liftSteps . c) +hoistSteps :: Functor n => (forall x. m x -> n x) -> Steps e m a -> Steps e n a+hoistSteps _ (Done a) = Done a+hoistSteps n (More e c) = More e (fmap (hoistSteps n) . n . c)+ -- | Execute all the steps of a computation. unsteps :: forall e m a          . ( FirstOrder e
src/Control/Effect/Error.hs view
@@ -76,7 +76,7 @@   throw :: Eff (Throw e) m => e -> m a-throw = send . Throw+throw = send .# Throw {-# INLINE throw #-}  catch :: Eff (Catch e) m => m a -> (e -> m a) -> m a
src/Control/Effect/Stepped.hs view
@@ -1,14 +1,15 @@-module Control.Effect.Stepped
-  ( SteppedC
-  , Steps(..)
-  , steps
-  , unsteps
-  , liftSteps
-
-  , FirstOrder
-
-    -- Threading constraints
-  , SteppedThreads
-  ) where
-
-import Control.Effect.Carrier.Internal.Stepped
+module Control.Effect.Stepped+  ( SteppedC+  , Steps(..)+  , steps+  , unsteps+  , liftSteps+  , hoistSteps++  , FirstOrder++    -- Threading constraints+  , SteppedThreads+  ) where++import Control.Effect.Carrier.Internal.Stepped
src/Control/Effect/Type/Unlift.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE MagicHash #-} {-# OPTIONS_HADDOCK not-home #-} module Control.Effect.Type.Unlift  ( -- * Effects@@ -5,6 +6,7 @@     -- Threading utilities  , threadUnliftViaClass+ , threadBaseControlViaUnlift     -- 'MonadBaseControlPure' and 'MonadTransControlPure'  , MonadBaseControlPure@@ -14,7 +16,13 @@  , unliftT  ) where +import GHC.Exts (Proxy#, proxy#)+import Data.Coerce import Control.Effect.Internal.Union+import Control.Effect.Internal.Utils+import Control.Effect.Type.Internal.BaseControl+import Control.Monad.Base+import Control.Monad.Trans import Control.Monad.Trans.Control import Control.Monad.Trans.Reader @@ -88,8 +96,9 @@ newtype Unlift b :: Effect where   Unlift :: forall b m a. ((forall x. m x -> b x) -> b a) -> Unlift b m a --- | A valid definition of 'threadEff' for a @'ThreadsEff' ('Unlift' b) t@ instance,--- given that @t@ is a 'MonadTransControl' where @'StT' t a ~ a@ holds for all @a@.+-- | A valid definition of 'threadEff' for a @'ThreadsEff' ('Unlift' b) t@+-- instance, given that @t@ is a 'MonadTransControl' where @'StT' t a ~ a@ holds+-- for all @a@. threadUnliftViaClass :: forall b t m a                       . (MonadTransControlPure t, Monad m)                      => (forall x. Unlift b m x -> m x)@@ -97,6 +106,47 @@ threadUnliftViaClass alg (Unlift main) = unliftT $ \lowerT ->   alg $ Unlift $ \lowerM -> main (lowerM . lowerT) {-# INLINE threadUnliftViaClass #-}++-- | A valid definition of 'threadEff' for a @'ThreadsEff' ('BaseControl' b) t@+-- instance, given that @t@ threads @'Unlift' z@ for any 'Monad' @z@.+threadBaseControlViaUnlift :: forall b t m a+                            . ( Monad m+                              , MonadTrans t+                              , forall z. Monad z => Monad (t z)+                              ,    forall z+                                 . Coercible z m+                                => Coercible (t z) (t m)+                              , forall z. Monad z => ThreadsEff t (Unlift z)+                              )+                           => (forall x. BaseControl b m x -> m x)+                           -> BaseControl b (t m) a -> t m a+threadBaseControlViaUnlift alg (GainBaseControl main) =+    lift $ alg $ GainBaseControl $ \(_ :: Proxy# z) ->+      main (proxy# :: Proxy# (Unlifted t z))+{-# INLINE threadBaseControlViaUnlift #-}++newtype Unlifted t m a = Unlifted { unUnlifted :: t m a }+  deriving (Functor, Applicative, Monad)+  deriving MonadTrans++instance (MonadBase b m, MonadTrans t, Monad (t m))+      => MonadBase b (Unlifted t m) where+  liftBase = lift . liftBase+  {-# INLINE liftBase #-}++instance (MonadBaseControl b m, MonadTrans t, ThreadsEff t (Unlift m),+          Monad (t m))+      => MonadBaseControl b (Unlifted t m) where+  type StM (Unlifted t m) a = StM m a++  liftBaseWith main =+    Unlifted $ threadEff (\(Unlift main') -> main' id) $ Unlift $ \lower ->+      liftBaseWith $ \run_it -> main $ run_it . lower .# unUnlifted+  {-# INLINE liftBaseWith #-}++  restoreM = Unlifted #. lift . restoreM+  {-# INLINE restoreM #-}+  instance ThreadsEff (ReaderT i) (Unlift b) where   threadEff alg (Unlift main) = ReaderT $ \s ->