Module

Data.Functor.Polynomial

Package
purescript-dissect
Repository
PureFunctor/purescript-dissect

Polynomial functors and bifunctors for implementing data types that comes equipped with free Dissect instances.

#Const Source

newtype Const :: forall k. Type -> k -> Typenewtype Const a b

Const models non-recursive data constructors.

Const Unit can be used to represent data constructors with no type arguments, while Const Void can be used data constructors that do not exist at all.

Constructors

Instances

#Id Source

newtype Id a

Id models recursive data constructors.

Constructors

Instances

#Sum Source

data Sum :: forall k. (k -> Type) -> (k -> Type) -> k -> Typedata Sum a b c

Sum models choice between two polynomial functors.

Sum can also be nested to allow for more variants, although this comes with the cost of having to unwrap several layers of structure when performing pattern matching.

Note that the Sum of some type a and Const Void is the same as just the type a.

0 (Const Void) + a ~ a
a + 0 (Const Void) ~ a

Constructors

Instances

#Product Source

data Product :: forall k. (k -> Type) -> (k -> Type) -> k -> Typedata Product a b c

Product models a pair of polynomial functors.

Product can also be nested to allow for more variants, although this comes with the cost of having to unwrap several layers of structure when performing pattern matching. However, one can make use of the (:*:) operator for better ergonomics.

Note that the Product of some type a and Const Void is Const Void, while the Product of some type a and Const Unit is just the type a.

0 (Const Void) * a ~ 0 (Const Void)
a * 0 (Const Void) ~ 0 (Const Void)

1 (Const Unit) * a ~ a
a * 1 (Const Unit) ~ a

Constructors

Instances

#type (:*:) Source

Operator alias for Data.Functor.Polynomial.Product (right-associative / precedence 4)

#(:*:) Source

Operator alias for Data.Functor.Polynomial.Product (right-associative / precedence 4)

#One Source

type One :: forall k. k -> Typetype One = Const Unit

An alias for Const Unit.

#Zero Source

type Zero :: forall k. k -> Typetype Zero = Const Void

An alias for Const Void.

#type (:+:) Source

Operator alias for Data.Functor.Polynomial.Sum (right-associative / precedence 5)

#Const_2 Source

newtype Const_2 :: forall k l. Type -> k -> l -> Typenewtype Const_2 a b c

Constructors

Instances

#Sum_2 Source

data Sum_2 :: forall k l. (k -> l -> Type) -> (k -> l -> Type) -> k -> l -> Typedata Sum_2 p q a b

Constructors

Instances

#Product_2 Source

data Product_2 :: forall k l. (k -> l -> Type) -> (k -> l -> Type) -> k -> l -> Typedata Product_2 p q a b

Constructors

Instances

#Fst Source

type Fst = Clown Id

#Snd Source

type Snd = Joker Id

#One_2 Source

type One_2 :: forall k l. k -> l -> Typetype One_2 = Const_2 Unit

Instances

  • Dissect Id One_2

    Id has a single position for an element, and unlike Const, allows its dissection to be eventually filled-in.

  • Plug Id One_2

#Zero_2 Source

type Zero_2 :: forall k l. k -> l -> Typetype Zero_2 = Const_2 Void

Instances

#refute Source

refute :: forall a. Void -> a