operational-alacarte 0.2 → 0.3
raw patch · 3 files changed
+33/−29 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.Monad.Operational.Higher: (:>>=) :: instr '(ProgramT instr fs m, fs) b -> (b -> ProgramT instr fs m a) -> ProgramViewT instr fs m a
- Control.Monad.Operational.Higher: Return :: a -> ProgramViewT instr fs m a
- Control.Monad.Operational.Higher: instance forall (k :: BOX) (instr :: (,) (* -> *) k -> * -> *) (fs :: k) (m :: * -> *). GHC.Base.Monad m => GHC.Base.Applicative (Control.Monad.Operational.Higher.ProgramT instr fs m)
- Control.Monad.Operational.Higher: instance forall (k :: BOX) (instr :: (,) (* -> *) k -> * -> *) (fs :: k) (m :: * -> *). GHC.Base.Monad m => GHC.Base.Functor (Control.Monad.Operational.Higher.ProgramT instr fs m)
- Control.Monad.Operational.Higher: instance forall (k :: BOX) (instr :: (,) (* -> *) k -> * -> *) (fs :: k) (m :: * -> *). GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Operational.Higher.ProgramT instr fs m)
- Control.Monad.Operational.Higher: instance forall (k :: BOX) (instr :: (,) (* -> *) k -> * -> *) (fs :: k). Control.Monad.Trans.Class.MonadTrans (Control.Monad.Operational.Higher.ProgramT instr fs)
- Control.Monad.Operational.Higher: instance forall (k :: BOX) (k1 :: BOX) (i1 :: (,) (* -> *) ((,) (k -> *) k1) -> * -> *) (i2 :: (,) (* -> *) ((,) (k -> *) k1) -> * -> *) (instr :: (,) (* -> *) ((,) (k -> *) k1) -> * -> *). (Control.Monad.Operational.Higher.Reexpressible i1 instr, Control.Monad.Operational.Higher.Reexpressible i2 instr) => Control.Monad.Operational.Higher.Reexpressible (i1 Data.ALaCarte.:+: i2) instr
- Control.Monad.Operational.Higher: instance forall (k :: BOX) (k1 :: BOX) (i1 :: (,) (k1 -> *) ((,) (k1 -> *) k) -> k1 -> *) (i2 :: (,) (k1 -> *) ((,) (k1 -> *) k) -> k1 -> *) (m :: k1 -> *) (fs :: k). (Control.Monad.Operational.Higher.InterpBi i1 m fs, Control.Monad.Operational.Higher.InterpBi i2 m fs) => Control.Monad.Operational.Higher.InterpBi (i1 Data.ALaCarte.:+: i2) m fs
- Control.Monad.Operational.Higher: instance forall (k :: BOX) (k1 :: BOX) (i1 :: (,) (k1 -> *) k -> k1 -> *) (i2 :: (,) (k1 -> *) k -> k1 -> *) (m :: k1 -> *) (fs :: k). (Control.Monad.Operational.Higher.Interp i1 m fs, Control.Monad.Operational.Higher.Interp i2 m fs) => Control.Monad.Operational.Higher.Interp (i1 Data.ALaCarte.:+: i2) m fs
- Control.Monad.Operational.Higher: reexpressInstr :: (Reexpressible i instr, Monad m) => (forall b. exp1 b -> ProgramT instr '(exp2, fs) m (exp2 b)) -> i '(ProgramT instr '(exp2, fs) m, '(exp1, fs)) a -> ProgramT instr '(exp2, fs) m a
- Data.ALaCarte: instance forall (k :: BOX) (h1 :: k -> * -> *) (h2 :: k -> * -> *) (fs :: k). (GHC.Base.Functor (h1 fs), GHC.Base.Functor (h2 fs)) => GHC.Base.Functor ((Data.ALaCarte.:+:) h1 h2 fs)
- Data.ALaCarte: instance forall (k :: BOX) (k1 :: BOX) (f :: k -> k1 -> *) (g :: k -> k1 -> *) (h :: k -> k1 -> *). (f Data.ALaCarte.:<: h) => f Data.ALaCarte.:<: (g Data.ALaCarte.:+: h)
- Data.ALaCarte: instance forall (k :: BOX) (k1 :: BOX) (f :: k -> k1 -> *) (g :: k -> k1 -> *). f Data.ALaCarte.:<: (f Data.ALaCarte.:+: g)
- Data.ALaCarte: instance forall (k :: BOX) (k1 :: BOX) (f :: k -> k1 -> *). f Data.ALaCarte.:<: f
- Data.ALaCarte: instance forall (k :: BOX) (k1 :: BOX) (k2 :: BOX) (h1 :: (,) (* -> *) ((,) (k1 -> *) k2) -> k -> *) (h2 :: (,) (* -> *) ((,) (k1 -> *) k2) -> k -> *). (Data.ALaCarte.HBifunctor h1, Data.ALaCarte.HBifunctor h2) => Data.ALaCarte.HBifunctor (h1 Data.ALaCarte.:+: h2)
- Data.ALaCarte: instance forall (k :: BOX) (k1 :: BOX) (k2 :: BOX) (h1 :: (,) (k -> *) k2 -> k1 -> *) (h2 :: (,) (k -> *) k2 -> k1 -> *). (Data.ALaCarte.HFunctor h1, Data.ALaCarte.HFunctor h2) => Data.ALaCarte.HFunctor (h1 Data.ALaCarte.:+: h2)
+ Control.Monad.Operational.Higher: [:>>=] :: instr '(ProgramT instr fs m, fs) b -> (b -> ProgramT instr fs m a) -> ProgramViewT instr fs m a
+ Control.Monad.Operational.Higher: [Return] :: a -> ProgramViewT instr fs m a
+ Control.Monad.Operational.Higher: instance forall k (instr :: (* -> *, k) -> * -> *) (fs :: k). Control.Monad.Trans.Class.MonadTrans (Control.Monad.Operational.Higher.ProgramT instr fs)
+ Control.Monad.Operational.Higher: instance forall k (m :: * -> *) (instr :: (* -> *, k) -> * -> *) (fs :: k). GHC.Base.Monad m => GHC.Base.Applicative (Control.Monad.Operational.Higher.ProgramT instr fs m)
+ Control.Monad.Operational.Higher: instance forall k (m :: * -> *) (instr :: (* -> *, k) -> * -> *) (fs :: k). GHC.Base.Monad m => GHC.Base.Functor (Control.Monad.Operational.Higher.ProgramT instr fs m)
+ Control.Monad.Operational.Higher: instance forall k (m :: * -> *) (instr :: (* -> *, k) -> * -> *) (fs :: k). GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Operational.Higher.ProgramT instr fs m)
+ Control.Monad.Operational.Higher: instance forall k k1 (i1 :: (* -> *, (k -> *, k1)) -> * -> *) (instr :: (* -> *, (k -> *, k1)) -> * -> *) env (i2 :: (* -> *, (k -> *, k1)) -> * -> *). (Control.Monad.Operational.Higher.Reexpressible i1 instr env, Control.Monad.Operational.Higher.Reexpressible i2 instr env) => Control.Monad.Operational.Higher.Reexpressible (i1 Data.ALaCarte.:+: i2) instr env
+ Control.Monad.Operational.Higher: instance forall k k1 (i1 :: (k1 -> *, (k1 -> *, k)) -> k1 -> *) (m :: k1 -> *) (fs :: k) (i2 :: (k1 -> *, (k1 -> *, k)) -> k1 -> *). (Control.Monad.Operational.Higher.InterpBi i1 m fs, Control.Monad.Operational.Higher.InterpBi i2 m fs) => Control.Monad.Operational.Higher.InterpBi (i1 Data.ALaCarte.:+: i2) m fs
+ Control.Monad.Operational.Higher: instance forall k k1 (i1 :: (k1 -> *, k) -> k1 -> *) (m :: k1 -> *) (fs :: k) (i2 :: (k1 -> *, k) -> k1 -> *). (Control.Monad.Operational.Higher.Interp i1 m fs, Control.Monad.Operational.Higher.Interp i2 m fs) => Control.Monad.Operational.Higher.Interp (i1 Data.ALaCarte.:+: i2) m fs
+ Data.ALaCarte: instance forall k (h1 :: k -> * -> *) (h2 :: k -> * -> *) (fs :: k). (GHC.Base.Functor (h1 fs), GHC.Base.Functor (h2 fs)) => GHC.Base.Functor ((Data.ALaCarte.:+:) h1 h2 fs)
+ Data.ALaCarte: instance forall k k1 (f :: k -> k1 -> *) (g :: k -> k1 -> *). f Data.ALaCarte.:<: (f Data.ALaCarte.:+: g)
+ Data.ALaCarte: instance forall k k1 (f :: k -> k1 -> *) (h :: k -> k1 -> *) (g :: k -> k1 -> *). (f Data.ALaCarte.:<: h) => f Data.ALaCarte.:<: (g Data.ALaCarte.:+: h)
+ Data.ALaCarte: instance forall k k1 (f :: k -> k1 -> *). f Data.ALaCarte.:<: f
+ Data.ALaCarte: instance forall k k1 k2 (h1 :: (* -> *, (k1 -> *, k2)) -> k -> *) (h2 :: (* -> *, (k1 -> *, k2)) -> k -> *). (Data.ALaCarte.HBifunctor h1, Data.ALaCarte.HBifunctor h2) => Data.ALaCarte.HBifunctor (h1 Data.ALaCarte.:+: h2)
+ Data.ALaCarte: instance forall k k1 k2 (h1 :: (k -> *, k2) -> k1 -> *) (h2 :: (k -> *, k2) -> k1 -> *). (Data.ALaCarte.HFunctor h1, Data.ALaCarte.HFunctor h2) => Data.ALaCarte.HFunctor (h1 Data.ALaCarte.:+: h2)
- Control.Monad.Operational.Higher: class HBifunctor i => Reexpressible i instr where reexpressInstr reexp = flip runReaderT () . reexpressInstrEnv (lift . reexp) . hbimap lift id
+ Control.Monad.Operational.Higher: class HBifunctor i => Reexpressible i instr env
- Control.Monad.Operational.Higher: interpretWithMonadT :: (HFunctor instr, Monad m) => (forall b. instr '(m, fs) b -> m b) -> (forall b. n b -> m b) -> ProgramT instr fs n a -> m a
+ Control.Monad.Operational.Higher: interpretWithMonadT :: forall instr fs m n a. (HFunctor instr, Monad m) => (forall b. instr '(m, fs) b -> m b) -> (forall b. n b -> m b) -> ProgramT instr fs n a -> m a
- Control.Monad.Operational.Higher: liftProgram :: (HFunctor instr, Monad m) => Program instr fs a -> ProgramT instr fs m a
+ Control.Monad.Operational.Higher: liftProgram :: forall instr fs m a. (HFunctor instr, Monad m) => Program instr fs a -> ProgramT instr fs m a
- Control.Monad.Operational.Higher: reexpress :: (Reexpressible instr1 instr2, Monad m) => (forall b. exp1 b -> ProgramT instr2 '(exp2, fs) m (exp2 b)) -> ProgramT instr1 '(exp1, fs) m a -> ProgramT instr2 '(exp2, fs) m a
+ Control.Monad.Operational.Higher: reexpress :: (Reexpressible instr1 instr2 (), Monad m) => (forall b. exp1 b -> ProgramT instr2 '(exp2, fs) m (exp2 b)) -> ProgramT instr1 '(exp1, fs) m a -> ProgramT instr2 '(exp2, fs) m a
- Control.Monad.Operational.Higher: reexpressEnv :: (Reexpressible instr1 instr2, Monad m) => (forall b. exp1 b -> ReaderT env (ProgramT instr2 '(exp2, fs) m) (exp2 b)) -> ProgramT instr1 '(exp1, fs) m a -> ReaderT env (ProgramT instr2 '(exp2, fs) m) a
+ Control.Monad.Operational.Higher: reexpressEnv :: (Reexpressible instr1 instr2 env, Monad m) => (forall b. exp1 b -> ReaderT env (ProgramT instr2 '(exp2, fs) m) (exp2 b)) -> ProgramT instr1 '(exp1, fs) m a -> ReaderT env (ProgramT instr2 '(exp2, fs) m) a
- Control.Monad.Operational.Higher: reexpressInstrEnv :: (Reexpressible i instr, Monad m) => (forall b. exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> i '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a
+ Control.Monad.Operational.Higher: reexpressInstrEnv :: (Reexpressible i instr env, Monad m) => (forall b. exp1 b -> ReaderT env (ProgramT instr '(exp2, fs) m) (exp2 b)) -> i '(ReaderT env (ProgramT instr '(exp2, fs) m), '(exp1, fs)) a -> ReaderT env (ProgramT instr '(exp2, fs) m) a
Files
- LICENSE +2/−1
- operational-alacarte.cabal +4/−3
- src/Control/Monad/Operational/Higher.hs +27/−25
LICENSE view
@@ -1,4 +1,5 @@-Copyright (c) 2015, Emil Axelsson, Heinrich Apfelmus+Copyright (c) 2016 Emil Axelsson+Copyright (c) 2015 Emil Axelsson, Heinrich Apfelmus All rights reserved.
operational-alacarte.cabal view
@@ -1,5 +1,5 @@ name: operational-alacarte-version: 0.2+version: 0.3 synopsis: A version of Operational suitable for extensible EDSLs description: A version of Operational \[1\] suitable for EDSLs extensible via data types à la carte.@@ -23,8 +23,8 @@ license-file: LICENSE author: Emil Axelsson maintainer: emax@chalmers.se-copyright: Copyright (c) 2015 Emil Axelsson, Heinrich Apfelmus- Copyright (c) 2016 Emil Axelsson+copyright: Copyright (c) 2016 Emil Axelsson+ Copyright (c) 2015 Emil Axelsson, Heinrich Apfelmus homepage: https://github.com/emilaxelsson/operational-alacarte bug-reports: https://github.com/emilaxelsson/operational-alacarte/issues category: Language@@ -46,6 +46,7 @@ DataKinds DeriveDataTypeable DeriveFunctor+ FlexibleContexts FlexibleInstances GADTs MultiParamTypeClasses
src/Control/Monad/Operational/Higher.hs view
@@ -454,35 +454,28 @@ -- -- @e1@ and @e2@ typically represent expressions; hence the name -- \"reexpressible\".-class HBifunctor i => Reexpressible i instr+class HBifunctor i => Reexpressible i instr env where -- | Rewrite an instruction changing its \"expression\" sub-structure- reexpressInstr :: Monad m- => (forall b . exp1 b -> ProgramT instr '(exp2,fs) m (exp2 b))- -- ^ Conversion of the \"expression\" sub-structure- -> i '(ProgramT instr '(exp2,fs) m, '(exp1, fs)) a- -> ProgramT instr '(exp2,fs) m a- reexpressInstr reexp- = flip runReaderT ()- . reexpressInstrEnv (lift . reexp)- . hbimap lift id-- -- | Rewrite an instruction changing its \"expression\" sub-structure -- -- As an example of how to define this function, take the following -- instruction that just puts a tag on a sub-program: --- -- > data Tag fs a- -- > where- -- > Tag :: String -> prog () -> Tag (Param2 prog exp) ()+ -- @+ -- data Tag fs a+ -- where+ -- Tag :: `String` -> prog () -> Tag (`Param2` prog exp) ()+ -- @ -- -- To define `reexpressInstrEnv` we have to use a combination of `ReaderT` -- and `runReaderT`: --- -- > instance (Tag :<: instr) => Reexpressible Tag instr- -- > where- -- > reexpressInstrEnv reexp (Tag tag prog) = ReaderT $ \env ->- -- > singleInj $ Tag tag (flip runReaderT env prog)+ -- @+ -- instance (Tag `:<:` instr) => `Reexpressible` Tag instr+ -- where+ -- `reexpressInstrEnv` reexp (Tag tag prog) = `ReaderT` `$` \env ->+ -- `singleInj` `$` Tag tag (`flip` `runReaderT` env prog)+ -- @ reexpressInstrEnv :: Monad m => ( forall b . exp1 b -> ReaderT env (ProgramT instr '(exp2,fs) m) (exp2 b)@@ -495,11 +488,20 @@ -- which `reexpressInstrEnv` can be defined (among common monads). E.g. -- the above trick with `runReaderT` doesn't work for `StateT`. -instance (Reexpressible i1 instr, Reexpressible i2 instr) =>- Reexpressible (i1 :+: i2) instr+-- | Rewrite an instruction changing its \"expression\" sub-structure+reexpressInstr :: (Reexpressible i instr (), Monad m)+ => (forall b . exp1 b -> ProgramT instr '(exp2,fs) m (exp2 b))+ -- ^ Conversion of the \"expression\" sub-structure+ -> i '(ProgramT instr '(exp2,fs) m, '(exp1, fs)) a+ -> ProgramT instr '(exp2,fs) m a+reexpressInstr reexp+ = flip runReaderT ()+ . reexpressInstrEnv (lift . reexp)+ . hbimap lift id++instance (Reexpressible i1 instr env, Reexpressible i2 instr env) =>+ Reexpressible (i1 :+: i2) instr env where- reexpressInstr reexp (Inl i) = reexpressInstr reexp i- reexpressInstr reexp (Inr i) = reexpressInstr reexp i reexpressInstrEnv reexp (Inl i) = reexpressInstrEnv reexp i reexpressInstrEnv reexp (Inr i) = reexpressInstrEnv reexp i @@ -509,7 +511,7 @@ -- Conversion of expressions is done in the target monad, so pure expressions -- are allowed to expand to monadic code. This can be used e.g. to \"compile\" -- complex expressions into simple expressions with supporting monadic code.-reexpress :: (Reexpressible instr1 instr2, Monad m)+reexpress :: (Reexpressible instr1 instr2 (), Monad m) => (forall b . exp1 b -> ProgramT instr2 '(exp2,fs) m (exp2 b)) -- ^ Conversion of expressions -> ProgramT instr1 '(exp1,fs) m a -> ProgramT instr2 '(exp2,fs) m a@@ -521,7 +523,7 @@ -- Conversion of expressions is done in the target monad, so pure expressions -- are allowed to expand to monadic code. This can be used e.g. to \"compile\" -- complex expressions into simple expressions with supporting monadic code.-reexpressEnv :: (Reexpressible instr1 instr2, Monad m)+reexpressEnv :: (Reexpressible instr1 instr2 env, Monad m) => ( forall b . exp1 b -> ReaderT env (ProgramT instr2 '(exp2,fs) m) (exp2 b) )