constrained-categories-0.4.2.0: Constrained clones of the category-theory type classes, using ConstraintKinds.
Copyright(c) 2014 Justus Sagemüller
LicenseGPL v3 (see COPYING)
Maintainer(@) jsag $ hvl.no
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Functor.Constrained

Description

 
Synopsis

Functors

class (Category r, Category t) => Functor (f :: Type -> Type) (r :: Type -> Type -> Type) (t :: Type -> Type -> Type) | f r -> t, f t -> r where Source #

Methods

fmap :: (Object r a, Object t (f a), Object r b, Object t (f b)) => r a b -> t (f a) (f b) Source #

Instances

Instances details
Functor Complex (Discrete :: Type -> Type -> Type) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Discrete :: Type -> Type -> Type) a, Object (Discrete :: Type -> Type -> Type) (Complex a), Object (Discrete :: Type -> Type -> Type) b, Object (Discrete :: Type -> Type -> Type) (Complex b)) => Discrete a b -> Discrete (Complex a) (Complex b) Source #

Functor Complex (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Coercion :: Type -> Type -> Type) a, Object (Coercion :: Type -> Type -> Type) (Complex a), Object (Coercion :: Type -> Type -> Type) b, Object (Coercion :: Type -> Type -> Type) (Complex b)) => Coercion a b -> Coercion (Complex a) (Complex b) Source #

Functor IO (Discrete :: Type -> Type -> Type) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Discrete :: Type -> Type -> Type) a, Object (Discrete :: Type -> Type -> Type) (IO a), Object (Discrete :: Type -> Type -> Type) b, Object (Discrete :: Type -> Type -> Type) (IO b)) => Discrete a b -> Discrete (IO a) (IO b) Source #

Functor IO (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Coercion :: Type -> Type -> Type) a, Object (Coercion :: Type -> Type -> Type) (IO a), Object (Coercion :: Type -> Type -> Type) b, Object (Coercion :: Type -> Type -> Type) (IO b)) => Coercion a b -> Coercion (IO a) (IO b) Source #

Functor Maybe (Discrete :: Type -> Type -> Type) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Discrete :: Type -> Type -> Type) a, Object (Discrete :: Type -> Type -> Type) (Maybe a), Object (Discrete :: Type -> Type -> Type) b, Object (Discrete :: Type -> Type -> Type) (Maybe b)) => Discrete a b -> Discrete (Maybe a) (Maybe b) Source #

Functor Maybe (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Coercion :: Type -> Type -> Type) a, Object (Coercion :: Type -> Type -> Type) (Maybe a), Object (Coercion :: Type -> Type -> Type) b, Object (Coercion :: Type -> Type -> Type) (Maybe b)) => Coercion a b -> Coercion (Maybe a) (Maybe b) Source #

Functor [] (Discrete :: Type -> Type -> Type) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Discrete :: Type -> Type -> Type) a, Object (Discrete :: Type -> Type -> Type) [a], Object (Discrete :: Type -> Type -> Type) b, Object (Discrete :: Type -> Type -> Type) [b]) => Discrete a b -> Discrete [a] [b] Source #

Functor [] (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Coercion :: Type -> Type -> Type) a, Object (Coercion :: Type -> Type -> Type) [a], Object (Coercion :: Type -> Type -> Type) b, Object (Coercion :: Type -> Type -> Type) [b]) => Coercion a b -> Coercion [a] [b] Source #

Functor [] k k => Functor [] (o k) (o k) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (o k) a, Object (o k) [a], Object (o k) b, Object (o k) [b]) => (o k) a b -> (o k) [a] [b] Source #

Functor f => Functor f (->) (->) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (->) a, Object (->) (f a), Object (->) b, Object (->) (f b)) => (a -> b) -> f a -> f b Source #

Functor (Either a) (Discrete :: Type -> Type -> Type) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Discrete :: Type -> Type -> Type) a0, Object (Discrete :: Type -> Type -> Type) (Either a a0), Object (Discrete :: Type -> Type -> Type) b, Object (Discrete :: Type -> Type -> Type) (Either a b)) => Discrete a0 b -> Discrete (Either a a0) (Either a b) Source #

