constraint-classes 0.4.0 → 0.5
raw patch · 2 files changed
+250/−49 lines, 2 filesdep +constraintsdep +transformersPVP ok
version bump matches the API change (PVP)
Dependencies added: constraints, transformers
API changes (from Hackage documentation)
- Control.ConstraintClasses: _forM :: (CFoldable f, Monad m, Con f a, Con f b) => f a -> (a -> m b) -> m (f b)
- Control.ConstraintClasses: _mapM :: (CFoldable f, Monad m, Con f a, Con f b) => (a -> m b) -> f a -> m (f b)
- Control.ConstraintClasses: class CFunctor f => CIndexed f i | f -> i
- Control.ConstraintClasses: class CFunctor f => CZippable f
- Control.ConstraintClasses: type Con f a = ();
- Control.ConstraintClasses: type family Con f a :: Constraint;
- Control.ConstraintClasses: }
+ Control.ConstraintClasses: (!?) :: (CLookup f, Dom f a) => CKey f -> f a -> Maybe a
+ Control.ConstraintClasses: (<$>:) :: (CFunctor f, Dom f a, Dom f b) => (a -> b) -> f a -> f b
+ Control.ConstraintClasses: (<*>:) :: (CApply f, DomClosed f, Dom f a, Dom f b) => f (a -> b) -> f a -> f b
+ Control.ConstraintClasses: (<|>:) :: (CAlt f, Dom f a) => f a -> f a -> f a
+ Control.ConstraintClasses: (=<<:) :: (CMonad f, Dom f a, Dom f b) => (a -> f b) -> f a -> f b
+ Control.ConstraintClasses: (>>=:) :: (CMonad f, Dom f a, Dom f b) => f a -> (a -> f b) -> f b
+ Control.ConstraintClasses: _adjust :: (CAdjustable f, Dom f a) => (a -> a) -> CKey f -> f a -> f a
+ Control.ConstraintClasses: _ap :: (CApply f, DomClosed f, Dom f a, Dom f b) => f (a -> b) -> f a -> f b
+ Control.ConstraintClasses: _concat :: (CAlt f, Dom f a) => f a -> f a -> f a
+ Control.ConstraintClasses: _empty :: (CAlternative f, Dom f a) => f a
+ Control.ConstraintClasses: _ifoldMap :: (CFoldableWithKey f, Monoid m, Dom f a) => (CKey f -> a -> m) -> f a -> m
+ Control.ConstraintClasses: _ifoldl :: (CFoldableWithKey f, Dom f b) => (a -> CKey f -> b -> a) -> a -> f b -> a
+ Control.ConstraintClasses: _ifoldl' :: (CFoldableWithKey f, Dom f b) => (a -> CKey f -> b -> a) -> a -> f b -> a
+ Control.ConstraintClasses: _ifoldr :: (CFoldableWithKey f, Dom f a) => (CKey f -> a -> b -> b) -> b -> f a -> b
+ Control.ConstraintClasses: _ifoldr' :: (CFoldableWithKey f, Dom f a) => (CKey f -> a -> b -> b) -> b -> f a -> b
+ Control.ConstraintClasses: _imap :: (CKeyed f, Dom f a, Dom f b) => (CKey f -> a -> b) -> f a -> f b
+ Control.ConstraintClasses: _index :: (CIndexable f, Dom f a) => f a -> CKey f -> a
+ Control.ConstraintClasses: _itoList :: (CFoldableWithKey f, Dom f a) => f a -> [(CKey f, a)]
+ Control.ConstraintClasses: _itraverse :: (CTraversableWithKey t, Dom t a, Dom t b, Monad f) => (CKey t -> a -> f b) -> t a -> f (t b)
+ Control.ConstraintClasses: _izipWith :: (CZipWithKey f, Dom f a, Dom f b, Dom f c) => (CKey f -> a -> b -> c) -> f a -> f b -> f c
+ Control.ConstraintClasses: _izipWith3 :: (CZipWithKey f, Dom f a, Dom f b, Dom f c, Dom f d) => (CKey f -> a -> b -> c -> d) -> f a -> f b -> f c -> f d
+ Control.ConstraintClasses: _izipWith4 :: (CZipWithKey f, Dom f a, Dom f b, Dom f c, Dom f d, Dom f e) => (CKey f -> a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
+ Control.ConstraintClasses: _lookup :: (CLookup f, Dom f a) => CKey f -> f a -> Maybe a
+ Control.ConstraintClasses: _replace :: (CAdjustable f, Dom f a) => CKey f -> a -> f a -> f a
+ Control.ConstraintClasses: _sequence :: (CTraversable t, Monad f, Dom t a, Dom t (f a)) => t (f a) -> f (t a)
+ Control.ConstraintClasses: _toList :: (CFoldable f, Dom f a) => f a -> [a]
+ Control.ConstraintClasses: _update :: (CAdjustable f, Dom f a) => (a -> b -> a) -> f a -> [(CKey f, b)] -> f a
+ Control.ConstraintClasses: _zip :: (CZip f, DomCartesian f, Dom f a, Dom f b) => f a -> f b -> f (a, b)
+ Control.ConstraintClasses: _zipA :: forall a b. (CApply f, DomCartesian f, Dom f a, Dom f b) => f a -> f b -> f (a, b)
+ Control.ConstraintClasses: _zipAp :: (CZip f, DomClosed f, Dom f a, Dom f b) => f (a -> b) -> f a -> f b
+ Control.ConstraintClasses: class CFunctor f => CAdjustable f where _adjust f n v = _update (\ a _ -> f a) v [(n, ())] _replace n x = _adjust (const x) n
+ Control.ConstraintClasses: class CApplicative f => CAlt f
+ Control.ConstraintClasses: class CAlt f => CAlternative f
+ Control.ConstraintClasses: class CFunctor f => CApply f where _zipA x y = _liftA2 (,) x y \\ domCartesian @f @a @b
+ Control.ConstraintClasses: class CFoldable f => CFoldableWithKey f
+ Control.ConstraintClasses: class CLookup f => CIndexable f
+ Control.ConstraintClasses: class CFunctor f => CKeyed f
+ Control.ConstraintClasses: class CLookup f
+ Control.ConstraintClasses: class (CKeyed t, CFoldableWithKey t, CTraversable t) => CTraversableWithKey t
+ Control.ConstraintClasses: class CFunctor f => CZip f
+ Control.ConstraintClasses: class (CKeyed f, CZip f) => CZipWithKey f
+ Control.ConstraintClasses: infixl 1 >>=:
+ Control.ConstraintClasses: infixl 3 <|>:
+ Control.ConstraintClasses: infixl 4 <*>:
+ Control.ConstraintClasses: infixr 1 =<<:
+ Control.ConstraintClasses: instance (Control.ConstraintClasses.CFunctor f, Control.ConstraintClasses.CFunctor g) => Control.ConstraintClasses.CFunctor (Data.Functor.Compose.Compose f g)
+ Control.ConstraintClasses: instance (Control.ConstraintClasses.CFunctor f, Control.ConstraintClasses.CFunctor g) => Control.ConstraintClasses.CFunctor (Data.Functor.Product.Product f g)
+ Control.ConstraintClasses: instance (Control.ConstraintClasses.CFunctor f, Control.ConstraintClasses.CFunctor g) => Control.ConstraintClasses.CFunctor (Data.Functor.Sum.Sum f g)
+ Control.ConstraintClasses: instance Control.ConstraintClasses.Any
+ Control.ConstraintClasses: instance Control.ConstraintClasses.CFunctor (Data.Functor.Constant.Constant a)
+ Control.ConstraintClasses: instance Control.ConstraintClasses.CFunctor Data.Functor.Identity.Identity
- Control.ConstraintClasses: (!) :: (CIndexed f i, Con f a) => f a -> i -> a
+ Control.ConstraintClasses: (!) :: (CIndexable f, Dom f a) => f a -> CKey f -> a
- Control.ConstraintClasses: _concatMap :: (CMonad f, Con f a, Con f b) => (a -> f b) -> f a -> f b
+ Control.ConstraintClasses: _concatMap :: (CMonad f, Dom f a, Dom f b) => (a -> f b) -> f a -> f b
- Control.ConstraintClasses: _fmap :: (CFunctor f, Con f a, Con f b) => (a -> b) -> f a -> f b
+ Control.ConstraintClasses: _fmap :: (CFunctor f, Dom f a, Dom f b) => (a -> b) -> f a -> f b
- Control.ConstraintClasses: _fold :: (CFoldable f, Con f m, Monoid m) => f m -> m
+ Control.ConstraintClasses: _fold :: (CFoldable f, Dom f m, Monoid m) => f m -> m
- Control.ConstraintClasses: _foldMap :: (CFoldable f, Con f a, Con f m, Monoid m) => (a -> m) -> f a -> m
+ Control.ConstraintClasses: _foldMap :: (CFoldable f, Dom f a, Monoid m) => (a -> m) -> f a -> m
- Control.ConstraintClasses: _foldl :: (CFoldable f, Con f b) => (a -> b -> a) -> a -> f b -> a
+ Control.ConstraintClasses: _foldl :: (CFoldable f, Dom f b) => (a -> b -> a) -> a -> f b -> a
- Control.ConstraintClasses: _foldl' :: (CFoldable f, Con f b) => (a -> b -> a) -> a -> f b -> a
+ Control.ConstraintClasses: _foldl' :: (CFoldable f, Dom f b) => (a -> b -> a) -> a -> f b -> a
- Control.ConstraintClasses: _foldr :: (CFoldable f, Con f a) => (a -> b -> b) -> b -> f a -> b
+ Control.ConstraintClasses: _foldr :: (CFoldable f, Dom f a) => (a -> b -> b) -> b -> f a -> b
- Control.ConstraintClasses: _foldr' :: (CFoldable f, Con f a) => (a -> b -> b) -> b -> f a -> b
+ Control.ConstraintClasses: _foldr' :: (CFoldable f, Dom f a) => (a -> b -> b) -> b -> f a -> b
- Control.ConstraintClasses: _forM_ :: (CFoldable f, Monad m, Con f a) => f a -> (a -> m b) -> m ()
+ Control.ConstraintClasses: _forM_ :: (CFoldable f, Monad m, Dom f a) => f a -> (a -> m b) -> m ()
- Control.ConstraintClasses: _length :: (CFoldable f, Con f a) => f a -> Int
+ Control.ConstraintClasses: _length :: (CFoldable f, Dom f a) => f a -> Int
- Control.ConstraintClasses: _liftA2 :: (CApplicative f, Con f a, Con f b, Con f c) => (a -> b -> c) -> f a -> f b -> f c
+ Control.ConstraintClasses: _liftA2 :: (CApply f, Dom f a, Dom f b, Dom f c) => (a -> b -> c) -> f a -> f b -> f c
- Control.ConstraintClasses: _liftA3 :: (CApplicative f, Con f a, Con f b, Con f c, Con f d) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
+ Control.ConstraintClasses: _liftA3 :: (CApply f, Dom f a, Dom f b, Dom f c, Dom f d) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- Control.ConstraintClasses: _liftA4 :: (CApplicative f, Con f a, Con f b, Con f c, Con f d, Con f e) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
+ Control.ConstraintClasses: _liftA4 :: (CApply f, Dom f a, Dom f b, Dom f c, Dom f d, Dom f e) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
- Control.ConstraintClasses: _mapM_ :: (CFoldable f, Monad m, Con f a) => (a -> m b) -> f a -> m ()
+ Control.ConstraintClasses: _mapM_ :: (CFoldable f, Monad m, Dom f a) => (a -> m b) -> f a -> m ()
- Control.ConstraintClasses: _pure :: (CApplicative f, Con f a) => a -> f a
+ Control.ConstraintClasses: _pure :: (CApplicative f, Dom f a) => a -> f a
- Control.ConstraintClasses: _traverse :: (CTraversable t, Con t a, Con t b, Monad f) => (a -> f b) -> t a -> f (t b)
+ Control.ConstraintClasses: _traverse :: (CTraversable t, Dom t a, Dom t b, Monad f) => (a -> f b) -> t a -> f (t b)
- Control.ConstraintClasses: _zipWith :: (CZippable f, Con f a, Con f b, Con f c) => (a -> b -> c) -> f a -> f b -> f c
+ Control.ConstraintClasses: _zipWith :: (CZip f, Dom f a, Dom f b, Dom f c) => (a -> b -> c) -> f a -> f b -> f c
- Control.ConstraintClasses: _zipWith3 :: (CZippable f, Con f a, Con f b, Con f c, Con f d) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
+ Control.ConstraintClasses: _zipWith3 :: (CZip f, Dom f a, Dom f b, Dom f c, Dom f d) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- Control.ConstraintClasses: _zipWith4 :: (CZippable f, Con f a, Con f b, Con f c, Con f d, Con f e) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
+ Control.ConstraintClasses: _zipWith4 :: (CZip f, Dom f a, Dom f b, Dom f c, Dom f d, Dom f e) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e
- Control.ConstraintClasses: class CFunctor f => CApplicative f
+ Control.ConstraintClasses: class CApply f => CApplicative f
- Control.ConstraintClasses: class CFoldable f where _fold = _foldMap id _foldMap f = _foldr (mappend . f) mempty _length = _foldl (\ c _ -> c + 1) 0 _forM = flip _mapM _forM_ = flip _mapM_
+ Control.ConstraintClasses: class CFoldable f where _fold = _foldMap id _foldMap f = _foldr (mappend . f) mempty _toList = _foldr (:) [] _length = _foldl (\ c _ -> c + 1) 0 _mapM_ f = _foldr ((>>) . f) (return ()) _forM_ = flip _mapM_
- Control.ConstraintClasses: class CFunctor f where type Con f a :: Constraint type Con f a = () where {
+ Control.ConstraintClasses: class CFunctor f
- Control.ConstraintClasses: class (CFunctor t, CFoldable t) => CTraversable t
+ Control.ConstraintClasses: class (CFunctor t, CFoldable t) => CTraversable t where _sequence = _traverse id
Files
- constraint-classes.cabal +5/−3
- src/Control/ConstraintClasses.hs +245/−46
constraint-classes.cabal view
@@ -1,9 +1,9 @@ name: constraint-classes version:- 0.4.0+ 0.5 synopsis:- Prelude classes using ConstraintKinds+ Various typeclasses using ConstraintKinds description: Please see README.md homepage:@@ -29,7 +29,9 @@ exposed-modules: Control.ConstraintClasses build-depends:- base >= 4.7 && < 5+ base >= 4.7 && < 5,+ constraints,+ transformers default-language: Haskell2010
src/Control/ConstraintClasses.hs view
@@ -2,113 +2,312 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-} module Control.ConstraintClasses- ( CFunctor (..)+ (+ -- * Constraint+ Dom (..)+ -- * Base classes+ , CFunctor (..)+ , (<$>:)+ , CApply (..)+ , (<*>:) , CApplicative (..) , CMonad (..)+ , (>>=:)+ , (=<<:)+ , CAlt (..)+ , (<|>:)+ , CAlternative (..) , CFoldable (..) , CTraversable (..)- , CZippable (..)- , CIndexed (..)+ -- * Key classes+ , CKey (..)+ , CLookup (..)+ , (!?)+ , CIndexable (..)+ , (!)+ , CKeyed (..)+ , CZip (..)+ , CZipWithKey (..)+ , CFoldableWithKey (..)+ , CTraversableWithKey (..)+ , CAdjustable (..) ) where import GHC.Exts (Constraint)+import Data.Constraint+import Data.Functor.Constant+import Data.Functor.Identity+import Data.Functor.Product+import Data.Functor.Sum+import Data.Functor.Compose -----------------------------------------------------------------------+-------------------------------------------------------------------------------- +-- | The 'Dom' type family gives the domain of a given type constructor of kind+-- @* -> *@. This is meant to represent that @f@ is a function from a subset of+-- the the objects in @Hask@ to the objects of @Hask@.+type family Dom (f :: * -> *) a :: Constraint++class Any+instance Any++-- Data.Functor+type instance Dom Identity a = Any+type instance Dom (Product f g) a = (Dom f a, Dom g a)+type instance Dom (Sum f g) a = (Dom f a, Dom g a)+type instance Dom (Compose f g) a = (Dom g a, Dom f (g a))++-- transformers+type instance Dom (Constant a) b = Any++--------------------------------------------------------------------------------++class DomCartesian f where+ domCartesian :: (Dom f a, Dom f b) :- Dom f (a,b)++class DomCartesian f => DomClosed f where+ domClosed :: (Dom f a, Dom f b) :- Dom f (a -> b)++--------------------------------------------------------------------------------++-- | Equivalent to the @Functor@ class. class CFunctor f where- type Con f a :: Constraint- type Con f a = ()+ _fmap :: (Dom f a, Dom f b) => (a -> b) -> f a -> f b - _fmap :: (Con f a, Con f b) => (a -> b) -> f a -> f b+infixl 4 <$>:+(<$>:) :: (CFunctor f, Dom f a, Dom f b) => (a -> b) -> f a -> f b+(<$>:) = _fmap -----------------------------------------------------------------------+instance CFunctor (Constant a) where+ _fmap = fmap -class CFunctor f => CApplicative f where+instance CFunctor Identity where+ _fmap = fmap - _pure :: (Con f a) => a -> f a+instance (CFunctor f, CFunctor g) => CFunctor (Product f g) where+ _fmap f (Pair l r) = Pair (_fmap f l) (_fmap f r) +instance (CFunctor f, CFunctor g) => CFunctor (Sum f g) where+ _fmap f (InL x) = InL (_fmap f x)+ _fmap f (InR x) = InR (_fmap f x)++instance (CFunctor f, CFunctor g) => CFunctor (Compose f g) where+ _fmap f (Compose x) = Compose (_fmap (_fmap f) x)++--------------------------------------------------------------------------------++-- | Equivalent to the @Applicative@ class.+class CFunctor f => CApply f where+ _zipA ::+ forall a b.+ (DomCartesian f, Dom f a, Dom f b) =>+ f a -> f b -> f (a, b)+ _zipA x y = _liftA2 (,) x y \\ domCartesian @f @a @b+ _liftA2 ::- (Con f a, Con f b, Con f c) =>+ (Dom f a, Dom f b, Dom f c) => (a -> b -> c) -> f a -> f b -> f c _liftA3 ::- (Con f a, Con f b, Con f c, Con f d) =>+ (Dom f a, Dom f b, Dom f c, Dom f d) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d _liftA4 ::- (Con f a, Con f b, Con f c, Con f d, Con f e) =>+ (Dom f a, Dom f b, Dom f c, Dom f d, Dom f e) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e -----------------------------------------------------------------------+ _ap ::+ (DomClosed f, Dom f a, Dom f b) =>+ f (a -> b) -> f a -> f b -class CApplicative f => CMonad f where+infixl 4 <*>:+(<*>:) :: (CApply f, DomClosed f, Dom f a, Dom f b) => f (a -> b) -> f a -> f b+(<*>:) = _ap +class CApply f => CApplicative f where+ _pure :: Dom f a => a -> f a++--------------------------------------------------------------------------------++-- | Equivalent to the @Monad$ class.+class CApplicative f => CMonad f where _concatMap ::- (Con f a, Con f b) =>+ (Dom f a, Dom f b) => (a -> f b) -> f a -> f b -----------------------------------------------------------------------+infixl 1 >>=:+(>>=:) :: (CMonad f, Dom f a, Dom f b) => f a -> (a -> f b) -> f b+(>>=:) = flip _concatMap +infixr 1 =<<:+(=<<:) :: (CMonad f, Dom f a, Dom f b) => (a -> f b) -> f a -> f b+(=<<:) = _concatMap++--------------------------------------------------------------------------------++-- | Equivalent to the @Applicative@ class.+class CApplicative f => CAlt f where+ _concat :: Dom f a => f a -> f a -> f a++infixl 3 <|>:+(<|>:) :: (CAlt f, Dom f a) => f a -> f a -> f a+(<|>:) = _concat++class CAlt f => CAlternative f where+ _empty :: Dom f a => f a++--------------------------------------------------------------------------------++-- | Equivalent to the @Foldable@ class. class CFoldable f where {-# MINIMAL _foldMap | _foldr #-} - _foldr :: (Con f a) => (a -> b -> b) -> b -> f a -> b- _foldr' :: (Con f a) => (a -> b -> b) -> b -> f a -> b- _foldl :: (Con f b) => (a -> b -> a) -> a -> f b -> a- _foldl' :: (Con f b) => (a -> b -> a) -> a -> f b -> a+ _foldr :: Dom f a => (a -> b -> b) -> b -> f a -> b+ _foldr' :: Dom f a => (a -> b -> b) -> b -> f a -> b+ _foldl :: Dom f b => (a -> b -> a) -> a -> f b -> a+ _foldl' :: Dom f b => (a -> b -> a) -> a -> f b -> a - _fold :: (Con f m, Monoid m) => f m -> m+ _fold :: (Dom f m, Monoid m) => f m -> m _fold = _foldMap id - _foldMap :: (Con f a, Con f m, Monoid m) => (a -> m) -> f a -> m+ _foldMap :: (Dom f a, Monoid m) => (a -> m) -> f a -> m _foldMap f = _foldr (mappend . f) mempty {-# INLINE _foldMap #-} - _length :: Con f a => f a -> Int- _length = _foldl (\c _ -> c+1) 0-- _mapM :: (Monad m, Con f a, Con f b)- => (a -> m b) -> f a -> m (f b)+ _toList :: Dom f a => f a -> [a]+ _toList = _foldr (:) [] - _forM :: (Monad m, Con f a, Con f b)- => f a -> (a -> m b) -> m (f b)- _forM = flip _mapM+ _length :: Dom f a => f a -> Int+ _length = _foldl (\c _ -> c+1) 0 - _mapM_ :: (Monad m, Con f a)- => (a -> m b) -> f a -> m ()+ _mapM_ ::+ (Monad m, Dom f a) =>+ (a -> m b) -> f a -> m ()+ _mapM_ f = _foldr ((>>) . f) (return ()) - _forM_ :: (Monad m, Con f a)- => f a -> (a -> m b) -> m ()+ _forM_ ::+ (Monad m, Dom f a) =>+ f a -> (a -> m b) -> m () _forM_ = flip _mapM_ -----------------------------------------------------------------------+-------------------------------------------------------------------------------- +-- | Equivalent to the @Traversable@ class. class (CFunctor t, CFoldable t) => CTraversable t where- _traverse ::- (Con t a, Con t b, Monad f) =>+ (Dom t a, Dom t b, Monad f) => (a -> f b) -> t a -> f (t b) -----------------------------------------------------------------------+ _sequence ::+ (Monad f, Dom t a, Dom t (f a)) =>+ t (f a) -> f (t a)+ _sequence = _traverse id -class CFunctor f => CZippable f where+-------------------------------------------------------------------------------- +-- | Equivalent to the @Zip@ class.+class CFunctor f => CZip f where+ _zip ::+ (DomCartesian f, Dom f a, Dom f b) =>+ f a -> f b -> f (a, b)+ _zipWith ::- (Con f a, Con f b, Con f c) =>+ (Dom f a, Dom f b, Dom f c) => (a -> b -> c) -> f a -> f b -> f c _zipWith3 ::- (Con f a, Con f b, Con f c, Con f d) =>+ (Dom f a, Dom f b, Dom f c, Dom f d) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d _zipWith4 ::- (Con f a, Con f b, Con f c, Con f d, Con f e) =>+ (Dom f a, Dom f b, Dom f c, Dom f d, Dom f e) => (a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e -----------------------------------------------------------------------+ _zipAp ::+ (DomClosed f, Dom f a, Dom f b) =>+ f (a -> b) -> f a -> f b -class CFunctor f => CIndexed f i | f -> i where+-------------------------------------------------------------------------------- - (!) :: (Con f a) => f a -> i -> a+-- | Equivalent to the @Key@ type family.+type family CKey (f :: * -> *)++--------------------------------------------------------------------------------++-- | Equivalent to the @Lookup@ class.+class CLookup f where+ _lookup :: Dom f a => CKey f -> f a -> Maybe a++(!?) :: (CLookup f, Dom f a) => CKey f -> f a -> Maybe a+(!?) = _lookup++--------------------------------------------------------------------------------++-- | Equivalent to the @Indexable@ class.+class CLookup f => CIndexable f where+ _index :: Dom f a => f a -> CKey f -> a++(!) :: (CIndexable f, Dom f a) => f a -> CKey f -> a+(!) = _index++--------------------------------------------------------------------------------++-- | Equivalent to the @Keyed@ class.+class CFunctor f => CKeyed f where+ _imap ::+ (Dom f a, Dom f b) =>+ (CKey f -> a -> b) -> f a -> f b++--------------------------------------------------------------------------------++-- | Equivalent to the @Zip@ class.+class (CKeyed f, CZip f) => CZipWithKey f where+ _izipWith ::+ (Dom f a, Dom f b, Dom f c) =>+ (CKey f -> a -> b -> c) -> f a -> f b -> f c++ _izipWith3 ::+ (Dom f a, Dom f b, Dom f c, Dom f d) =>+ (CKey f -> a -> b -> c -> d) -> f a -> f b -> f c -> f d++ _izipWith4 ::+ (Dom f a, Dom f b, Dom f c, Dom f d, Dom f e) =>+ (CKey f -> a -> b -> c -> d -> e) -> f a -> f b -> f c -> f d -> f e++--------------------------------------------------------------------------------++-- | Equivalent to the @FoldableWithKey@ class.+class CFoldable f => CFoldableWithKey f where+ _itoList :: Dom f a => f a -> [(CKey f, a)]+ _ifoldMap :: (Monoid m, Dom f a) => (CKey f -> a -> m) -> f a -> m+ _ifoldr :: Dom f a => (CKey f -> a -> b -> b) -> b -> f a -> b+ _ifoldr' :: Dom f a => (CKey f -> a -> b -> b) -> b -> f a -> b+ _ifoldl :: Dom f b => (a -> CKey f -> b -> a) -> a -> f b -> a+ _ifoldl' :: Dom f b => (a -> CKey f -> b -> a) -> a -> f b -> a++--------------------------------------------------------------------------------++-- | Equivalent to the @Adjustable@ class.+class CFunctor f => CAdjustable f where+ _update :: Dom f a => (a -> b -> a) -> f a -> [(CKey f, b)] -> f a+ _adjust :: Dom f a => (a -> a) -> CKey f -> f a -> f a+ _adjust f n v = _update (\a _ -> f a) v [(n,())]+ _replace :: Dom f a => CKey f -> a -> f a -> f a+ _replace n x = _adjust (const x) n++--------------------------------------------------------------------------------++-- | Equivalent to the @Traversable@ class.+class (CKeyed t, CFoldableWithKey t, CTraversable t) =>+ CTraversableWithKey t where+ _itraverse ::+ (Dom t a, Dom t b, Monad f) =>+ (CKey t -> a -> f b) -> t a -> f (t b)