unbound-generics-0.3: Support for programming with names and binders using GHC Generics

Copyright(c) 2014, Aleksey Kliger
LicenseBSD3 (See LICENSE)
MaintainerAleksey Kliger
Safe HaskellNone



The pattern Rebind p1 p2 binds the names in p1 and p2 just as (p1, p2) would, however it additionally also brings the names of p1 into scope in p2.



data Rebind p1 p2 Source

Rebind p1 p2 is a pattern that binds the names of p1 and p2, and additionally brings the names of p1 into scope over p2.

This may be used, for example, to faithfully represent Scheme's let* binding form, defined by:

 (let* () body) ≙ body
 (let* ([v1, e1] binds ...) body) ≙ (let ([v1, e1]) (let* (binds ...) body))

using the following AST:

type Var = Name Expr
data Lets = EmptyLs
          | ConsLs (Rebind (Var, Embed Expr) Lets)
data Expr = ...
          | LetStar (Bind Lets Expr)
          | ...


Rebnd p1 p2 


(Subst c p1, Subst c p2) => Subst c (Rebind p1 p2) Source 
(Eq p1, Eq p2) => Eq (Rebind p1 p2) Source 
(Show p1, Show p2) => Show (Rebind p1 p2) Source 
Generic (Rebind p1 p2) Source 
(NFData p1, NFData p2) => NFData (Rebind p1 p2) Source 
(Alpha p1, Alpha p2) => Alpha (Rebind p1 p2) Source 
type Rep (Rebind p1 p2) Source