Functor (Either a) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Coercion :: Type -> Type -> Type) a0, Object (Coercion :: Type -> Type -> Type) (Either a a0), Object (Coercion :: Type -> Type -> Type) b, Object (Coercion :: Type -> Type -> Type) (Either a b)) => Coercion a0 b -> Coercion (Either a a0) (Either a b) Source #

Functor ((,) a) (Discrete :: Type -> Type -> Type) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Discrete :: Type -> Type -> Type) a0, Object (Discrete :: Type -> Type -> Type) (a, a0), Object (Discrete :: Type -> Type -> Type) b, Object (Discrete :: Type -> Type -> Type) (a, b)) => Discrete a0 b -> Discrete (a, a0) (a, b) Source #

Functor ((,) a) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Coercion :: Type -> Type -> Type) a0, Object (Coercion :: Type -> Type -> Type) (a, a0), Object (Coercion :: Type -> Type -> Type) b, Object (Coercion :: Type -> Type -> Type) (a, b)) => Coercion a0 b -> Coercion (a, a0) (a, b) Source #

Functor ((->) a) (Discrete :: Type -> Type -> Type) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Discrete :: Type -> Type -> Type) a0, Object (Discrete :: Type -> Type -> Type) (a -> a0), Object (Discrete :: Type -> Type -> Type) b, Object (Discrete :: Type -> Type -> Type) (a -> b)) => Discrete a0 b -> Discrete (a -> a0) (a -> b) Source #

Functor ((->) a) (Coercion :: Type -> Type -> Type) (Coercion :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (Coercion :: Type -> Type -> Type) a0, Object (Coercion :: Type -> Type -> Type) (a -> a0), Object (Coercion :: Type -> Type -> Type) b, Object (Coercion :: Type -> Type -> Type) (a -> b)) => Coercion a0 b -> Coercion (a -> a0) (a -> b) Source #

(<$>) :: (Functor f r (->), Object r a, Object r b) => r a b -> f a -> f b infixl 4 Source #

constrainedFmap :: forall r t (o :: Type -> Constraint) a b f. (Category r, Category t, o a, o b, o (f a), o (f b)) => (r a b -> t (f a) (f b)) -> (o r) a b -> (o t) (f a) (f b) Source #

[Co]product mapping

class (CoCartesian r, Cartesian t, Functor f r t, Object t (f (ZeroObject r))) => SumToProduct (f :: Type -> Type) (r :: Type -> Type -> Type) (t :: Type -> Type -> Type) where Source #

It is fairly common for functors (typically, container-like) to map Either to tuples in a natural way, thus "separating the variants". This is related to Foldable (with list and tuple monoids), but rather more effective.

Methods

sum2product :: (ObjectSum r a b, ObjectPair t (f a) (f b)) => t (f (a + b)) (f a, f b) Source #

  sum2product ≡ mapEither id
  

mapEither :: (Object r a, ObjectSum r b c, Object t (f a), ObjectPair t (f b) (f c)) => r a (b + c) -> t (f a) (f b, f c) Source #

  mapEither f ≡ sum2product . fmap f
  

filter :: (Object r a, Object r Bool, Object t (f a)) => r a Bool -> t (f a) (f a) Source #

Instances

Instances details
(o (), o Void, o [Void]) => SumToProduct [] (o (->)) (o (->)) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

sum2product :: (ObjectSum (o (->)) a b, ObjectPair (o (->)) [a] [b]) => (o (->)) [a + b] ([a], [b]) Source #

mapEither :: (Object (o (->)) a, ObjectSum (o (->)) b c, Object (o (->)) [a], ObjectPair (o (->)) [b] [c]) => (o (->)) a (b + c) -> (o (->)) [a] ([b], [c]) Source #

filter :: (Object (o (->)) a, Object (o (->)) Bool, Object (o (->)) [a]) => (o (->)) a Bool -> (o (->)) [a] [a] Source #

SumToProduct [] (->) (->) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

sum2product :: (ObjectSum (->) a b, ObjectPair (->) [a] [b]) => [a + b] -> ([a], [b]) Source #

mapEither :: (Object (->) a, ObjectSum (->) b c, Object (->) [a], ObjectPair (->) [b] [c]) => (a -> (b + c)) -> [a] -> ([b], [c]) Source #

filter :: (Object (->) a, Object (->) Bool, Object (->) [a]) => (a -> Bool) -> [a] -> [a] Source #