packages feed

comonad-transformers 1.4.0 → 1.5.0

raw patch · 4 files changed

+88/−46 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Control.Comonad.Trans.Store.Lazy: experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a
- Control.Comonad.Trans.Store.Lazy: get :: StoreT s w a -> s
- Control.Comonad.Trans.Store.Lazy: modify :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Lazy: put :: Comonad w => s -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Memo: experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a
- Control.Comonad.Trans.Store.Memo: get :: StoreT s w a -> s
- Control.Comonad.Trans.Store.Memo: modify :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Memo: put :: Comonad w => s -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Strict: experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a
- Control.Comonad.Trans.Store.Strict: get :: StoreT s w a -> s
- Control.Comonad.Trans.Store.Strict: modify :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
- Control.Comonad.Trans.Store.Strict: put :: Comonad w => s -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store.Lazy: peek :: Comonad w => s -> StoreT s w a -> a
+ Control.Comonad.Trans.Store.Lazy: peeks :: Comonad w => (s -> s) -> StoreT s w a -> a
+ Control.Comonad.Trans.Store.Lazy: pos :: StoreT s w a -> s
+ Control.Comonad.Trans.Store.Lazy: seek :: Comonad w => s -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store.Lazy: seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store.Memo: peek :: Comonad w => s -> StoreT s w a -> a
+ Control.Comonad.Trans.Store.Memo: peeks :: Comonad w => (s -> s) -> StoreT s w a -> a
+ Control.Comonad.Trans.Store.Memo: pos :: StoreT s w a -> s
+ Control.Comonad.Trans.Store.Memo: seek :: Comonad w => s -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store.Memo: seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store.Strict: peek :: Comonad w => s -> StoreT s w a -> a
+ Control.Comonad.Trans.Store.Strict: peeks :: Comonad w => (s -> s) -> StoreT s w a -> a
+ Control.Comonad.Trans.Store.Strict: pos :: StoreT s w a -> s
+ Control.Comonad.Trans.Store.Strict: seek :: Comonad w => s -> StoreT s w a -> StoreT s w a
+ Control.Comonad.Trans.Store.Strict: seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a

Files

