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.
- data Product f as where
- class ToProduct tuple f as | f as -> tuple where
- tupleToProduct :: ToProduct t f as => t -> Product f as
- type OpenProduct = Product Identity
- class ToOpenProduct tuple as | as -> tuple where
- tupleToOpenProduct :: ToOpenProduct t as => t -> OpenProduct as
Documentation
>>>
-- :set -XDataKinds
data Product f as where Source #
An extensible product type. This is similar to
Union
, except a product type
instead of a sum type.
class ToProduct tuple f as | f as -> tuple where Source #
This type class provides a way to turn a tuple into a Product
.
tupleToProduct :: ToProduct t f as => t -> Product f as Source #
Turn a tuple into a Product
.
>>>
tupleToProduct (Identity 1, Identity 2.0) :: Product Identity '[Int, Double]
Cons (Identity 1) (Cons (Identity 2.0) Nil)
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 #
tupleToOpenProduct :: ToOpenProduct t as => t -> OpenProduct as Source #
Turn a tuple into an OpenProduct
.
For example, turn a triple into an OpenProduct
:
>>>
tupleToOpenProduct (1, 2.0, "hello") :: OpenProduct '[Int, Double, String]
Cons (Identity 1) (Cons (Identity 2.0) (Cons (Identity "hello") Nil))
Turn a single value into an OpenProduct
:
>>>
tupleToOpenProduct 'c' :: OpenProduct '[Char]
Cons (Identity 'c') Nil