generics-mrsop-1.2.2: Generic Programming with Mutually Recursive Sums of Products.

Safe HaskellNone
LanguageHaskell2010

Generics.MRSOP.Examples.LambdaAlphaEqTH

Contents

Description

Provide a generic alpha equality decider for the lambda calculus.

Synopsis

Documentation

data Term #

Standard Lambda Calculus.

Constructors

Var String 
Abs String Term 
App Term Term 

type FamTerm = '[Term] #

type CodesTerm = '['['[K KString], '[K KString, I Z], '[I Z, I Z]]] #

pattern App_ :: phi Z -> phi Z -> View kon phi (Lkup Z CodesTerm) #

pattern Abs_ :: kon KString -> phi Z -> View kon phi (Lkup Z CodesTerm) #

pattern Var_ :: kon KString -> View kon phi (Lkup Z CodesTerm) #

pattern IdxTerm :: forall (a :: Nat). () => a ~# Z => SNat a #

The alpha-eq monad

We will use an abstract monad for keeping track of scopes and name equivalences

class Monad m => MonadAlphaEq m where #

Interface needed for deciding alpha equivalence.

Methods

onNewScope :: m a -> m a #

Runs a computation under a new scope.

addRule :: String -> String -> m () #

Registers a name equivalence under the current scope.

(=~=) :: String -> String -> m Bool #

Checks for a name equivalence under all scopes.

Instances
MonadAlphaEq (State [[(String, String)]]) #

One of the simplest monads that implement MonadAlphaEq

Instance details

Defined in Generics.MRSOP.Examples.LambdaAlphaEqTH

Methods

onNewScope :: State [[(String, String)]] a -> State [[(String, String)]] a #

addRule :: String -> String -> State [[(String, String)]] () #

(=~=) :: String -> String -> State [[(String, String)]] Bool #

onHead :: (a -> a) -> [a] -> [a] #

onScope :: String -> String -> [[(String, String)]] -> Bool #

Given a list of scopes, which consist in a list of pairs each, checks whether or not two names are equivalent.

runAlpha :: State [[(String, String)]] a -> a #

Runs a computation.

Alpha equivalence for Lambda terms

alphaEq :: Term -> Term -> Bool #

Decides whether or not two terms are alpha equivalent.

Tests

t1 :: String -> String -> Term #

t2 :: String -> String -> String -> Char -> Term #

Orphan instances

Family Singl FamTerm CodesTerm # 
Instance details

Methods

sfrom' :: SNat ix -> El FamTerm ix -> Rep Singl (El FamTerm) (Lkup ix CodesTerm) #

sto' :: SNat ix -> Rep Singl (El FamTerm) (Lkup ix CodesTerm) -> El FamTerm ix #