packages feed

free-functors 0.7.1 → 0.7.2

raw patch · 4 files changed

+21/−13 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- 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: rightAdjunctT :: ForallT c t => (a -> t f b) -> Free c a -> t f b
+ Data.Functor.Free: instance Data.Functor.Free.ForallLifted c => Data.Foldable.Foldable (Data.Functor.Free.Free c)
+ Data.Functor.Free: instance Data.Functor.Free.ForallLifted c => Data.Traversable.Traversable (Data.Functor.Free.Free c)

Files

CHANGELOG view
@@ -1,5 +1,11 @@ CHANGELOG +0.7.1 -> 0.7.2+  - Fixed Traversable instance of `Free c`++0.7 -> 0.7.1+  - Rewritten SuperClass1+ 0.6.5 -> 0.7   - Allow contravariant uses of HFree   - Added HHFree for free profunctors/categories/arrows
examples/NonEmptyList.hs view
@@ -24,6 +24,6 @@ fromList :: [a] -> NonEmptyList a fromList = foldr1 (<>) . map pure --- Test the comonad and foldable instances, returns [10,9,7,4].+-- Test the comonad and foldable instances, returns [15,14,12,9,5]. test :: NonEmptyList Int test = extend sum $ (pure 1 <> pure 2) <> (pure 3 <> (pure 4 <> pure 5))
free-functors.cabal view
@@ -1,5 +1,5 @@ name:                free-functors-version:             0.7.1+version:             0.7.2 synopsis:            Free functors, 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
src/Data/Functor/Free.hs view
@@ -32,7 +32,6 @@   , unit   , rightAdjunct   , rightAdjunctF-  , rightAdjunctT   , counit   , leftAdjunct   , transform@@ -73,11 +72,11 @@ --   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 } --- | `unit` allows you to create `Free c` values, together with the operations from the class @c@.+-- | `unit` allows you to create @`Free` c@ values, together with the operations from the class @c@. unit :: a -> Free c a unit a = Free $ \k -> k a --- | `rightAdjunct` is the destructor of `Free c` values.+-- | `rightAdjunct` is the destructor of @`Free` c@ values. rightAdjunct :: c b => (a -> b) -> Free c a -> b rightAdjunct f g = runFree g f @@ -90,14 +89,16 @@       -> (a -> f b) -> Free c a -> f b     h (Sub Dict) f = f -rightAdjunctT :: ForallT c t => (a -> t f b) -> Free c a -> t f b-rightAdjunctT = h instT rightAdjunct+class ForallLifted c where+  dictLifted :: Applicative f => Dict (c (LiftAFree c f a))++rightAdjunctLifted :: (ForallLifted c, Applicative f) => (a -> LiftAFree c f b) -> Free c a -> LiftAFree c f b+rightAdjunctLifted = h dictLifted rightAdjunct   where-    h :: ForallT c t-      => (ForallT c t :- c (t f b))+    h :: Dict (c (t f b))       -> (c (t f b) => (a -> t f b) -> Free c a -> t f b)       -> (a -> t f b) -> Free c a -> t f b-    h (Sub Dict) f = f+    h Dict f = f  -- | @counit = rightAdjunct id@ counit :: c a => Free c a -> a@@ -183,6 +184,7 @@   , deriveInstanceWith_skipSignature freeHeader $ return []   , deriveInstanceWith_skipSignature liftAFreeHeader $ return []   , deriveInstanceWith_skipSignature showHelperHeader $ return []+  , [d|instance ForallLifted $(return c) where dictLifted = Dict|]   ]   where     freeHeader = return $ ForallT [PlainTV a] []@@ -205,11 +207,11 @@ instance (Applicative f, c ~ Class s) => Algebra s (LiftAFree c f a) where   algebra = LiftAFree . fmap algebra . traverse getLiftAFree -instance ForallT c (LiftAFree c) => Foldable (Free c) where+instance ForallLifted c => Foldable (Free c) where   foldMap = foldMapDefault -instance ForallT c (LiftAFree c) => Traversable (Free c) where-  traverse f = getLiftAFree . rightAdjunctT (LiftAFree . fmap unit . f)+instance ForallLifted c => Traversable (Free c) where+  traverse f = getLiftAFree . rightAdjunctLifted (LiftAFree . fmap unit . f)   data ShowHelper f a = ShowUnit a | ShowRec (f (ShowHelper f a))