yoko
Version 0.2 revision 0 uploaded by NicolasFrisby.
Package meta
- Synopsis
- generic programming with disbanded constructors
- Description
yoko
views a nominal datatype as a band of constructors, each a nominal type in its own right. Such datatypes can be disbanded via thedisband
function into an anonymous sum of nominal constructors, and vice versa via theband
function. This library uses extensive type-level programming to enrich itsinstant-generics
foundation with capabilities derived from the constructor-centric perspective.For example, consider the following nominal datatype.
data Beatles = John ... | Paul ... | George ... | Ringo ...
This type can of course be understood as a sum of the individual constructor types.
data John = John ... data Paul = Paul ... data George = George ... data Ringo = Ringo ...
yoko
's conceptual foundations start there. In particular, this allows a constructor, sayJohn
, to be used independently of its original range type and sibling constructors.As a generic programming library,
yoko
extendsinstant-generics
with support for constructor-centric generic programming. TheExamples/LL.hs
file distributed with theyoko
source demonstrates defining a lambda-lifting conversion between the two typesInner
, which has lambdas, andProg
, which has top-level function declarations instead.data Inner = Lam Type Inner | Var Int | App Inner Inner data Term = Var Int | App Term Term | DVar Int data Prog = Prog ([Type], Type, Term) Term
These types are defined in separate modules, since they have constructors with the same name. Indeed, the fact that they having matching constructors named
App
is crucial foryoko
's automatic conversion fromInner
'sApp
toTerm
'sApp
. As written, the generic lambda-lifter would continue to work for any newInner
constructors (e.g. syntax for tuples or mutable references) as long as constructors with the same names and analogous fields were added toTerm
and the semantics of those constructors doesn't involve binding. This default behavior of the lambda-lifter is specified in about ten lines of user code.Existing generic libraries don't use constructor names to the degree that
yoko
does, and so cannot accomodate generic conversions nearly as well.See the wiki at http://code.google.com/p/yoko for more documentation.
- Author
- Nicolas Frisby <nicolas.frisby@gmail.com>
- Bug reports
- n/a
- Category
- Generics, Reflection
- Copyright
- n/a
- Homepage
- n/a
- Maintainer
- Nicolas Frisby <nicolas.frisby@gmail.com>
- Package URL
- n/a
- Stability
- experimental