free-functors 0.6.3.3 → 0.6.4
raw patch · 3 files changed
+19/−19 lines, 3 filesdep ~algebraic-classesdep ~template-haskellPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: algebraic-classes, template-haskell
API changes (from Hackage documentation)
- Data.Functor.Cofree: instance (ForallF c (Cofree c)) => Comonad (Cofree c)
- Data.Functor.Cofree: instance (ForallF c Identity, ForallF c (Cofree c), ForallF c (Compose (Cofree c) (Cofree c))) => Applicative (Cofree c)
- Data.Functor.Cofree: instance (ForallF c Identity, ForallF c (Cofree c), ForallF c (Compose (Cofree c) (Cofree c))) => Monad (Cofree c)
- Data.Functor.Cofree: instance Functor (Cofree c)
- Data.Functor.Free: instance (Applicative f, c ~ Class s) => Algebra s (LiftAFree c f a)
- Data.Functor.Free: instance (ForallF c Identity, ForallF c (Compose (Free c) (Free c))) => Comonad (Free c)
- Data.Functor.Free: instance (ForallT c (LiftAFree c)) => Foldable (Free c)
- Data.Functor.Free: instance (ForallT c (LiftAFree c)) => Traversable (Free c)
- Data.Functor.Free: instance (Show a, Show (Signature c (ShowHelper (Signature c) a)), c (ShowHelper (Signature c) a)) => Show (Free c a)
- Data.Functor.Free: instance (Show a, Show (f (ShowHelper f a))) => Show (ShowHelper f a)
- Data.Functor.Free: instance Algebra f (ShowHelper f a)
- Data.Functor.Free: instance Applicative (Free c)
- Data.Functor.Free: instance Functor (Free c)
- Data.Functor.Free: instance Monad (Free c)
- Data.Functor.Free: instance c ~ Class f => Algebra f (Free c a)
- Data.Functor.Free: runFree :: Free c a -> forall b. c b => (a -> b) -> b
- Data.Functor.HCofree: instance Comonad (HCofree Comonad g)
- Data.Functor.HCofree: instance Foldable (HCofree Foldable g)
- Data.Functor.HCofree: instance Foldable (HCofree Traversable g)
- Data.Functor.HCofree: instance Functor (HCofree c g)
- Data.Functor.HCofree: instance Traversable (HCofree Traversable g)
- Data.Functor.HFree: instance Alternative (HFree Alternative f)
- Data.Functor.HFree: instance Applicative (HFree Alternative f)
- Data.Functor.HFree: instance Applicative (HFree Applicative f)
- Data.Functor.HFree: instance Applicative (HFree Monad f)
- Data.Functor.HFree: instance Functor (HFree c f)
- Data.Functor.HFree: instance Monad (HFree Monad f)
- Data.Functor.HFree: runHFree :: HFree c f a -> forall g. (c g, Functor g) => (f :~> g) -> g a
+ Data.Functor.Cofree: instance (Data.Constraint.Forall.ForallF c Data.Functor.Identity.Identity, Data.Constraint.Forall.ForallF c (Data.Functor.Cofree.Cofree c), Data.Constraint.Forall.ForallF c (Data.Functor.Compose.Compose (Data.Functor.Cofree.Cofree c) (Data.Functor.Cofree.Cofree c))) => GHC.Base.Applicative (Data.Functor.Cofree.Cofree c)
+ Data.Functor.Cofree: instance (Data.Constraint.Forall.ForallF c Data.Functor.Identity.Identity, Data.Constraint.Forall.ForallF c (Data.Functor.Cofree.Cofree c), Data.Constraint.Forall.ForallF c (Data.Functor.Compose.Compose (Data.Functor.Cofree.Cofree c) (Data.Functor.Cofree.Cofree c))) => GHC.Base.Monad (Data.Functor.Cofree.Cofree c)
+ Data.Functor.Cofree: instance Data.Constraint.Forall.ForallF c (Data.Functor.Cofree.Cofree c) => Control.Comonad.Comonad (Data.Functor.Cofree.Cofree c)
+ Data.Functor.Cofree: instance GHC.Base.Functor (Data.Functor.Cofree.Cofree c)
+ Data.Functor.Free: [runFree] :: Free c a -> forall b. c b => (a -> b) -> b
+ Data.Functor.Free: instance (Data.Constraint.Forall.ForallF c Data.Functor.Identity.Identity, Data.Constraint.Forall.ForallF c (Data.Functor.Compose.Compose (Data.Functor.Free.Free c) (Data.Functor.Free.Free c))) => Control.Comonad.Comonad (Data.Functor.Free.Free c)
+ Data.Functor.Free: instance (GHC.Base.Applicative f, c ~ Data.Algebra.Internal.Class s) => Data.Algebra.Internal.Algebra s (Data.Functor.Free.LiftAFree c f a)
+ Data.Functor.Free: instance (GHC.Show.Show a, GHC.Show.Show (Data.Algebra.Internal.Signature c (Data.Functor.Free.ShowHelper (Data.Algebra.Internal.Signature c) a)), c (Data.Functor.Free.ShowHelper (Data.Algebra.Internal.Signature c) a)) => GHC.Show.Show (Data.Functor.Free.Free c a)
+ Data.Functor.Free: instance (GHC.Show.Show a, GHC.Show.Show (f (Data.Functor.Free.ShowHelper f a))) => GHC.Show.Show (Data.Functor.Free.ShowHelper f a)
+ Data.Functor.Free: instance (c ~ Data.Algebra.Internal.Class f) => Data.Algebra.Internal.Algebra f (Data.Functor.Free.Free c a)
+ Data.Functor.Free: instance Data.Algebra.Internal.Algebra f (Data.Functor.Free.ShowHelper f a)
+ Data.Functor.Free: instance Data.Constraint.Forall.ForallT c (Data.Functor.Free.LiftAFree c) => Data.Foldable.Foldable (Data.Functor.Free.Free c)
+ Data.Functor.Free: instance Data.Constraint.Forall.ForallT c (Data.Functor.Free.LiftAFree c) => Data.Traversable.Traversable (Data.Functor.Free.Free c)
+ Data.Functor.Free: instance GHC.Base.Applicative (Data.Functor.Free.Free c)
+ Data.Functor.Free: instance GHC.Base.Functor (Data.Functor.Free.Free c)
+ Data.Functor.Free: instance GHC.Base.Monad (Data.Functor.Free.Free c)
+ Data.Functor.HCofree: instance Control.Comonad.Comonad (Data.Functor.HCofree.HCofree Control.Comonad.Comonad g)
+ Data.Functor.HCofree: instance Data.Foldable.Foldable (Data.Functor.HCofree.HCofree Data.Foldable.Foldable g)
+ Data.Functor.HCofree: instance Data.Foldable.Foldable (Data.Functor.HCofree.HCofree Data.Traversable.Traversable g)
+ Data.Functor.HCofree: instance Data.Traversable.Traversable (Data.Functor.HCofree.HCofree Data.Traversable.Traversable g)
+ Data.Functor.HCofree: instance GHC.Base.Functor (Data.Functor.HCofree.HCofree c g)
+ Data.Functor.HFree: [runHFree] :: HFree c f a -> forall g. (c g, Functor g) => (f :~> g) -> g a
+ Data.Functor.HFree: instance GHC.Base.Alternative (Data.Functor.HFree.HFree GHC.Base.Alternative f)
+ Data.Functor.HFree: instance GHC.Base.Applicative (Data.Functor.HFree.HFree GHC.Base.Alternative f)
+ Data.Functor.HFree: instance GHC.Base.Applicative (Data.Functor.HFree.HFree GHC.Base.Applicative f)
+ Data.Functor.HFree: instance GHC.Base.Applicative (Data.Functor.HFree.HFree GHC.Base.Monad f)
+ Data.Functor.HFree: instance GHC.Base.Functor (Data.Functor.HFree.HFree c f)
+ Data.Functor.HFree: instance GHC.Base.Monad (Data.Functor.HFree.HFree GHC.Base.Monad f)
Files
- examples/Parser.hs +3/−3
- free-functors.cabal +3/−3
- src/Data/Functor/Free.hs +13/−13
examples/Parser.hs view
@@ -1,5 +1,5 @@-{-# LANGUAGE - FlexibleInstances +{-# LANGUAGE+ FlexibleInstances , TypeOperators , GADTs , TypeSynonymInstances@@ -18,7 +18,7 @@ type Parser c = HFree Alternative (ParserF c) -symbol :: c -> Parser (ParserF c) c+symbol :: c -> Parser c c symbol = liftFree . Symbol
free-functors.cabal view
@@ -1,5 +1,5 @@ name: free-functors-version: 0.6.3.3+version: 0.6.4 synopsis: Provides free functors that are adjoint to functors that forget class constraints. description: A free functor is a left adjoint to a forgetful functor. It used to be the case that the only category that was easy to work with in Haskell was Hask itself, so@@ -46,8 +46,8 @@ transformers >= 0.2.0.0 && < 0.5, comonad >= 4.0 && < 4.3, void >= 0.4 && < 0.8,- algebraic-classes >= 0.5 && < 0.6,- template-haskell >= 2.8.0.0 && < 2.9.1+ algebraic-classes >= 0.5 && < 0.7,+ template-haskell >= 2.8.0.0 && < 2.10.1 source-repository head type: git
src/Data/Functor/Free.hs view
@@ -2,7 +2,7 @@ ConstraintKinds , GADTs , RankNTypes- , TypeOperators + , TypeOperators , FlexibleInstances , MultiParamTypeClasses , UndecidableInstances@@ -38,7 +38,7 @@ , unfold , convert , convertClosed- + -- * Coproducts , Coproduct , coproduct@@ -46,9 +46,9 @@ , inR , InitialObject , initial- + ) where- + import Control.Applicative import Control.Comonad import Data.Function@@ -66,9 +66,9 @@ import Data.Algebra.TH import Language.Haskell.TH.Syntax --- | The free functor for class @c@. +-- | The free functor for class @c@. ----- @Free c a@ is basically an expression tree with operations from class @c@ +-- @Free c a@ is basically an expression tree with operations from class @c@ -- and variables/placeholders of type @a@, created with `unit`. -- Monadic bind allows you to replace each of these variables with another sub-expression. newtype Free c a = Free { runFree :: forall b. c b => (a -> b) -> b }@@ -150,7 +150,7 @@ --- | Products of @Monoid@s are @Monoid@s themselves. But coproducts of @Monoid@s are not. +-- | Products of @Monoid@s are @Monoid@s themselves. But coproducts of @Monoid@s are not. -- However, the free @Monoid@ applied to the coproduct /is/ a @Monoid@, and it is the coproduct in the category of @Monoid@s. -- This is also called the free product, and generalizes to any algebraic class. type Coproduct c m n = Free c (Either m n)@@ -172,8 +172,8 @@ -- | Derive the instances of @`Free` c a@ for the class @c@, `Show`, `Foldable` and `Traversable`. ----- For example: --- +-- For example:+-- -- @deriveInstances ''Num@ deriveInstances :: Name -> Q [Dec] deriveInstances nm = concat <$> sequenceA@@ -183,11 +183,11 @@ , deriveInstanceWith_skipSignature showHelperHeader $ return [] ] where- freeHeader = return $ ForallT [PlainTV a] [] + freeHeader = return $ ForallT [PlainTV a] [] (AppT c (AppT (AppT free c) (VarT a)))- liftAFreeHeader = return $ ForallT [PlainTV f,PlainTV a] [ClassP ''Applicative [VarT f]] + liftAFreeHeader = return $ ForallT [PlainTV f,PlainTV a] [AppT (ConT ''Applicative) (VarT f)] (AppT c (AppT (AppT (AppT liftAFree c) (VarT f)) (VarT a)))- showHelperHeader = return $ ForallT [PlainTV a] [] + showHelperHeader = return $ ForallT [PlainTV a] [] (AppT c (AppT (AppT showHelper sig) (VarT a))) free = ConT ''Free liftAFree = ConT ''LiftAFree@@ -219,5 +219,5 @@ showsPrec p (ShowUnit a) = showParen (p > 10) $ showString "unit " . showsPrec 11 a showsPrec p (ShowRec f) = showsPrec p f -instance (Show a, Show (Signature c (ShowHelper (Signature c) a)), c (ShowHelper (Signature c) a)) => Show (Free c a) where +instance (Show a, Show (Signature c (ShowHelper (Signature c) a)), c (ShowHelper (Signature c) a)) => Show (Free c a) where show = show . rightAdjunct (ShowUnit :: a -> ShowHelper (Signature c) a)