| License | Apache License 2.0 |
|---|---|
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Transpiler.Scope
Description
Contains helpers for differentiating the behaviour conversions have on bound and unbound variables. Furthermore, this module enables for inlined variables.
Synopsis
- data ScopeTerm t
- addDepth :: Integral a => a -> Expr (ScopeTerm a) -> Expr (ScopeTerm a)
- toScopeTerm :: Expr a -> Expr (ScopeTerm a)
- toTerm :: Integral a => Expr (ScopeTerm a) -> Expr a
- accessIndex :: Integral a => Expr (ScopeTerm a) -> a -> a -> Expr (ScopeTerm a)
- makeGlobalAccessor :: Integral a => [String] -> String -> Maybe (Expr (ScopeTerm a))
- accessMain :: Integral a => [String] -> Expr (ScopeTerm a) -> Maybe (Expr (ScopeTerm a))
- makeBoundAccessor :: Integral a => [String] -> String -> Maybe (Expr (ScopeTerm a))
- makeAccessor :: Integral a => [String] -> [String] -> (String -> Either String (Expr (ScopeTerm a))) -> String -> Either String (Expr (ScopeTerm a))
- identifyInlineable :: [(String, [String], a)] -> [(String, a)]
Documentation
Term that can refer to either the global scope or a bound variable.
addDepth :: Integral a => a -> Expr (ScopeTerm a) -> Expr (ScopeTerm a) #
Adds depth to all bound variables so that an expression can be wrapped in a and still be valid.Lambda
toScopeTerm :: Expr a -> Expr (ScopeTerm a) #
Converts an expression containing only bound variables to a scoped expression.
toTerm :: Integral a => Expr (ScopeTerm a) -> Expr a #
Converts an expression containing scoped terms to one containing only scoped variables, with the assumption that the global scope is at depth 0.
Arguments
| :: Integral a | |
| => Expr (ScopeTerm a) | The partition that access is being done on. |
| -> a | The length of this partition. |
| -> a | The term that needs to be accessed in this partition. |
| -> Expr (ScopeTerm a) | Expression which accesses this term. |
Accesses the nth term of a partition of length l, by passing in and truthAccessor
to access binary partitions of this partition.falseAccessor
makeGlobalAccessor :: Integral a => [String] -> String -> Maybe (Expr (ScopeTerm a)) #
Accesses a global variable from the global scope: see for an in detail explanation of how this works.accessIndex
accessMain :: Integral a => [String] -> Expr (ScopeTerm a) -> Maybe (Expr (ScopeTerm a)) #
Accesses main, but outside of the : this enables a program to be run.yCombinator
makeBoundAccessor :: Integral a => [String] -> String -> Maybe (Expr (ScopeTerm a)) #
Accesses a bound variable: as the bound term refers to a term at a higer level, the length of bound terms should not be added to this accessor.
Arguments
| :: Integral a | |
| => [String] | The list of bound variable names. |
| -> [String] | The list of global variable names. |
| -> (String -> Either String (Expr (ScopeTerm a))) | A function giving inlined expressions. |
| -> String | The variable wanting to be accessed. |
| -> Either String (Expr (ScopeTerm a)) | The final expression that accesses the variable. |
Accesses any variable: bound variables; global variables; inlined variables.