Copyright | Dennis Gosnell 2017 |
---|---|

License | BSD3 |

Maintainer | Dennis Gosnell (cdep.illabout@gmail.com) |

Stability | experimental |

Portability | unknown |

Safe Haskell | Safe |

Language | Haskell2010 |

This module defines an open product type. This is used in the case-analysis
handler for the open sum type (`catchesUnion`

).

## Synopsis

- data Product (f :: u -> *) (as :: [u]) where
- class ToProduct (tuple :: *) (f :: u -> *) (as :: [u]) | f as -> tuple where
- tupleToProduct :: ToProduct t f as => t -> Product f as
- type OpenProduct = Product Identity
- class ToOpenProduct (tuple :: *) (as :: [*]) | as -> tuple where
- toOpenProduct :: tuple -> OpenProduct as

- tupleToOpenProduct :: ToOpenProduct t as => t -> OpenProduct as

# Documentation

`>>>`

`-- :set -XDataKinds`

data Product (f :: u -> *) (as :: [u]) where Source #

An extensible product type. This is similar to
`Union`

, except a product type
instead of a sum type.

class ToProduct (tuple :: *) (f :: u -> *) (as :: [u]) | f as -> tuple where Source #

This type class provides a way to turn a tuple into a `Product`

.

toProduct :: tuple -> Product f as Source #

Convert a tuple into a `Product`

. See `tupleToProduct`

for examples.

## Instances

ToProduct (f a) (f :: u -> Type) (a ': ([] :: [u]) :: [u]) Source # | Convert a single value into a |

Defined in Data.WorldPeace.Product | |

ToProduct (f a, f b) (f :: u -> Type) (a ': (b ': ([] :: [u])) :: [u]) Source # | Convert a tuple into a |

Defined in Data.WorldPeace.Product | |

ToProduct (f a, f b, f c) (f :: u -> Type) (a ': (b ': (c ': ([] :: [u]))) :: [u]) Source # | Convert a 3-tuple into a |

Defined in Data.WorldPeace.Product | |

ToProduct (f a, f b, f c, f d) (f :: u -> Type) (a ': (b ': (c ': (d ': ([] :: [u])))) :: [u]) Source # | Convert a 4-tuple into a |

Defined in Data.WorldPeace.Product |

tupleToProduct :: ToProduct t f as => t -> Product f as Source #

Turn a tuple into a `Product`

.

`>>>`

Cons (Identity 1) (Cons (Identity 2.0) Nil)`tupleToProduct (Identity 1, Identity 2.0) :: Product Identity '[Int, Double]`

type OpenProduct = Product Identity Source #

class ToOpenProduct (tuple :: *) (as :: [*]) | as -> tuple where Source #

`ToOpenProduct`

gives us a way to convert a tuple to an `OpenProduct`

.
See `tupleToOpenProduct`

.

toOpenProduct :: tuple -> OpenProduct as Source #

## Instances

ToOpenProduct a (a ': ([] :: [Type])) Source # | Convert a single value into an |

Defined in Data.WorldPeace.Product toOpenProduct :: a -> OpenProduct (a ': []) Source # | |

ToOpenProduct (a, b) (a ': (b ': ([] :: [Type]))) Source # | Convert a tuple into an |

Defined in Data.WorldPeace.Product toOpenProduct :: (a, b) -> OpenProduct (a ': (b ': [])) Source # | |

ToOpenProduct (a, b, c) (a ': (b ': (c ': ([] :: [Type])))) Source # | Convert a 3-tuple into an |

Defined in Data.WorldPeace.Product toOpenProduct :: (a, b, c) -> OpenProduct (a ': (b ': (c ': []))) Source # | |

ToOpenProduct (a, b, c, d) (a ': (b ': (c ': (d ': ([] :: [Type]))))) Source # | Convert a 4-tuple into an |

Defined in Data.WorldPeace.Product toOpenProduct :: (a, b, c, d) -> OpenProduct (a ': (b ': (c ': (d ': [])))) Source # |

tupleToOpenProduct :: ToOpenProduct t as => t -> OpenProduct as Source #

Turn a tuple into an `OpenProduct`

.

#### Examples

Turn a triple into an `OpenProduct`

:

`>>>`

Cons (Identity 1) (Cons (Identity 2.0) (Cons (Identity "hello") Nil))`tupleToOpenProduct (1, 2.0, "hello") :: OpenProduct '[Int, Double, String]`

Turn a single value into an `OpenProduct`

:

`>>>`

Cons (Identity 'c') Nil`tupleToOpenProduct 'c' :: OpenProduct '[Char]`