first-class-patterns-0.3.2.5: 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 :: [Type]) r Source #

Curried functions. We have

Fun '[x1, ..., xn] r   =   x1 -> ... -> xn -> r
Instances
type Fun ([] :: [Type]) r Source # 
Instance details

Defined in Data.Pattern.Base.Tuple

type Fun ([] :: [Type]) r = r
type Fun (h ': t) r Source # 
Instance details

Defined in Data.Pattern.Base.Tuple

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 :: Type -> Type) (xs :: [Type]) :: [Type] Source #

Instances
type Map f ([] :: [Type]) Source # 
Instance details

Defined in Data.Pattern.Base.Tuple

type Map f ([] :: [Type]) = ([] :: [Type])
type Map f (h ': t) Source # 
Instance details

Defined in Data.Pattern.Base.Tuple

type Map f (h ': t) = f h ': Map f t

class Distribute xs where Source #

Methods

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

Instances
Distribute ([] :: [Type]) Source # 
Instance details

Defined in Data.Pattern.Base.Tuple

Methods

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

(Uncurriable t, Tupable t, Distribute t) => Distribute (h ': t) Source # 
Instance details

Defined in Data.Pattern.Base.Tuple

Methods

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