-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Various typeclasses using ConstraintKinds -- -- Please see README.md @package constraint-classes @version 0.5.1 module Control.ConstraintClasses -- | 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. class DomCartesian f domCartesian :: DomCartesian f => (Dom f a, Dom f b) :- Dom f (a, b) class DomCartesian f => DomClosed f domClosed :: DomClosed f => (Dom f a, Dom f b) :- Dom f (a -> b) -- | Equivalent to the Functor class. class CFunctor f _fmap :: (CFunctor f, Dom f a, Dom f b) => (a -> b) -> f a -> f b (<$>:) :: (CFunctor f, Dom f a, Dom f b) => (a -> b) -> f a -> f b infixl 4 <$>: -- | Equivalent to the Applicative class. class CFunctor f => CApply f where _zipA x y = _liftA2 (,) x y \\ domCartesian @f @a @b _zipA :: forall a b. (CApply f, DomCartesian f, Dom f a, Dom f b) => f a -> f b -> f (a, b) _liftA2 :: (CApply f, Dom f a, Dom f b, Dom f c) => (a -> b -> c) -> f a -> f b -> f c _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 _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 _ap :: (CApply f, DomClosed f, Dom f a, Dom f b) => f (a -> b) -> f a -> f b (<*>:) :: (CApply f, DomClosed f, Dom f a, Dom f b) => f (a -> b) -> f a -> f b infixl 4 <*>: class CApply f => CApplicative f _pure :: (CApplicative f, Dom f a) => a -> f a -- | Equivalent to the @Monad$ class. class CApplicative f => CMonad f _concatMap :: (CMonad f, Dom f a, Dom f b) => (a -> f b) -> f a -> f b (>>=:) :: (CMonad f, Dom f a, Dom f b) => f a -> (a -> f b) -> f b infixl 1 >>=: (=<<:) :: (CMonad f, Dom f a, Dom f b) => (a -> f b) -> f a -> f b infixr 1 =<<: -- | Equivalent to the Applicative class. class CApplicative f => CAlt f _concat :: (CAlt f, Dom f a) => f a -> f a -> f a (<|>:) :: (CAlt f, Dom f a) => f a -> f a -> f a infixl 3 <|>: class CAlt f => CAlternative f _empty :: (CAlternative f, Dom f a) => f a -- | Equivalent to the Foldable class. 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_ _foldr :: (CFoldable f, Dom f a) => (a -> b -> b) -> b -> f a -> b _foldr' :: (CFoldable f, Dom f a) => (a -> b -> b) -> b -> f a -> b _foldl :: (CFoldable f, Dom f b) => (a -> b -> a) -> a -> f b -> a _foldl' :: (CFoldable f, Dom f b) => (a -> b -> a) -> a -> f b -> a _fold :: (CFoldable f, Dom f m, Monoid m) => f m -> m _foldMap :: (CFoldable f, Dom f a, Monoid m) => (a -> m) -> f a -> m _toList :: (CFoldable f, Dom f a) => f a -> [a] _length :: (CFoldable f, Dom f a) => f a -> Int _mapM_ :: (CFoldable f, Monad m, Dom f a) => (a -> m b) -> f a -> m () _forM_ :: (CFoldable f, Monad m, Dom f a) => f a -> (a -> m b) -> m () -- | Equivalent to the Traversable class. class (CFunctor t, CFoldable t) => CTraversable t where _sequence = _traverse id _traverse :: (CTraversable t, Dom t a, Dom t b, Monad f) => (a -> f b) -> t a -> f (t b) _sequence :: (CTraversable t, Monad f, Dom t a, Dom t (f a)) => t (f a) -> f (t a) -- | Equivalent to the Key type family. -- | Equivalent to the Lookup class. class CLookup f _lookup :: (CLookup f, Dom f a) => CKey f -> f a -> Maybe a (!?) :: (CLookup f, Dom f a) => CKey f -> f a -> Maybe a -- | Equivalent to the Indexable class. class CLookup f => CIndexable f _index :: (CIndexable f, Dom f a) => f a -> CKey f -> a (!) :: (CIndexable f, Dom f a) => f a -> CKey f -> a -- | Equivalent to the Keyed class. class CFunctor f => CKeyed f _imap :: (CKeyed f, Dom f a, Dom f b) => (CKey f -> a -> b) -> f a -> f b -- | Equivalent to the Zip class. class CFunctor f => CZip f _zip :: (CZip f, DomCartesian f, Dom f a, Dom f b) => f a -> f b -> f (a, b) _zipWith :: (CZip f, Dom f a, Dom f b, Dom f c) => (a -> b -> c) -> f a -> f b -> f c _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 _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 _zipAp :: (CZip f, DomClosed f, Dom f a, Dom f b) => f (a -> b) -> f a -> f b -- | Equivalent to the Zip class. class (CKeyed f, CZip f) => CZipWithKey f _izipWith :: (CZipWithKey f, Dom f a, Dom f b, Dom f c) => (CKey f -> a -> b -> c) -> f a -> f b -> f c _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 _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 -- | Equivalent to the FoldableWithKey class. class CFoldable f => CFoldableWithKey f _itoList :: (CFoldableWithKey f, Dom f a) => f a -> [(CKey f, a)] _ifoldMap :: (CFoldableWithKey f, Monoid m, Dom f a) => (CKey f -> a -> m) -> f a -> m _ifoldr :: (CFoldableWithKey f, Dom f a) => (CKey f -> a -> b -> b) -> b -> f a -> b _ifoldr' :: (CFoldableWithKey f, Dom f a) => (CKey f -> a -> b -> b) -> b -> f a -> b _ifoldl :: (CFoldableWithKey f, Dom f b) => (a -> CKey f -> b -> a) -> a -> f b -> a _ifoldl' :: (CFoldableWithKey f, Dom f b) => (a -> CKey f -> b -> a) -> a -> f b -> a -- | Equivalent to the Traversable class. class (CKeyed t, CFoldableWithKey t, CTraversable t) => CTraversableWithKey t _itraverse :: (CTraversableWithKey t, Dom t a, Dom t b, Monad f) => (CKey t -> a -> f b) -> t a -> f (t b) -- | Equivalent to the Adjustable class. class CFunctor f => CAdjustable f where _adjust f n v = _update (\ a _ -> f a) v [(n, ())] _replace n x = _adjust (const x) n _update :: (CAdjustable f, Dom f a) => (a -> b -> a) -> f a -> [(CKey f, b)] -> f a _adjust :: (CAdjustable f, Dom f a) => (a -> a) -> CKey f -> f a -> f a _replace :: (CAdjustable f, Dom f a) => CKey f -> a -> f a -> f a instance Control.ConstraintClasses.Any instance Control.ConstraintClasses.CFunctor (Data.Functor.Constant.Constant a) instance Control.ConstraintClasses.CFunctor Data.Functor.Identity.Identity instance (Control.ConstraintClasses.CFunctor f, Control.ConstraintClasses.CFunctor g) => Control.ConstraintClasses.CFunctor (Data.Functor.Product.Product f g) instance (Control.ConstraintClasses.CFunctor f, Control.ConstraintClasses.CFunctor g) => Control.ConstraintClasses.CFunctor (Data.Functor.Sum.Sum f g) instance (Control.ConstraintClasses.CFunctor f, Control.ConstraintClasses.CFunctor g) => Control.ConstraintClasses.CFunctor (Data.Functor.Compose.Compose f g)