servant-checked-exceptions-0.4.1.0: Checked exceptions for Servant APIs.

CopyrightDennis Gosnell 2017
LicenseBSD3
MaintainerDennis Gosnell (cdep.illabout@gmail.com)
Stabilityexperimental
Portabilityunknown
Safe HaskellSafe
LanguageHaskell2010

Servant.Checked.Exceptions.Internal.Product

Description

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

Synopsis

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.

Constructors

Nil :: Product f '[] 
Cons :: !(f a) -> Product f as -> Product f (a ': as) 

Instances

(Show (f a1), Show (Product a f as)) => Show (Product a f ((:) a a1 as)) Source #

Show Cons values.

Methods

showsPrec :: Int -> Product a f ((a ': a1) as) -> ShowS #

show :: Product a f ((a ': a1) as) -> String #

showList :: [Product a f ((a ': a1) as)] -> ShowS #

Show (Product u f ([] u)) Source #

Show Nil values.

Methods

showsPrec :: Int -> Product u f [u] -> ShowS #

show :: Product u f [u] -> String #

showList :: [Product u f [u]] -> ShowS #

class ToProduct tuple f as | f as -> tuple where Source #

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

Minimal complete definition

toProduct

Methods

toProduct :: tuple -> Product f as Source #

Convert a tuple into a Product. See tupleToProduct for examples.

Instances

ToProduct u (f a) f ((:) u a ([] u)) Source #

Convert a single value into a Product.

Methods

toProduct :: f -> Product (f a) ((u ': a) [u]) as Source #

ToProduct u (f a, f b) f ((:) u a ((:) u b ([] u))) Source #

Convert a tuple into a Product.

Methods

toProduct :: f -> Product (f a, f b) ((u ': a) ((u ': b) [u])) as Source #

ToProduct u (f a, f b, f c) f ((:) u a ((:) u b ((:) u c ([] u)))) Source #

Convert a 3-tuple into a Product.

Methods

toProduct :: f -> Product (f a, f b, f c) ((u ': a) ((u ': b) ((u ': c) [u]))) as Source #

ToProduct u (f a, f b, f c, f d) f ((:) u a ((:) u b ((:) u c ((:) u d ([] u))))) Source #

Convert a 4-tuple into a Product.

Methods

toProduct :: f -> Product (f a, f b, f c, f d) ((u ': a) ((u ': b) ((u ': c) ((u ': d) [u])))) as Source #

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 #

Product Identity is used as a standard open product type.

class ToOpenProduct tuple as | as -> tuple where Source #

ToOpenProduct gives us a way to convert a tuple to an OpenProduct. See tupleToOpenProduct.

Minimal complete definition

toOpenProduct

Methods

toOpenProduct :: tuple -> OpenProduct as Source #

Instances

ToOpenProduct a ((:) * a ([] *)) Source #

Convert a single value into an OpenProduct.

Methods

toOpenProduct :: a -> OpenProduct ((* ': a) [*]) Source #

ToOpenProduct (a, b) ((:) * a ((:) * b ([] *))) Source #

Convert a tuple into an OpenProduct.

Methods

toOpenProduct :: (a, b) -> OpenProduct ((* ': a) ((* ': b) [*])) Source #

ToOpenProduct (a, b, c) ((:) * a ((:) * b ((:) * c ([] *)))) Source #

Convert a 3-tuple into an OpenProduct.

Methods

toOpenProduct :: (a, b, c) -> OpenProduct ((* ': a) ((* ': b) ((* ': c) [*]))) Source #

ToOpenProduct (a, b, c, d) ((:) * a ((:) * b ((:) * c ((:) * d ([] *))))) Source #

Convert a 4-tuple into an OpenProduct.

Methods

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:

>>> 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