references-0.2.1.0: Generalization of lenses, folds and traversals to handle monads and addition.

Safe HaskellNone
LanguageHaskell98

Control.Reference.TH.Tuple

Description

A module for creating lenses to fields of simple, tuple data structures like pairs, triplets, and so on.

Synopsis

Documentation

data TupleConf

A tuple configuration is a scheme for tuple-like data structures.

Constructors

TupleConf 

Fields

tupleType :: [Name] -> Type
 
tuplePattern :: [Name] -> Pat
 
tupleExpr :: [Name] -> Exp
 

hsTupConf :: TupleConf

Generates the normal haskell tuples ((a,b), (a,b,c), (a,b,c,d))

makeTupleRefs :: TupleConf -> Int -> Int -> Q [Dec]

Creates Lens_1 ... Lens_n classes, and instances for tuples up to m.

Classes and instances look like the following:

class Lens_1 s t a b | s -> a, t -> b
                     , a t -> s, b s -> t where 
  _1 :: Lens s t a b

instance Lens_1 (a,b) (a',b) a a' where 
  _1 = lens ((a,b) -> a) (a' (a,b) -> (a',b))