Lambda-Calculus
LicenseApache License 2.0
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Transpiler.Conversion

Description

Converts from Equation to Lambda using a method that: allows for recursion between multiple variables; is suitably efficient.

Synopsis

Documentation

type Scope a = String -> Either String (Expr (ScopeTerm a)) #

Type representing return value of makeAccessor.

data RHS #

Represents the right hand side of an equation, which can either be a term or an application of multiple RHSses.

Constructors

App RHS RHS 
Term String 

data LHS #

Represents the left hand side of an equation: an equation's name and the list of bound variables it takes.

Constructors

LHS String [String] 

data Equation #

Represents an equation that can be converted to a Expr a, which consists of an LHS and RHS.

Constructors

Equation LHS RHS 

name :: Equation -> String #

Gets the name of an equation

convertRHS :: Integral a => Scope a -> RHS -> Either String (Expr (ScopeTerm a)) #

Converts the right hand side of an equation to a Expr a, given its scope.

convertExpression :: Integral a => [String] -> Scope a -> Equation -> Either String (Expr (ScopeTerm a)) #

Generates the scope of the right hand side of an equation, and then converts it.

boolChoice :: Integral a => [Expr (ScopeTerm a)] -> Expr (ScopeTerm a) #

Makes a function from which variables can be chosen, by applying truthAccessor and falseAccessor to a binary structure.

ensureNoDuplicates :: [Equation] -> Either String [String] #

Errors with the name of a duplicate variable if it exists.

splitInlineable :: [Equation] -> ([Equation], [Equation]) #

Converts equations so that identifyInlineable can be used, and returns inlineable and global variables in order.

toExpression :: Integral a => [Equation] -> Either String (Expr a) #

Converts a program into a lambda expression.