compdata-0.4.1: Compositional Data Types

Portabilitynon-portable (GHC Extensions)
MaintainerTom Hvitved <>



This module defines a monad for generating fresh, abstract variables, useful e.g. for defining equality on terms.



data FreshM a Source

Monad for generating fresh (abstract) variables.


data Var i Source

Abstract notion of a variable (the constructor is hidden).


PShow Var 
PEq Var 
POrd Var 
(ShowHD f, PShow a) => PShow (Cxt h f Var a)

From an ShowHD higher-order difunctor an ShowHD instance of the corresponding term type can be derived.

(EqHD f, PEq a) => PEq (Cxt h f Var a) 
(OrdHD f, POrd a) => POrd (Cxt h f Var a) 

varEq :: Var i -> Var j -> BoolSource

Equality on variables.

varCompare :: Var i -> Var j -> OrderingSource

Ordering of variables.

varShow :: Var i -> StringSource

Printing of variables.

genVar :: FreshM (Var i)Source

Generate a fresh variable.

varCoerce :: Var i -> Var jSource

Change the type of a variable.

evalFreshM :: FreshM a -> aSource

Evaluate a computation that uses fresh variables.