Control/Comonad/Trans/Store/Lazy.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module      :  Control.Comonad.Trans.Store.Lazy@@ -10,9 +11,9 @@ -- -- The lazy store (state-in-context/costate) comonad transformer is subject to the laws: -- --- > x = put (get x) x--- > y = get (put y) x)--- > put y x = put y (put z x)+-- > x = seek (pos x) x+-- > y = pos (seek y x)+-- > seek y x = seek y (seek z x) -- -- Thanks go to Russell O'Connor and Daniel Peebles for their help formulating  -- and proving the laws for this comonad transformer.@@ -24,10 +25,9 @@   -- * The Store comonad transformer   , StoreT(..), runStoreT   -- * Operations-  , get-  , put-  , modify-  , experiment+  , pos+  , seek, seeks+  , peek, peeks   ) where  import Control.Comonad@@ -82,14 +82,28 @@ instance ComonadHoist (StoreT s) where   cohoist ~(StoreT f s) = StoreT (Identity (extract f)) s -get :: StoreT s w a -> s-get (StoreT _ s) = s+-- | Read the current position+pos :: StoreT s w a -> s+pos (StoreT _ s) = s -put :: Comonad w => s -> StoreT s w a -> StoreT s w a -put s ~(StoreT f _) = StoreT f s+-- | Seek to an absolute location+--+-- > seek s = peek s . duplicate+seek :: Comonad w => s -> StoreT s w a -> StoreT s w a +seek s ~(StoreT f _) = StoreT f s -modify :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a-modify f ~(StoreT g s) = StoreT g (f s)+-- | Seek to a relative location+--+-- > seeks f = peeks f . duplicate+seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a+seeks f ~(StoreT g s) = StoreT g (f s) -experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a-experiment fs ~(StoreT g s) = fmap (\f -> extract g (f s)) fs+-- | Peek at a value at a given absolute location+--+-- > peek x . extend (peek y) = peek y+peek :: Comonad w => s -> StoreT s w a -> a+peek s (StoreT g _) = extract g s++-- | Peek at a value at a given relative location+peeks :: Comonad w => (s -> s) -> StoreT s w a -> a+peeks f ~(StoreT g s) = extract g (f s)
Control/Comonad/Trans/Store/Memo.hs view
@@ -12,9 +12,9 @@ -- The memoizing store (state-in-context/costate) comonad transformer is  -- subject to the laws: -- --- > x = put (get x) x--- > y = get (put y x)--- > put y x = put y (put z x)+-- > x = seek (pos x) x+-- > y = pos (seek y x)+-- > seek y x = seek y (seek z x) -- -- This version of the transformer lazily memoizes the result of applying the  -- comonad to the current state. This can be useful for avoiding redundant @@ -27,10 +27,9 @@   -- * The Store comonad transformer   , StoreT, storeT, runStoreT   -- * Operations-  , get-  , put-  , modify-  , experiment+  , pos+  , seek, seeks+  , peek, peeks   ) where  import Control.Comonad@@ -90,14 +89,29 @@ instance ComonadHoist (StoreT s) where   cohoist (StoreT f s w) = StoreT (Identity (extract f)) s (Identity (extract w)) -get :: StoreT s w a -> s-get (StoreT _ s _) = s+-- | Read the current position+pos :: StoreT s w a -> s+pos (StoreT _ s _) = s -put :: Comonad w => s -> StoreT s w a -> StoreT s w a-put s (StoreT f _ _) = storeT f s+-- | Seek to an absolute location+--+-- > seek s = peek s . duplicate+seek :: Comonad w => s -> StoreT s w a -> StoreT s w a+seek s (StoreT f _ _) = storeT f s -modify :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a-modify f (StoreT g s _) = storeT g (f s)+-- | Seek to a relative location+--+-- > seeks f = peeks f . duplicate+seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a+seeks f (StoreT g s _) = storeT g (f s) -experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a-experiment fs (StoreT g s _) = fmap (\f -> extract g (f s)) fs+-- | Peek at a value at a given absolute location+--+-- > peek x . extend (peek y) = peek y+peek :: Comonad w => s -> StoreT s w a -> a+peek s (StoreT g _ _) = extract g s++-- | Peek at a value at a given relative location+peeks :: Comonad w => (s -> s) -> StoreT s w a -> a+peeks f (StoreT g s _) = extract g (f s)+
Control/Comonad/Trans/Store/Strict.hs view
@@ -10,9 +10,9 @@ -- -- The strict store (state-in-context/costate) comonad transformer is subject to the laws: -- --- > x = put (get x) x--- > y = get (put y x)--- > put y x = put y (put z x)+-- > x = seek (pos x) x+-- > y = pos (seek y x)+-- > seek y x = seek y (seek z x) -- -- Thanks go to Russell O'Connor and Daniel Peebles for their help formulating  -- and proving the laws for this comonad transformer.@@ -24,10 +24,9 @@   -- * The Store comonad transformer   , StoreT(..), runStoreT   -- * Operations-  , get-  , put-  , modify-  , experiment+  , pos+  , seek, seeks+  , peek, peeks   ) where  import Control.Comonad@@ -82,14 +81,29 @@ instance ComonadHoist (StoreT s) where   cohoist (StoreT f s) = StoreT (Identity (extract f)) s -get :: StoreT s w a -> s-get (StoreT _ s) = s+-- | Read the current position+pos :: StoreT s w a -> s+pos (StoreT _ s) = s -put :: Comonad w => s -> StoreT s w a -> StoreT s w a-put s (StoreT f _) = StoreT f s+-- | Seek to an absolute location+--+-- > seek s = peek s . duplicate+seek :: Comonad w => s -> StoreT s w a -> StoreT s w a+seek s ~(StoreT f _) = StoreT f s -modify :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a-modify f (StoreT g s) = StoreT g (f s)+-- | Seek to a relative location+--+-- > seeks f = peeks f . duplicate+seeks :: Comonad w => (s -> s) -> StoreT s w a -> StoreT s w a+seeks f ~(StoreT g s) = StoreT g (f s) -experiment :: (Comonad w, Functor f) => f (s -> s) -> StoreT s w a -> f a-experiment fs (StoreT g s) = fmap (\f -> extract g (f s)) fs+-- | Peek at a value at a given absolute location+--+-- > peek x . extend (peek y) = peek y+peek :: Comonad w => s -> StoreT s w a -> a+peek s (StoreT g _) = extract g s++-- | Peek at a value at a given relative location+peeks :: Comonad w => (s -> s) -> StoreT s w a -> a+peeks f ~(StoreT g s) = extract g (f s)+
comonad-transformers.cabal view
@@ -1,6 +1,6 @@ name:          comonad-transformers category:      Control, Comonads-version:       1.4.0+version:       1.5.0 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE