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

Copyright(c) 2015, Aleksey Kliger
LicenseBSD3 (See LICENSE)
MaintainerAleksey Kliger
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010
ExtensionsTemplateHaskell

Unbound.Generics.LocallyNameless.TH

Description

Template Haskell methods to construct instances of Alpha for datatypes that don't contain any names and don't participate in Alpha operations in any non-trivial way.

Synopsis

Documentation

makeClosedAlpha :: Name -> DecsQ Source

Make a trivial instance Alpha T for a type T that does not contain any bound or free variable names (or any in general any values that are themselves non-trivial instances of Alpha). Use this to write Alpha instances for types that you don't want to traverse via their GHC.Generics.Rep representation just to find out that there aren't any names.

newtype T = T Int deriving (Eq, Ord, Show)
$(makeClosedAlpha T)
-- constructs
-- instance Alpha T where
--   aeq' _ = (==)
--   acompare' _ = compare
--   fvAny' _ _ = pure
--   close _ _ = id
--   open _ _ = id
--   isPat _ = mempty
--   isTerm _ = True
--   nthPatFind _ = Left
--   namePatFind _ _ = Left 0
--   swaps' _ _ = id
--   freshen' _ i = return (i, mempty)
--   lfreshen' _ i cont = cont i mempty