packages feed

free 2.1.1.1 → 2.2

raw patch · 5 files changed

+45/−46 lines, 5 filesdep −data-lensPVP ok

version bump matches the API change (PVP)

Dependencies removed: data-lens

API changes (from Hackage documentation)

- Control.Comonad.Cofree: extractLens :: Lens (Cofree f a) a
- Control.Comonad.Cofree: telescope :: [Lens (f (Cofree f a)) (Cofree f a)] -> Lens (Cofree f a) a
- Control.Comonad.Cofree: unwrapLens :: Lens (Cofree f a) (f (Cofree f a))
+ Control.Comonad.Cofree: extracting :: Functor f => (a -> f a) -> Cofree g a -> f (Cofree g a)
+ Control.Comonad.Cofree: telescoping :: (Functor f, Functor g) => [(Cofree g a -> f (Cofree g a)) -> g (Cofree g a) -> f (g (Cofree g a))] -> (a -> f a) -> Cofree g a -> f (Cofree g a)
+ Control.Comonad.Cofree: unwrapping :: Functor f => (g (Cofree g a) -> f (g (Cofree g a))) -> Cofree g a -> f (Cofree g a)

Files

Control/Comonad/Cofree.hs view
@@ -1,8 +1,8 @@-{-# LANGUAGE CPP-           , FlexibleContexts-           , FlexibleInstances-           , UndecidableInstances-           , MultiParamTypeClasses #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-} ----------------------------------------------------------------------------- -- | -- Module      :  Control.Comonad.Cofree@@ -23,9 +23,9 @@   , coiter   , unfold   -- * Lenses into cofree comonads-  , extractLens-  , unwrapLens-  , telescope+  , extracting+  , unwrapping+  , telescoping   ) where  import Control.Applicative@@ -34,10 +34,8 @@ import Control.Comonad.Cofree.Class import Control.Comonad.Env.Class import Control.Comonad.Store.Class as Class-import Control.Comonad.Trans.Store import Control.Comonad.Traced.Class import Control.Category-import Data.Lens.Common import Data.Functor.Bind import Data.Distributive import Data.Foldable@@ -59,7 +57,7 @@ coiter psi a = a :< (coiter psi <$> psi a)  unfold :: Functor f => (b -> (a, f b)) -> b -> Cofree f a-unfold f c = case f c of +unfold f c = case f c of   (x, d) -> x :< fmap (unfold f) d  instance Functor f => ComonadCofree f (Cofree f) where@@ -83,7 +81,7 @@   lower (_ :< as) = fmap extract as  -- | lower . section = id-section :: Comonad f => f a -> Cofree f a +section :: Comonad f => f a -> Cofree f a section as = extract as :< extend section as  instance Apply f => Apply (Cofree f) where@@ -98,7 +96,7 @@   (_ :< fs)  *> (a :< as) = a :< (( *>) <$> fs <*> as)  instance (Show (f (Cofree f a)), Show a) => Show (Cofree f a) where-  showsPrec d (a :< as) = showParen (d > 5) $ +  showsPrec d (a :< as) = showParen (d > 5) $     showsPrec 6 a . showString " :< " . showsPrec 5 as  instance (Read (f (Cofree f a)), Read a) => Read (Cofree f a) where@@ -180,17 +178,16 @@ instance ComonadTraced m w => ComonadTraced m (Cofree w) where   trace m = trace m . lower -extractLens :: Lens (Cofree f a) a-extractLens = Lens $ \(a :< as) -> store (:< as) a+extracting :: Functor f => (a -> f a) -> Cofree g a -> f (Cofree g a)+extracting f (a :< as) = (:< as) <$> f a+{-# INLINE extracting #-} -unwrapLens :: Lens (Cofree f a) (f (Cofree f a))-unwrapLens = Lens $ \(a :< as) -> store (a :<) as+unwrapping :: Functor f => (g (Cofree g a) -> f (g (Cofree g a))) -> Cofree g a -> f (Cofree g a)+unwrapping f (a :< as) = (a :<) <$> f as+{-# INLINE unwrapping #-} --- | --- We'd prefer the following non-Haskell 98 type to make parametricity clearer,--- but this suffices------ > telescope :: (forall b. [Lens (f b) b]) -> Lens (Cofree f a) a-telescope :: [Lens (f (Cofree f a)) (Cofree f a)] -> Lens (Cofree f a) a-telescope []     = extractLens-telescope (l:ls) = telescope ls . l . unwrapLens+telescoping :: (Functor f, Functor g) =>+             [(Cofree g a -> f (Cofree g a)) -> g (Cofree g a) -> f (g (Cofree g a))] ->+              (a -> f a) -> Cofree g a -> f (Cofree g a)+telescoping [] = extracting+telescoping (l:ls) = unwrapping . l . telescoping ls
Control/Comonad/Cofree/Class.hs view
@@ -1,7 +1,7 @@-{-# LANGUAGE MultiParamTypeClasses-           , FunctionalDependencies-           , FlexibleInstances-           , UndecidableInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UndecidableInstances #-} ----------------------------------------------------------------------------- -- | -- Module      :  Control.Comonad.Cofree.Class
Control/Monad/Free.hs view
@@ -1,7 +1,7 @@-{-# LANGUAGE FlexibleContexts-           , FlexibleInstances-           , UndecidableInstances-	   , MultiParamTypeClasses #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-} ----------------------------------------------------------------------------- -- | -- Module      :  Control.Monad.Free@@ -59,7 +59,7 @@  instance (Read (f (Free f a)), Read a) => Read (Free f a) where   readsPrec d r = readParen (d > 10)-      (\r' -> [ (Pure m, t) +      (\r' -> [ (Pure m, t)              | ("Pure", s) <- lex r'              , (m, t) <- readsPrec 11 s]) r     ++ readParen (d > 10)@@ -75,7 +75,7 @@   Pure a  <.> Pure b = Pure (a b)   Pure a  <.> Free fb = Free $ fmap a <$> fb   Free fa <.> b = Free $ (<.> b) <$> fa-  + instance Functor f => Applicative (Free f) where   pure = Pure   Pure a <*> Pure b = Pure $ a b@@ -85,7 +85,7 @@ instance Functor f => Bind (Free f) where   Pure a >>- f = f a   Free m >>- f = Free ((>>- f) <$> m)-  + instance Functor f => Monad (Free f) where   return = Pure   Pure a >>= f = f a@@ -111,7 +111,7 @@   foldMap1 f (Free fa) = foldMap1 (foldMap1 f) fa  instance Traversable f => Traversable (Free f) where-  traverse f (Pure a) = Pure <$> f a +  traverse f (Pure a) = Pure <$> f a   traverse f (Free fa) = Free <$> traverse (traverse f) fa  instance Traversable1 f => Traversable1 (Free f) where@@ -122,11 +122,11 @@   tell = lift . tell   listen = lift . listen . retract   pass = lift . pass . retract-  + instance (Functor m, MonadReader e m) => MonadReader e (Free m) where   ask = lift ask   local f = lift . local f . retract-  + instance (Functor m, MonadState s m) => MonadState s (Free m) where   get = lift get   put s = lift (put s)@@ -144,7 +144,7 @@ instance Functor f => MonadFree f (Free f) where   wrap = Free --- | +-- | -- -- > retract . lift = id -- > retract . liftF = id
Control/Monad/Free/Class.hs view
@@ -1,4 +1,7 @@-{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE UndecidableInstances #-} ----------------------------------------------------------------------------- -- | -- Module      :  Control.Monad.Free.Class@@ -9,7 +12,7 @@ -- Stability   :  experimental -- Portability :  non-portable (fundeps, MPTCs) -----------------------------------------------------------------------------module Control.Monad.Free.Class +module Control.Monad.Free.Class   ( MonadFree(..)   ) where @@ -24,7 +27,7 @@ import Control.Monad.Trans.Maybe import Control.Monad.Trans.List import Control.Monad.Trans.Error-import Control.Monad.Trans.Identity +import Control.Monad.Trans.Identity import Data.Monoid  class Monad m => MonadFree f m | m -> f where@@ -55,7 +58,7 @@   wrap = MaybeT . wrap . fmap runMaybeT  instance (Functor f, MonadFree f m) => MonadFree f (IdentityT m) where-  wrap = IdentityT . wrap . fmap runIdentityT +  wrap = IdentityT . wrap . fmap runIdentityT  instance (Functor f, MonadFree f m) => MonadFree f (ListT m) where   wrap = ListT . wrap . fmap runListT
free.cabal view
@@ -1,6 +1,6 @@ name:          free category:      Control, Monads-version:       2.1.1.1+version:       2.2 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -35,7 +35,6 @@     comonad              >= 1.1.1.5 && < 1.2,     comonad-transformers >= 2.1.1.1 && < 2.2,     comonads-fd          >= 2.1.1.1 && < 2.2,-    data-lens            >= 2.0.4.1 && < 2.10,     semigroups           >= 0.8.3.1 && < 0.9    if impl(ghc)