first-class-patterns-0.3.2.4: First class patterns and pattern matching, using type families

LicenseBSD3
MaintainerBrent Yorgey <byorgey@cis.upenn.edu>
Stabilityexperimental
Portabilitynon-portable (see .cabal)
Safe HaskellNone
LanguageHaskell2010

Data.Pattern.Base.Tuple

Contents

Description

Various types defined inductively as type families or data families on type-lists.

Synopsis

Functions

type family Fun (xs :: [*]) r Source #

Curried functions. We have

Fun '[x1, ..., xn] r   =   x1 -> ... -> xn -> r

Instances

type Fun ([] *) r Source # 
type Fun ([] *) r = r
type Fun ((:) * h t) r Source # 
type Fun ((:) * h t) r = h -> Fun t r

Tuples

data Tuple xs Source #

Tuples with types given by xs.

zeroT :: Tuple '[] Source #

The empty tuple

oneT :: a -> Tuple '[a] Source #

The singleton tuple

(<+>) :: Tuple xs -> Tuple ys -> Tuple (xs :++: ys) Source #

Concatenation of tuples.

runTuple :: Tuple xs -> Fun xs r -> r Source #

Runs a tuple by applying it to a curried function.

Mapping and distributing over tuples

type family Map (f :: * -> *) (xs :: [*]) :: [*] Source #

Instances

type Map f ([] *) Source # 
type Map f ([] *) = [] *
type Map f ((:) * h t) Source # 
type Map f ((:) * h t) = (:) * (f h) (Map f t)

class Distribute xs where Source #

Minimal complete definition

distribute

Methods

distribute :: Functor f => f (Tuple xs) -> Tuple (Map f xs) Source #

Instances

Distribute ([] *) Source # 

Methods

distribute :: Functor f => f (Tuple [*]) -> Tuple (Map f [*]) Source #

(Uncurriable t, Tupable t, Distribute t) => Distribute ((:) * h t) Source # 

Methods

distribute :: Functor f => f (Tuple ((* ': h) t)) -> Tuple (Map f ((* ': h) t)) Source #