Safe Haskell | None |
---|---|

Language | Haskell2010 |

This module provides a way to constrain types to be data constructors, much like Control.IndexT.Tuple and Control.IndexT.Function.

It also provides type families for accessing the elements of those data constructors, both the constructors themselves and the parameters to them.

Note I haven't yet wrote code to generate many instances for these, so currently only constructors with up to two parameters is supported. Just nag me if your application needs more.

- type IndexC n i a = IndexCK Type n i a
- type family IndexCK k (n :: Nat) (i :: Nat) a = (r :: k)
- type family GetConstructor1 a where ...
- type family GetConstructor2 a where ...
- type family IsData (n :: Nat) a :: Constraint

# Documentation

type IndexC n i a = IndexCK Type n i a Source #

IndexC i n (f a_0 a_1 .. a_(n-1))

the ith (zero based) parameter of the constructor with n parameters, i.e. `a_i`

This however only allows constructors with parameters of type :: `Type`

,
not of other kinds (see `IndexCK`

)

type family IndexCK k (n :: Nat) (i :: Nat) a = (r :: k) Source #

Just like 'IndexC' but has an additional kind parameter

These functions actually get the constructor, Unfortunately these are separate named functions instead
of being indexed by `n`

because they have different kinds, i.e. `GetConstructor1`

is `* -> *`

whereas `GetConstructor2`

is `* -> * -> *`

. If there's a better way of doing this let me know.

type family GetConstructor1 a where ... Source #

GetConstructor1 (f _) = f |

type family GetConstructor2 a where ... Source #

GetConstructor2 (f _ _) = f |