free 2.0 → 2.0.1
raw patch · 2 files changed
+28/−4 lines, 2 filesdep +data-lensPVP ok
version bump matches the API change (PVP)
Dependencies added: 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))
Files
- Control/Comonad/Cofree.hs +26/−3
- free.cabal +2/−1
Control/Comonad/Cofree.hs view
@@ -22,6 +22,10 @@ , unwrap , coiter , unfold+ -- * Lenses into cofree comonads+ , extractLens+ , unwrapLens+ , telescope ) where import Control.Applicative@@ -29,8 +33,11 @@ import Control.Comonad.Trans.Class import Control.Comonad.Cofree.Class import Control.Comonad.Env.Class-import Control.Comonad.Store.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@@ -39,6 +46,7 @@ import Data.Traversable import Data.Semigroup.Foldable import Data.Semigroup.Traversable+import Prelude hiding (id,(.)) #ifdef GHC_TYPEABLE import Data.Data@@ -162,9 +170,24 @@ ask = ask . lower instance ComonadStore s w => ComonadStore s (Cofree w) where- pos (_ :< as) = pos as- peek s (_ :< as) = extract (peek s as)+ pos (_ :< as) = Class.pos as+ peek s (_ :< as) = extract (Class.peek s as) 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++unwrapLens :: Lens (Cofree f a) (f (Cofree f a))+unwrapLens = Lens $ \(a :< as) -> store (a :<) as++-- | +-- 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
free.cabal view
@@ -1,6 +1,6 @@ name: free category: Control, Monads-version: 2.0+version: 2.0.1 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -33,6 +33,7 @@ comonad >= 1.1.1 && < 1.2, comonad-transformers >= 2.0 && < 2.1, comonads-fd >= 2.0 && < 2.1,+ data-lens >= 2.0 && < 2.1, semigroups >= 0.7.1 && < 0.8 if impl(ghc)