proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Object

Description

Working with objects through their identity arrows: Obj a is a ~> a used as a witness that a is an object, with obj, src and tgt to produce them and the Obj/Objs pattern synonyms to recover Ob constraints from arrows and profunctor values.

Synopsis

Documentation

type Obj (a :: k) = a ~> a Source Github #

Type of identity morphism for object a.

pattern Obj :: forall k (a :: k). CategoryOf k => Ob a => Obj a Source Github #

pattern Objs :: forall {j} {k} p (a :: k) (b :: j). Profunctor p => (Ob a, Ob b) => p a b Source Github #

Matching a profunctor value p a b against Objs brings (Ob a, Ob b) into scope. This is the pattern form of (\\), handy in function equations.

obj :: forall {k} (a :: k). (CategoryOf k, Ob a) => Obj a Source Github #

The identity morphism for a given object. Compared to id this makes the kind argument implicit, allowing to write obj @a instead of id @k @a.

src :: forall {j} {k} (a :: k) (b :: j) p. Profunctor p => p a b -> Obj a Source Github #

Extract source identity morphism from a profunctor heteromorphism.

tgt :: forall {k1} {k2} (a :: k2) (b :: k1) p. Profunctor p => p a b -> Obj b Source Github #

Extract target identity morphism from a profunctor heteromorphism.

class (Ob a, CategoryOf k) => Ob' (a :: k) Source Github #

Ob as a proper class, for the positions where the type family Ob itself cannot appear, such as the head of a quantified constraint.

Instances

Instances details
(Ob a, CategoryOf k) => Ob' (a :: k) Source Github # 
Instance details

Defined in Proarrow.Core

class (CategoryOf k, forall (a :: k). Ob' a) => VacuousOb k Source Github #

A category without constraints on its objects.

Instances

Instances details
(CategoryOf k, forall (a :: k). Ob' a) => VacuousOb k Source Github # 
Instance details

Defined in Proarrow.Core

objDicts :: forall {k1} {k2} p (a :: k2) (a' :: k1). Profunctor p => p a a' -> (ObjDict a, ObjDict a') Source Github #

data ObjDict (a :: k) where Source Github #

Constructors

ObjDict :: forall {k} (a :: k). Ob a => ObjDict a 

Lists of objects

type family (as :: [k]) ++ (bs :: [k]) :: [k] where ... Source Github #

List concatenation.

Equations

('[] :: [k]) ++ (bs :: [k]) = bs 
(a ': as :: [k]) ++ (bs :: [k]) = a ': (as ++ bs) 

data ListOf (c :: OB k) (xs :: [k]) where Source Github #

A type-level list with the evidence c for each element, as a value.

Constructors

Nil :: forall {k} (c :: OB k). ListOf c ('[] :: [k]) 
Cons :: forall {k} {c :: OB k} (x :: k) (xs1 :: [k]). c x => ListOf c xs1 -> ListOf c (x ': xs1) 

class KnownListOf (c :: OB k) (xs :: [k]) where Source Github #

A type-level list whose elements have the evidence c, as its ListOf.

Methods

listOf :: ListOf c xs Source Github #

Instances

Instances details
KnownListOf (c :: OB k) ('[] :: [k]) Source Github # 
Instance details

Defined in Proarrow.Object

Methods

listOf :: ListOf c ('[] :: [k]) Source Github #

(c x, KnownListOf c xs) => KnownListOf (c :: a -> Constraint) (x ': xs :: [a]) Source Github # 
Instance details

Defined in Proarrow.Object

Methods

listOf :: ListOf c (x ': xs) Source Github #

withKnownListOf :: forall {k} (c :: OB k) (xs :: [k]) r. ListOf c xs -> (KnownListOf c xs => r) -> r Source Github #

The class from the list.

mapListOf :: forall {k} c (xs :: [k]) r. (forall (x :: k). c x => r) -> ListOf c xs -> [r] Source Github #

A value for each element, in order.

lengthListOf :: forall {k} (c :: OB k) (xs :: [k]). ListOf c xs -> Int Source Github #

The number of elements.

appendListOf :: forall {k} (c :: OB k) (as :: [k]) (bs :: [k]). ListOf c as -> ListOf c bs -> ListOf c (as ++ bs) Source Github #

The elements of both lists.

withKnownAppend :: forall {k} (c :: OB k) (as :: [k]) (bs :: [k]) r. (KnownListOf c as, KnownListOf c bs) => (KnownListOf c (as ++ bs) => r) -> r Source Github #

The class for the elements of both lists.

withKnownAssoc :: forall {k} (c :: OB k) (as :: [k]) (bs :: [k]) (cs :: [k]) r. (KnownListOf c as, KnownListOf c bs, KnownListOf c cs) => ((KnownListOf c ((as ++ bs) ++ cs), KnownListOf c (as ++ (bs ++ cs))) => r) -> r Source Github #

The class for the elements of three lists, appended either way round.

eqListOf :: forall {k} c (as :: [k]) (bs :: [k]). (forall (x :: k) (y :: k). (c x, c y) => Maybe (x :~: y)) -> ListOf c as -> ListOf c bs -> Maybe (as :~: bs) Source Github #

Whether two lists have the same elements, given how to decide that for one element.

One object of many

data SomeOf (c :: OB k) where Source Github #

Some type with the evidence c, which one known only at runtime.

Constructors

Some :: forall {k} {c :: OB k} (x :: k). c x => SomeOf c 

Instances

Instances details
Show (SomeOf ((Typeable :: k -> Constraint) :&&: c)) Source Github # 
Instance details

Defined in Proarrow.Object

Eq (SomeOf ((Typeable :: k -> Constraint) :&&: c)) Source Github # 
Instance details

Defined in Proarrow.Object

Methods

(==) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(/=) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

Ord (SomeOf ((Typeable :: k -> Constraint) :&&: c)) Source Github # 
Instance details

Defined in Proarrow.Object

Methods

compare :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Ordering Github #

(<) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(<=) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(>) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

(>=) :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> Bool Github #

max :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) Github #

min :: SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeOf ((Typeable :: k -> Constraint) :&&: c) Github #

someOfList :: forall {k} (c :: OB k) (xs :: [k]). ListOf c xs -> [SomeOf c] Source Github #

The elements of the list, each on its own.

withListOf :: forall {k} (c :: OB k) r. [SomeOf c] -> (forall (xs :: [k]). ListOf c xs -> r) -> r Source Github #

A list of types known at runtime as a type-level list.

someRepOf :: forall {k} (c :: OB k). SomeOf ((Typeable :: k -> Constraint) :&&: c) -> SomeTypeRep Source Github #

The type representation of the type, which is what SomeOf values are compared and shown by.