comonad-transformers 1.7 → 1.8.0
raw patch · 6 files changed
+1/−605 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.Comonad.Trans.Cofree: (:<) :: a -> f (Cofree f a) -> Cofree f a
- Control.Comonad.Trans.Cofree: coiter :: Functor f => (a -> f a) -> a -> Cofree f a
- Control.Comonad.Trans.Cofree: data Cofree f a
- Control.Comonad.Trans.Cofree: instance (Eq (f (Cofree f a)), Eq a) => Eq (Cofree f a)
- Control.Comonad.Trans.Cofree: instance (Ord (f (Cofree f a)), Ord a) => Ord (Cofree f a)
- Control.Comonad.Trans.Cofree: instance (Read (f (Cofree f a)), Read a) => Read (Cofree f a)
- Control.Comonad.Trans.Cofree: instance (Show (f (Cofree f a)), Show a) => Show (Cofree f a)
- Control.Comonad.Trans.Cofree: instance Applicative f => Applicative (Cofree f)
- Control.Comonad.Trans.Cofree: instance Apply f => Apply (Cofree f)
- Control.Comonad.Trans.Cofree: instance ComonadTrans Cofree
- Control.Comonad.Trans.Cofree: instance Distributive f => Distributive (Cofree f)
- Control.Comonad.Trans.Cofree: instance Foldable f => Foldable (Cofree f)
- Control.Comonad.Trans.Cofree: instance Foldable1 f => Foldable1 (Cofree f)
- Control.Comonad.Trans.Cofree: instance Functor f => Comonad (Cofree f)
- Control.Comonad.Trans.Cofree: instance Functor f => Extend (Cofree f)
- Control.Comonad.Trans.Cofree: instance Functor f => Functor (Cofree f)
- Control.Comonad.Trans.Cofree: instance Traversable f => Traversable (Cofree f)
- Control.Comonad.Trans.Cofree: instance Traversable1 f => Traversable1 (Cofree f)
- Control.Comonad.Trans.Cofree: section :: Comonad f => f a -> Cofree f a
- Control.Comonad.Trans.Cofree: unfold :: Functor f => (b -> (a, f b)) -> b -> Cofree f a
- Control.Comonad.Trans.Cofree: unwrap :: Cofree f a -> f (Cofree f a)
- Control.Monad.Trans.Free: Free :: (f (Free f a)) -> Free f a
- Control.Monad.Trans.Free: Pure :: a -> Free f a
- Control.Monad.Trans.Free: data Free f a
- Control.Monad.Trans.Free: instance (Eq (f (Free f a)), Eq a) => Eq (Free f a)
- Control.Monad.Trans.Free: instance (Functor v, MonadPlus v) => MonadPlus (Free v)
- Control.Monad.Trans.Free: instance (Ord (f (Free f a)), Ord a) => Ord (Free f a)
- Control.Monad.Trans.Free: instance (Read (f (Free f a)), Read a) => Read (Free f a)
- Control.Monad.Trans.Free: instance (Show (f (Free f a)), Show a) => Show (Free f a)
- Control.Monad.Trans.Free: instance Alternative v => Alternative (Free v)
- Control.Monad.Trans.Free: instance Foldable f => Foldable (Free f)
- Control.Monad.Trans.Free: instance Foldable1 f => Foldable1 (Free f)
- Control.Monad.Trans.Free: instance Functor f => Applicative (Free f)
- Control.Monad.Trans.Free: instance Functor f => Apply (Free f)
- Control.Monad.Trans.Free: instance Functor f => Bind (Free f)
- Control.Monad.Trans.Free: instance Functor f => Functor (Free f)
- Control.Monad.Trans.Free: instance Functor f => Monad (Free f)
- Control.Monad.Trans.Free: instance MonadTrans Free
- Control.Monad.Trans.Free: instance Traversable f => Traversable (Free f)
- Control.Monad.Trans.Free: instance Traversable1 f => Traversable1 (Free f)
- Control.Monad.Trans.Free: iter :: Functor f => (f a -> a) -> Free f a -> a
- Control.Monad.Trans.Free: liftF :: Functor f => f a -> Free f a
- Control.Monad.Trans.Free: retract :: Monad f => Free f a -> f a
- Control.Monad.Trans.Free: wrap :: f (Free f a) -> Free f a
- Data.Lens.Common: (^!%=) :: Lens a b -> (b -> b) -> a -> a
- Data.Lens.Common: (^!) :: a -> Lens a b -> b
- Data.Lens.Common: (^!*=) :: Num b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^!+=) :: Num b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^!-=) :: Num b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^!/=) :: Fractional b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^!=) :: Lens a b -> b -> a -> a
- Data.Lens.Common: (^$!) :: Lens a b -> a -> b
- Data.Lens.Common: (^$) :: Lens a b -> a -> b
- Data.Lens.Common: (^%%=) :: Functor f => Lens a b -> (b -> f b) -> a -> f a
- Data.Lens.Common: (^%=) :: Lens a b -> (b -> b) -> a -> a
- Data.Lens.Common: (^*=) :: Num b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^+=) :: Num b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^-=) :: Num b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^.) :: a -> Lens a b -> b
- Data.Lens.Common: (^/=) :: Fractional b => Lens a b -> b -> a -> a
- Data.Lens.Common: (^=) :: Lens a b -> b -> a -> a
- Data.Lens.Common: Lens :: (a -> Store b a) -> Lens a b
- Data.Lens.Common: fstLens :: Lens (a, b) a
- Data.Lens.Common: instance Category Lens
- Data.Lens.Common: instance Semigroupoid Lens
- Data.Lens.Common: intMapLens :: Int -> Lens (IntMap v) (Maybe v)
- Data.Lens.Common: intSetLens :: Int -> Lens IntSet Bool
- Data.Lens.Common: iso :: (a -> b) -> (b -> a) -> Lens a b
- Data.Lens.Common: lens :: (a -> b) -> (b -> a -> a) -> Lens a b
- Data.Lens.Common: mapLens :: Ord k => k -> Lens (Map k v) (Maybe v)
- Data.Lens.Common: newtype Lens a b
- Data.Lens.Common: runLens :: Lens a b -> a -> Store b a
- Data.Lens.Common: setLens :: Ord k => k -> Lens (Set k) Bool
- Data.Lens.Common: sndLens :: Lens (a, b) b
- Data.Lens.Lazy: (!%%=) :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c
- Data.Lens.Lazy: (!%=) :: Monad m => Lens a b -> (b -> b) -> StateT a m b
- Data.Lens.Lazy: (!&&=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Lazy: (!*=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (!+=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (!-=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (!/=) :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (!=) :: Monad m => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (!||=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Lazy: (%%=) :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c
- Data.Lens.Lazy: (%=) :: Monad m => Lens a b -> (b -> b) -> StateT a m b
- Data.Lens.Lazy: (&&=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Lazy: (*=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (+=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (-=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (//=) :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: (||=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Lazy: (~=) :: Monad m => Lens a b -> b -> StateT a m b
- Data.Lens.Lazy: access :: Monad m => Lens a b -> StateT a m b
- Data.Lens.Lazy: focus :: Monad m => Lens a b -> StateT b m c -> StateT a m c
- Data.Lens.Strict: (!%%=) :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c
- Data.Lens.Strict: (!%=) :: Monad m => Lens a b -> (b -> b) -> StateT a m b
- Data.Lens.Strict: (!&&=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Strict: (!*=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (!+=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (!-=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (!/=) :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (!=) :: Monad m => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (!||=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Strict: (%%=) :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c
- Data.Lens.Strict: (%=) :: Monad m => Lens a b -> (b -> b) -> StateT a m b
- Data.Lens.Strict: (&&=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Strict: (*=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (+=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (-=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (//=) :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: (||=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool
- Data.Lens.Strict: (~=) :: Monad m => Lens a b -> b -> StateT a m b
- Data.Lens.Strict: access :: Monad m => Lens a b -> StateT a m b
- Data.Lens.Strict: focus :: Monad m => Lens a b -> StateT b m c -> StateT a m c
Files
- Control/Comonad/Trans/Cofree.hs +0/−151
- Control/Monad/Trans/Free.hs +0/−126
- Data/Lens/Common.hs +0/−140
- Data/Lens/Lazy.hs +0/−90
- Data/Lens/Strict.hs +0/−90
- comonad-transformers.cabal +1/−8
− Control/Comonad/Trans/Cofree.hs
@@ -1,151 +0,0 @@-{-# LANGUAGE CPP, FlexibleContexts, FlexibleInstances, UndecidableInstances #-}--------------------------------------------------------------------------------- |--- Module : Control.Comonad.Trans.Cofree--- Copyright : (C) 2008-2011 Edward Kmett,--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ Haskell 98 cofree comonads---------------------------------------------------------------------------------module Control.Comonad.Trans.Cofree- ( Cofree(..)- , section- , unwrap- , coiter- , unfold- ) where--import Control.Applicative-import Control.Comonad-import Control.Comonad.Trans.Class-import Data.Functor.Bind-import Data.Distributive-import Data.Foldable-import Data.Semigroup-import Data.Monoid-import Data.Traversable-import Data.Semigroup.Foldable-import Data.Semigroup.Traversable--#ifdef GHC_TYPEABLE-import Data.Data-#endif--infixr 5 :<--data Cofree f a = a :< f (Cofree f a)--unwrap :: Cofree f a -> f (Cofree f a)-unwrap (_ :< as) = as--coiter :: Functor f => (a -> f a) -> a -> Cofree f a-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 - (x, d) -> x :< fmap (unfold f) d--instance Distributive f => Distributive (Cofree f) where- distribute w = fmap extract w :< fmap distribute (collect unwrap w)--instance Functor f => Functor (Cofree f) where- fmap f (a :< as) = f a :< fmap (fmap f) as- b <$ (_ :< as) = b :< fmap (b <$) as--instance Functor f => Extend (Cofree f) where- extend f w = f w :< fmap (extend f) (unwrap w)- duplicate w = w :< fmap duplicate (unwrap w)--instance Functor f => Comonad (Cofree f) where- extract (a :< _) = a--instance ComonadTrans Cofree where- lower (_ :< as) = fmap extract as---- | lower . section = id-section :: Comonad f => f a -> Cofree f a -section as = extract as :< extend section as--instance Apply f => Apply (Cofree f) where- (f :< fs) <.> (a :< as) = f a :< ((<.>) <$> fs <.> as)- (f :< fs) <. (_ :< as) = f :< ((<. ) <$> fs <.> as)- (_ :< fs) .> (a :< as) = a :< (( .>) <$> fs <.> as)--instance Applicative f => Applicative (Cofree f) where- pure a = as where as = a :< pure as- (f :< fs) <*> (a :< as) = f a :< ((<*>) <$> fs <*> as)- (f :< fs) <* (_ :< as) = f :< ((<* ) <$> fs <*> as)- (_ :< 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 6 a . showString " :< " . showsPrec 5 as--instance (Read (f (Cofree f a)), Read a) => Read (Cofree f a) where- readsPrec d r = readParen (d > 5)- (\r' -> [(u :< v,w) |- (u, s) <- readsPrec 6 r',- (":<", t) <- lex s,- (v, w) <- readsPrec 5 t]) r--instance (Eq (f (Cofree f a)), Eq a) => Eq (Cofree f a) where- a :< as == b :< bs = a == b && as == bs--instance (Ord (f (Cofree f a)), Ord a) => Ord (Cofree f a) where- compare (a :< as) (b :< bs) = case compare a b of- LT -> LT- EQ -> compare as bs- GT -> GT--instance Foldable f => Foldable (Cofree f) where- foldMap f (a :< as) = f a `mappend` foldMap (foldMap f) as--instance Foldable1 f => Foldable1 (Cofree f) where- foldMap1 f (a :< as) = f a <> foldMap1 (foldMap1 f) as--instance Traversable f => Traversable (Cofree f) where- traverse f (a :< as) = (:<) <$> f a <*> traverse (traverse f) as--instance Traversable1 f => Traversable1 (Cofree f) where- traverse1 f (a :< as) = (:<) <$> f a <.> traverse1 (traverse1 f) as--#ifdef GHC_TYPEABLE-instance (Typeable1 f) => Typeable1 (Cofree f) where- typeOf1 dfa = mkTyConApp cofreeTyCon [typeOf1 (f dfa)]- where- f :: Cofree f a -> f a- f = undefined--instance (Typeable1 f, Typeable a) => Typeable (Cofree f a) where- typeOf = typeOfDefault--cofreeTyCon :: TyCon-cofreeTyCon = mkTyCon "Control.Comonad.Cofree.Cofree"-{-# NOINLINE cofreeTyCon #-}--instance- ( Typeable1 f- , Data (f (Cofree f a))- , Data a- ) => Data (Cofree f a) where- gfoldl f z (a :< as) = z (:<) `f` a `f` as- toConstr _ = cofreeConstr- gunfold k z c = case constrIndex c of- 1 -> k (k (z (:<)))- _ -> error "gunfold"- dataTypeOf _ = cofreeDataType- dataCast1 f = gcast1 f--cofreeConstr :: Constr-cofreeConstr = mkConstr cofreeDataType ":<" [] Infix-{-# NOINLINE cofreeConstr #-}--cofreeDataType :: DataType-cofreeDataType = mkDataType "Control.Comonad.Cofree.Cofree" [cofreeConstr]-{-# NOINLINE cofreeDataType #-}-#endif
− Control/Monad/Trans/Free.hs
@@ -1,126 +0,0 @@-{-# LANGUAGE FlexibleContexts, FlexibleInstances, UndecidableInstances #-}--------------------------------------------------------------------------------- |--- Module : Control.Monad.Trans.Free--- Copyright : (C) 2008-2011 Edward Kmett,--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ Haskell 98 free monads---------------------------------------------------------------------------------module Control.Monad.Trans.Free- ( Free(..)- , retract- , liftF- , iter- , wrap- ) where--import Control.Applicative-import Control.Monad (liftM, MonadPlus(..))-import Control.Monad.Trans.Class-import Data.Functor.Bind-import Data.Foldable-import Data.Traversable-import Data.Semigroup.Foldable-import Data.Semigroup.Traversable--data Free f a = Pure a | Free (f (Free f a))--instance (Eq (f (Free f a)), Eq a) => Eq (Free f a) where- Pure a == Pure b = a == b- Free fa == Free fb = fa == fb- _ == _ = False--instance (Ord (f (Free f a)), Ord a) => Ord (Free f a) where- Pure a `compare` Pure b = a `compare` b- Pure _ `compare` Free _ = LT- Free _ `compare` Pure _ = GT- Free fa `compare` Free fb = fa `compare` fb--instance (Show (f (Free f a)), Show a) => Show (Free f a) where- showsPrec d (Pure a) = showParen (d > 10) $- showString "Pure " . showsPrec 11 a- showsPrec d (Free m) = showParen (d > 10) $- showString "Free " . showsPrec 11 m--instance (Read (f (Free f a)), Read a) => Read (Free f a) where- readsPrec d r = readParen (d > 10)- (\r' -> [ (Pure m, t) - | ("Pure", s) <- lex r'- , (m, t) <- readsPrec 11 s]) r- ++ readParen (d > 10)- (\r' -> [ (Free m, t)- | ("Free", s) <- lex r'- , (m, t) <- readsPrec 11 s]) r--instance Functor f => Functor (Free f) where- fmap f (Pure a) = Pure (f a)- fmap f (Free fa) = Free (fmap f <$> fa)--instance Functor f => Apply (Free f) where- 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- Pure a <*> Free mb = Free $ fmap a <$> mb- Free ma <*> b = Free $ (<*> b) <$> ma--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- Free m >>= f = Free ((>>= f) <$> m)--instance Alternative v => Alternative (Free v) where- empty = Free empty- a <|> b = Free (pure a <|> pure b)--instance (Functor v, MonadPlus v) => MonadPlus (Free v) where- mzero = Free mzero- a `mplus` b = Free (return a `mplus` return b)--instance MonadTrans Free where- lift = Free . liftM Pure--instance Foldable f => Foldable (Free f) where- foldMap f (Pure a) = f a- foldMap f (Free fa) = foldMap (foldMap f) fa--instance Foldable1 f => Foldable1 (Free f) where- foldMap1 f (Pure a) = f a- foldMap1 f (Free fa) = foldMap1 (foldMap1 f) fa--instance Traversable f => Traversable (Free f) where- traverse f (Pure a) = Pure <$> f a - traverse f (Free fa) = Free <$> traverse (traverse f) fa--instance Traversable1 f => Traversable1 (Free f) where- traverse1 f (Pure a) = Pure <$> f a- traverse1 f (Free fa) = Free <$> traverse1 (traverse1 f) fa--liftF :: Functor f => f a -> Free f a-liftF = Free . fmap Pure--wrap :: f (Free f a) -> Free f a -wrap = Free---- | retract . lift = id--- | retract . liftF = id-retract :: Monad f => Free f a -> f a-retract (Pure a) = return a-retract (Free as) = as >>= retract--iter :: Functor f => (f a -> a) -> Free f a -> a-iter _ (Pure a) = a-iter phi (Free m) = phi (iter phi <$> m)
− Data/Lens/Common.hs
@@ -1,140 +0,0 @@-module Data.Lens.Common- ( Lens(..)- -- * Lens construction- , lens -- build a lens from a getter and setter- , iso -- build a lens from an isomorphism- -- * Functional API- , (^$), (^$!) -- getter -- :: Lens a b -> a -> b- , (^.), (^!) -- getter -- :: a -> Lens a b -> b- , (^=), (^!=) -- setter -- :: Lens a b -> b -> (a -> a)- , (^%=), (^!%=) -- modify -- :: Lens a b -> (b -> b) -> (a -> a) - , (^%%=) -- modify -- :: Functor f => Lens a b -> (b -> f b) -> a -> f a- -- * Pseudo-imperatives- , (^+=), (^!+=) -- addition- , (^-=), (^!-=) -- subtraction- , (^*=), (^!*=) -- multiplication- , (^/=), (^!/=) -- division- -- * Stock lenses- , fstLens- , sndLens- , mapLens- , intMapLens- , setLens- , intSetLens- ) where--import Control.Applicative-import Control.Comonad.Trans.Store-import Control.Category-import Data.Functor.Identity-import Data.Functor.Apply-import Data.Semigroupoid-import Prelude hiding ((.), id)-import Data.IntMap (IntMap)-import qualified Data.Map as Map-import Data.Set (Set)-import qualified Data.IntMap as IntMap-import Data.Map (Map)-import qualified Data.Set as Set-import Data.IntSet (IntSet)-import qualified Data.IntSet as IntSet--newtype Lens a b = Lens { runLens :: a -> Store b a }--instance Semigroupoid Lens where- Lens f `o` Lens g = Lens $ \a -> case g a of- StoreT wba b -> case f b of- StoreT wcb c -> StoreT ((.) <$> wba <.> wcb) c--instance Category Lens where- id = Lens $ StoreT (pure id)- Lens f . Lens g = Lens $ \a -> case g a of- StoreT wba b -> case f b of - StoreT wcb c -> StoreT ((.) <$> wba <*> wcb) c---- * Lens construction---- | build a lens out of a getter and setter-lens :: (a -> b) -> (b -> a -> a) -> Lens a b-lens get set = Lens $ \a -> store (\b -> set b a) (get a)---- | build a lens out of an isomorphism-iso :: (a -> b) -> (b -> a) -> Lens a b-iso f g = Lens (store g . f)--infixr 0 ^$, ^$!---- | functional getter-(^$), (^$!) :: Lens a b -> a -> b-Lens f ^$ a = pos (f a)-Lens f ^$! a = pos (f $! a)--infixr 9 ^., ^!--- | functional getter, which acts like a field accessor-(^.), (^!) :: a -> Lens a b -> b-a ^. Lens f = pos (f a)-a ^! Lens f = pos (f $! a)--infixr 4 ^=, ^!=--- | functional setter-(^=), (^!=) :: Lens a b -> b -> a -> a-Lens f ^= b = peek b . f-Lens f ^!= b = \a -> case f a of- StoreT (Identity g) _ -> g $! b--infixr 4 ^%=, ^!%=--- | functional modify-(^%=), (^!%=) :: Lens a b -> (b -> b) -> a -> a-Lens f ^%= g = peeks g . f-Lens f ^!%= g = \a -> case f a of- StoreT (Identity h) b -> h $! g b--infixr 4 ^%%=--- | functorial modify-(^%%=) :: Functor f => Lens a b -> (b -> f b) -> a -> f a-Lens f ^%%= g = \a -> case f a of- StoreT (Identity h) b -> h <$> g b--infixr 4 ^+=, ^!+=, ^-=, ^!-=, ^*=, ^!*=-(^+=), (^!+=), (^-=), (^!-=), (^*=), (^!*=) :: Num b => Lens a b -> b -> a -> a-l ^+= n = l ^%= (+ n)-l ^-= n = l ^%= subtract n-l ^*= n = l ^%= (* n)-l ^!+= n = l ^!%= (+ n)-l ^!-= n = l ^!%= subtract n-l ^!*= n = l ^!%= (* n)--infixr 4 ^/=, ^!/=-(^/=), (^!/=) :: Fractional b => Lens a b -> b -> a -> a-l ^/= r = l ^%= (/ r)-l ^!/= r = l ^!%= (/ r)---- * Stock lenses--fstLens :: Lens (a,b) a-fstLens = Lens $ \(a,b) -> store (\ a' -> (a', b)) a--sndLens :: Lens (a,b) b-sndLens = Lens $ \(a,b) -> store (\ b' -> (a, b')) b--mapLens :: Ord k => k -> Lens (Map k v) (Maybe v)-mapLens k = Lens $ \m -> store (\mv -> case mv of- Nothing -> Map.delete k m- Just v' -> Map.insert k v' m- ) (Map.lookup k m)--intMapLens :: Int -> Lens (IntMap v) (Maybe v)-intMapLens k = Lens $ \m -> store (\mv -> case mv of- Nothing -> IntMap.delete k m- Just v' -> IntMap.insert k v' m- ) (IntMap.lookup k m)--setLens :: Ord k => k -> Lens (Set k) Bool-setLens k = Lens $ \m -> store (\mv ->- if mv then Set.delete k m else Set.insert k m- ) (Set.member k m)- -intSetLens :: Int -> Lens IntSet Bool-intSetLens k = Lens $ \m -> store (\mv -> - if mv then IntSet.delete k m else IntSet.insert k m- ) (IntSet.member k m)
− Data/Lens/Lazy.hs
@@ -1,90 +0,0 @@-module Data.Lens.Lazy- ( module Data.Lens.Common- -- * State API- , access -- getter -- :: Monad m => Lens a b -> StateT a m b- , (~=), (!=) -- setter -- :: Monad m => Lens a b -> b -> StateT a m b- , (%=), (!%=) -- modify -- :: Monad m => Lens a b -> (b -> b) -> StateT a m b- , (%%=), (!%%=) -- modify -- :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c- , (+=), (!+=) -- modify -- :: (Monad m, Num b) => Lens a b -> b -> StateT a m b- , (-=), (!-=) -- modify -- :: (Monad m, Num b) => Lens a b -> b -> StateT a m b- , (*=), (!*=) -- modify -- :: (Monad m, Num b) => Lens a b -> b -> StateT a m b- , (//=), (!/=) -- modify -- :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b- , (&&=), (!&&=) -- modify -- :: Monad m => Lens a Bool -> Bool -> StateT a m Bool- , (||=), (!||=) -- modify -- :: Monad m => Lens a Bool -> Bool -> StateT a m Bool- , focus -- modify -- :: Monad m => Lens a b -> StateT m b c -> StateT m a c- ) where--import Control.Comonad.Trans.Store-import Control.Monad.Trans.State-import Control.Monad (liftM)-import Data.Functor.Identity-import Data.Lens.Common---- * State actions---- | get the value of a lens into state-access :: Monad m => Lens a b -> StateT a m b-access (Lens f) = gets (pos . f)-{-# INLINE access #-}--focus :: Monad m => Lens a b -> StateT b m c -> StateT a m c-focus (Lens f) (StateT g) = StateT $ \a -> case f a of- StoreT (Identity h) b -> liftM (\(c, b') -> (c, h b')) (g b)--infixr 4 ~=, !=---- | set a value using a lens into state-(~=), (!=) :: Monad m => Lens a b -> b -> StateT a m b-Lens f ~= b = StateT $ \a -> let c = peek b (f a) in - return (b, c)-Lens f != b = StateT $ \a -> case f a of- StoreT (Identity h) _ -> let c = h $! b in- return (b, c)--infixr 4 %=, !%=- --- | infix modification a value through a lens into state-(%=), (!%=) :: Monad m => Lens a b -> (b -> b) -> StateT a m b-Lens f %= g = StateT $ \a -> case f a of - StoreT (Identity h) b -> let b' = g b in- return (b', h b')-Lens f !%= g = StateT $ \a -> case f a of- StoreT (Identity h) b -> let b' = g b in- b' `seq` return (b', h b')--infixr 4 %%=, !%%=---- | infix modification of a value through a lens into state--- with a supplemental response-(%%=), (!%%=) :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c-Lens f %%= g = StateT $ \a -> case f a of- StoreT (Identity h) b -> case g b of- (c, b') -> return (c, h b')-Lens f !%%= g = StateT $ \a -> case f a of- StoreT (Identity h) b -> case g b of- (c, b') -> return (c, h $! b')--infixr 4 +=, !+=, -=, !-=, *=, !*=--(+=), (!+=), (-=), (!-=), (*=), (!*=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b-f += b = f %= (+ b)-f -= b = f %= subtract b-f *= b = f %= (* b)-f !+= b = f !%= (+ b)-f !-= b = f !%= subtract b-f !*= b = f !%= (* b)--infixr 4 //=, !/=--(//=), (!/=) :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b-f //= b = f %= (/ b)-f !/= b = f !%= (/ b)--infixr 4 &&=, !&&=, ||=, !||=--(&&=), (||=), (!&&=), (!||=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool-f &&= b = f %= (&& b)-f ||= b = f %= (|| b)-f !&&= b = f !%= (&& b)-f !||= b = f !%= (|| b)-
− Data/Lens/Strict.hs
@@ -1,90 +0,0 @@-module Data.Lens.Strict- ( module Data.Lens.Common- -- * State API- , access -- getter -- :: Monad m => Lens a b -> StateT a m b- , (~=), (!=) -- setter -- :: Monad m => Lens a b -> b -> StateT a m b- , (%=), (!%=) -- modify -- :: Monad m => Lens a b -> (b -> b) -> StateT a m b- , (%%=), (!%%=) -- modify -- :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c- , (+=), (!+=) -- modify -- :: (Monad m, Num b) => Lens a b -> b -> StateT a m b- , (-=), (!-=) -- modify -- :: (Monad m, Num b) => Lens a b -> b -> StateT a m b- , (*=), (!*=) -- modify -- :: (Monad m, Num b) => Lens a b -> b -> StateT a m b- , (//=), (!/=) -- modify -- :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b- , (&&=), (!&&=) -- modify -- :: Monad m => Lens a Bool -> Bool -> StateT a m Bool- , (||=), (!||=) -- modify -- :: Monad m => Lens a Bool -> Bool -> StateT a m Bool- , focus -- modify -- :: Monad m => Lens a b -> StateT m b c -> StateT m a c- ) where--import Control.Comonad.Trans.Store-import Control.Monad.Trans.State.Strict-import Control.Monad (liftM)-import Data.Functor.Identity-import Data.Lens.Common---- * State actions---- | get the value of a lens into state-access :: Monad m => Lens a b -> StateT a m b-access (Lens f) = gets (pos . f)-{-# INLINE access #-}--focus :: Monad m => Lens a b -> StateT b m c -> StateT a m c-focus (Lens f) (StateT g) = StateT $ \a -> case f a of- StoreT (Identity h) b -> liftM (\(c, b') -> (c, h b')) (g b)--infixr 4 ~=, !=---- | set a value using a lens into state-(~=), (!=) :: Monad m => Lens a b -> b -> StateT a m b-Lens f ~= b = StateT $ \a -> let c = peek b (f a) in - return (b, c)-Lens f != b = StateT $ \a -> case f a of- StoreT (Identity h) _ -> let c = h $! b in- return (b, c)--infixr 4 %=, !%=- --- | infix modification a value through a lens into state-(%=), (!%=) :: Monad m => Lens a b -> (b -> b) -> StateT a m b-Lens f %= g = StateT $ \a -> case f a of - StoreT (Identity h) b -> let b' = g b in- return (b', h b')-Lens f !%= g = StateT $ \a -> case f a of- StoreT (Identity h) b -> let b' = g b in- b' `seq` return (b', h b')--infixr 4 %%=, !%%=---- | infix modification of a value through a lens into state--- with a supplemental response-(%%=), (!%%=) :: Monad m => Lens a b -> (b -> (c, b)) -> StateT a m c-Lens f %%= g = StateT $ \a -> case f a of- StoreT (Identity h) b -> case g b of- (c, b') -> return (c, h b')-Lens f !%%= g = StateT $ \a -> case f a of- StoreT (Identity h) b -> case g b of- (c, b') -> return (c, h $! b')--infixr 4 +=, !+=, -=, !-=, *=, !*=--(+=), (!+=), (-=), (!-=), (*=), (!*=) :: (Monad m, Num b) => Lens a b -> b -> StateT a m b-f += b = f %= (+ b)-f -= b = f %= subtract b-f *= b = f %= (* b)-f !+= b = f !%= (+ b)-f !-= b = f !%= subtract b-f !*= b = f !%= (* b)--infixr 4 //=, !/=--(//=), (!/=) :: (Monad m, Fractional b) => Lens a b -> b -> StateT a m b-f //= b = f %= (/ b)-f !/= b = f !%= (/ b)--infixr 4 &&=, !&&=, ||=, !||=--(&&=), (||=), (!&&=), (!||=) :: Monad m => Lens a Bool -> Bool -> StateT a m Bool-f &&= b = f %= (&& b)-f ||= b = f %= (|| b)-f !&&= b = f !%= (&& b)-f !||= b = f !%= (|| b)-
comonad-transformers.cabal view
@@ -1,6 +1,6 @@ name: comonad-transformers category: Control, Comonads-version: 1.7+version: 1.8.0 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -42,7 +42,6 @@ exposed-modules: Control.Comonad.Hoist.Class Control.Comonad.Trans.Class- Control.Comonad.Trans.Cofree Control.Comonad.Trans.Discont Control.Comonad.Trans.Discont.Lazy Control.Comonad.Trans.Discont.Strict@@ -58,13 +57,7 @@ Control.Comonad.Trans.Traced Control.Comonad.Trans.Traced.Memo - Control.Monad.Trans.Free- Data.Functor.Coproduct Data.Functor.Composition-- Data.Lens.Common- Data.Lens.Lazy- Data.Lens.Strict ghc-options: -Wall