diff --git a/CodeGen-RiscV-AsmGen.html b/CodeGen-RiscV-AsmGen.html new file mode 100644 index 0000000..47bf3d0 --- /dev/null +++ b/CodeGen-RiscV-AsmGen.html @@ -0,0 +1 @@ +CodeGen.RiscV.AsmGen
mini-ml-0.1.0.0: MiniML compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

CodeGen.RiscV.AsmGen

Documentation

\ No newline at end of file diff --git a/CodeGen-RiscV-Lib-Monad.html b/CodeGen-RiscV-Lib-Monad.html new file mode 100644 index 0000000..742ae7e --- /dev/null +++ b/CodeGen-RiscV-Lib-Monad.html @@ -0,0 +1 @@ +CodeGen.RiscV.Lib.Monad
mini-ml-0.1.0.0: MiniML compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

CodeGen.RiscV.Lib.Monad

Documentation

newtype AsmBuilderT m a Source #

Constructors

AsmBuilderT 

Instances

Instances details
MonadTrans AsmBuilderT Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Monad

Methods

lift :: Monad m => m a -> AsmBuilderT m a #

MonadState s m => MonadState s (AsmBuilderT m) Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Monad

Methods

get :: AsmBuilderT m s #

put :: s -> AsmBuilderT m () #

state :: (s -> (a, s)) -> AsmBuilderT m a #

MonadFix m => MonadFix (AsmBuilderT m) Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Monad

Methods

mfix :: (a -> AsmBuilderT m a) -> AsmBuilderT m a #

Monad m => Applicative (AsmBuilderT m) Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Monad

Methods

pure :: a -> AsmBuilderT m a #

(<*>) :: AsmBuilderT m (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b #

liftA2 :: (a -> b -> c) -> AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m c #

(*>) :: AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b #

(<*) :: AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m a #

Functor m => Functor (AsmBuilderT m) Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Monad

Methods

fmap :: (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b #

(<$) :: a -> AsmBuilderT m b -> AsmBuilderT m a #

Monad m => Monad (AsmBuilderT m) Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Monad

Methods

(>>=) :: AsmBuilderT m a -> (a -> AsmBuilderT m b) -> AsmBuilderT m b #

(>>) :: AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b #

return :: a -> AsmBuilderT m a #

Monad m => MonadAsmBuilder (AsmBuilderT m) Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Monad

data ProgramBuilderState Source #

Constructors

PBS 
\ No newline at end of file diff --git a/CodeGen-RiscV-Lib-Types.html b/CodeGen-RiscV-Lib-Types.html new file mode 100644 index 0000000..3319db5 --- /dev/null +++ b/CodeGen-RiscV-Lib-Types.html @@ -0,0 +1 @@ +CodeGen.RiscV.Lib.Types
mini-ml-0.1.0.0: MiniML compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

CodeGen.RiscV.Lib.Types

Documentation

newtype Label Source #

Constructors

Label Text 

Instances

Instances details
Pretty Label Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Methods

pretty :: Label -> Doc ann #

prettyList :: [Label] -> Doc ann #

data Instruction Source #

Constructors

Instruction OpCode [Operand] 

Instances

Instances details
Pretty Instruction Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Methods

pretty :: Instruction -> Doc ann #

prettyList :: [Instruction] -> Doc ann #

data Directive Source #

Instances

Instances details
Pretty Directive Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Methods

pretty :: Directive -> Doc ann #

prettyList :: [Directive] -> Doc ann #

data OpCode Source #

Constructors

And 
Or 
Add 
Sub 
Mul 
Neg 
Seqz 
Snez 
Slt 
Sd 
Ld 
Li 
La 
Addi 
Beqz 
J 
Call 
Ret 

Instances

Instances details
Show OpCode Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Pretty OpCode Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Methods

pretty :: OpCode -> Doc ann #

prettyList :: [OpCode] -> Doc ann #

data Operand Source #

Instances

Instances details
Eq Operand Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Methods

(==) :: Operand -> Operand -> Bool #

(/=) :: Operand -> Operand -> Bool #

Ord Operand Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Pretty Operand Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Methods

pretty :: Operand -> Doc ann #

prettyList :: [Operand] -> Doc ann #

pattern Memory :: Offset -> Operand Source #

data Register Source #

Constructors

Zero 
Ra 
Sp 
Gp 
Tp 
T0 
T1 
T2 
S0 
S1 
A0 
A1 
A2 
A3 
A4 
A5 
A6 
A7 
S2 
S3 
S4 
S5 
S6 
S7 
S8 
S9 
S10 
S11 
T3 
T4 
T5 
T6 

Instances

Instances details
Show Register Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Eq Register Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Ord Register Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Pretty Register Source # 
Instance details

Defined in CodeGen.RiscV.Lib.Types

Methods

pretty :: Register -> Doc ann #

prettyList :: [Register] -> Doc ann #

\ No newline at end of file diff --git a/CodeGen-RiscV-Lib.html b/CodeGen-RiscV-Lib.html new file mode 100644 index 0000000..b01404e --- /dev/null +++ b/CodeGen-RiscV-Lib.html @@ -0,0 +1 @@ +CodeGen.RiscV.Lib
mini-ml-0.1.0.0: MiniML compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

CodeGen.RiscV.Lib

Synopsis

Documentation

compileT :: Monad m => AsmBuilderT m a -> m [CodeLine] Source #

Compile the code

compile :: AsmBuilder a -> [CodeLine] Source #

Compile the code

mainFunction :: MonadAsmBuilder m => (() -> m ()) -> m () Source #

Emit main function (entry point routine)

function :: MonadAsmBuilder m => Text -> Int64 -> ([Operand] -> m Operand) -> m Operand Source #

Emit main function (entry point routine)

globalVar :: MonadAsmBuilder m => Text -> m Operand Source #

Emit uninitialized global variable

externFunction :: MonadAsmBuilder m => Text -> m Operand Source #

Get external function operand

ite :: MonadAsmBuilder m => Operand -> (() -> m Operand) -> (() -> m Operand) -> m Operand Source #

\ No newline at end of file diff --git a/CodeGen-RiscV-Runner.html b/CodeGen-RiscV-Runner.html new file mode 100644 index 0000000..315e3b9 --- /dev/null +++ b/CodeGen-RiscV-Runner.html @@ -0,0 +1 @@ +CodeGen.RiscV.Runner
mini-ml-0.1.0.0: MiniML compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

CodeGen.RiscV.Runner

Documentation

\ No newline at end of file diff --git a/CodeGen-Runtime-PrintRuntime.html b/CodeGen-Runtime-PrintRuntime.html new file mode 100644 index 0000000..e3e61de --- /dev/null +++ b/CodeGen-Runtime-PrintRuntime.html @@ -0,0 +1 @@ +CodeGen.Runtime.PrintRuntime
mini-ml-0.1.0.0: MiniML compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

CodeGen.Runtime.PrintRuntime

Documentation

\ No newline at end of file diff --git a/doc-index-61.html b/doc-index-61.html index 4e682b4..ff1c017 100644 --- a/doc-index-61.html +++ b/doc-index-61.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - =)
mini-ml-0.1.0.0: MiniML compiler

Index - =

=:=TypeChecker.HindleyMilner
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - =)
mini-ml-0.1.0.0: MiniML compiler

Index - =

=:=TypeChecker.HindleyMilner
\ No newline at end of file diff --git a/doc-index-A.html b/doc-index-A.html index 1466a2d..23fe561 100644 --- a/doc-index-A.html +++ b/doc-index-A.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - A)
mini-ml-0.1.0.0: MiniML compiler

Index - A

allDeclsWithArityStdLib
AndOpTrees.Common
applyBindingsTypeChecker.HindleyMilner
ArithmeticOperatorTrees.Common
ArithOpTrees.Common
ArityTrees.Common
arrowParser.Lexer
AtomBoolTransformations.Anf.Anf
AtomicExpressionTransformations.Anf.Anf
AtomIdTransformations.Anf.Anf
AtomIntTransformations.Anf.Anf
AtomUnitTransformations.Anf.Anf
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - A)
mini-ml-0.1.0.0: MiniML compiler

Index - A

A0CodeGen.RiscV.Lib.Types
A1CodeGen.RiscV.Lib.Types
A2CodeGen.RiscV.Lib.Types
A3CodeGen.RiscV.Lib.Types
A4CodeGen.RiscV.Lib.Types
A5CodeGen.RiscV.Lib.Types
A6CodeGen.RiscV.Lib.Types
A7CodeGen.RiscV.Lib.Types
AddCodeGen.RiscV.Lib.Types
addCodeGen.RiscV.Lib
AddiCodeGen.RiscV.Lib.Types
allDeclsWithArityStdLib
AndCodeGen.RiscV.Lib.Types
andCodeGen.RiscV.Lib
AndOpTrees.Common
applyBindingsTypeChecker.HindleyMilner
ArithmeticOperatorTrees.Common
ArithOpTrees.Common
ArityTrees.Common
arrowParser.Lexer
AsmBuilderCodeGen.RiscV.Lib.Monad, CodeGen.RiscV.Lib
AsmBuilderT 
1 (Type/Class)CodeGen.RiscV.Lib.Monad, CodeGen.RiscV.Lib
2 (Data Constructor)CodeGen.RiscV.Lib.Monad
AtomBoolTransformations.Anf.Anf
AtomicExpressionTransformations.Anf.Anf
AtomIdTransformations.Anf.Anf
AtomIntTransformations.Anf.Anf
AtomUnitTransformations.Anf.Anf
\ No newline at end of file diff --git a/doc-index-All.html b/doc-index-All.html index 272ac7d..2cb5763 100644 --- a/doc-index-All.html +++ b/doc-index-All.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index)
mini-ml-0.1.0.0: MiniML compiler

Index

=:=TypeChecker.HindleyMilner
allDeclsWithArityStdLib
AndOpTrees.Common
applyBindingsTypeChecker.HindleyMilner
ArithmeticOperatorTrees.Common
ArithOpTrees.Common
ArityTrees.Common
arrowParser.Lexer
AtomBoolTransformations.Anf.Anf
AtomicExpressionTransformations.Anf.Anf
AtomIdTransformations.Anf.Anf
AtomIntTransformations.Anf.Anf
AtomUnitTransformations.Anf.Anf
BinaryOperatorTrees.Common
BooleanOperatorTrees.Common
boolLitPParser.Lexer
BoolOpTrees.Common
ccAstTransformations.Cc.Cc
checkProgramTypeChecker.TypeChecker
choice'Parser.Utils
codeCodeGen.Module
colonParser.Lexer
CompAppTransformations.Anf.Anf
ComparisonOperatorTrees.Common
CompBinOpTransformations.Anf.Anf
compErrMsgCodeGen.RunResult
CompilationErrorCodeGen.RunResult
compileToBinaryCodeGen.Llvm.Runner
compileToLlvmIrCodeGen.Llvm.Runner
compileToModuleCodeGen.Module
CompIteTransformations.Anf.Anf
ComplexExpressionTransformations.Anf.Anf
CompOpTrees.Common
compTimeCodeGen.RunResult
CompUnOpTransformations.Anf.Anf
Declaration 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Parser.Ast
DeclarationWithArityStdLib
DeclFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
declIdTransformations.Simplifier.SimplifiedAst
declsStdLib
DeclVar 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
DivOpTrees.Common
eqParser.Lexer
EqOpTrees.Common
exitCodeCodeGen.RunResult
ExprApp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprAtomTransformations.Anf.Anf
ExprBinOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprCompTransformations.Anf.Anf
Expression 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Transformations.Ll.Lfr
3 (Type/Class)Transformations.Anf.Anf
4 (Type/Class)Parser.Ast
ExprFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
ExprId 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprIte 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprLetIn 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Transformations.Anf.Anf
4 (Data Constructor)Parser.Ast
ExprPrimVal 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprUnOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ForallTypeChecker.HindleyMilner
freshTypeChecker.HindleyMilner
Fun 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Parser.Ast
4 (Data Constructor)Parser.Ast
GenTrees.Common
genAnfTransformations.Anf.AnfGen
generalizeTypeChecker.HindleyMilner
genLlvmIrModuleCodeGen.Llvm.LlvmIrGen
GeOpTrees.Common
GlobalDeclaration 
1 (Type/Class)Transformations.Ll.Lfr
2 (Type/Class)Transformations.Anf.Anf
GlobFunDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GlobVarDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GtOpTrees.Common
IdCntTrees.Common
IdentifierTrees.Common
Identifier'Trees.Common
identifierPParser.Lexer
ImpossibleBinOpApplicationTypeChecker.HindleyMilner
ImpossibleUnOpApplicationTypeChecker.HindleyMilner
InferTypeChecker.HindleyMilner
inferProgramTypeChecker.TypeChecker
InfiniteTypeChecker.HindleyMilner
intLitPParser.Lexer
IsRecTrees.Common
kwBoolParser.Lexer
kwElseParser.Lexer
kwFunParser.Lexer
kwIfParser.Lexer
kwInParser.Lexer
kwIntParser.Lexer
kwLetParser.Lexer
kwRecParser.Lexer
kwThenParser.Lexer
kwUnitParser.Lexer
leftParParser.Lexer
LeOpTrees.Common
lexemeParser.Lexer
liftM1'MonadUtils
liftM2'MonadUtils
liftM3'MonadUtils
llAstTransformations.Ll.Ll
locallyMonadUtils
lookupTypeChecker.HindleyMilner
LtOpTrees.Common
manyParensParser.Utils
measureTimeCodeGen.TimedValue
measureTimedValueCodeGen.TimedValue
MinusOpTrees.Common
MismatchTypeChecker.HindleyMilner
mkVarNameTypeChecker.HindleyMilner
Module 
1 (Type/Class)CodeGen.Module
2 (Data Constructor)CodeGen.Module
MulOpTrees.Common
Nanoseconds 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
NeOpTrees.Common
optional'Parser.Utils
OrOpTrees.Common
parensParser.Utils
parseProgramParser.Parser
ParserParser.Lexer
PlusOpTrees.Common
PolyTypeChecker.HindleyMilner
PolytypeTypeChecker.HindleyMilner
ppLlvmModuleCodeGen.Llvm.LlvmIrGen
prettyTypeChecker.PrettyPrinter
prettyPrintTransformations.Anf.PrettyPrinter
PrimitiveValueTrees.Common
PrimValBoolTrees.Common
PrimValIntTrees.Common
PrimValUnitTrees.Common
Program 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Transformations.Ll.Lfr
4 (Data Constructor)Transformations.Ll.Lfr
5 (Type/Class)Transformations.Anf.Anf
6 (Data Constructor)Transformations.Anf.Anf
7 (Type/Class)Parser.Ast
8 (Data Constructor)Parser.Ast
relabelAstTransformations.Relabeler.Relabeler
rightParParser.Lexer
runCodeGen.Llvm.Runner
RunResultCodeGen.RunResult
runTimeCodeGen.RunResult
RuntimeErrorCodeGen.RunResult
scParser.Lexer
semicolon2Parser.Lexer
simplifyAstTransformations.Simplifier.Simplifier
someParensParser.Utils
StatementParser.Ast
stderrCodeGen.RunResult
stdoutCodeGen.RunResult
StmtDeclParser.Ast
StmtExprParser.Ast
SuccessCodeGen.RunResult
symbolParser.Lexer
TBoolTrees.Common
TBoolFTypeChecker.HindleyMilner
TFunTrees.Common
TFunFTypeChecker.HindleyMilner
timeCodeGen.TimedValue
TimedValue 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
TIntTrees.Common
TIntFTypeChecker.HindleyMilner
toPolytypeTypeChecker.HindleyMilner
toUTypeTypeChecker.HindleyMilner
TUnitTrees.Common
TUnitFTypeChecker.HindleyMilner
TVarFTypeChecker.HindleyMilner
TxtTrees.Common
TypeTrees.Common
TypedDeclarationStdLib
typedDeclsStdLib
TypeErrorTypeChecker.HindleyMilner
TypeFTypeChecker.HindleyMilner
UnaryOperatorTrees.Common
UnboundVarTypeChecker.HindleyMilner
unitLitPParser.Lexer
UnMinusOpTrees.Common
UnreachableTypeChecker.HindleyMilner
UTBoolTypeChecker.HindleyMilner
UTermTypeChecker.HindleyMilner
UTFunTypeChecker.HindleyMilner
UTIntTypeChecker.HindleyMilner
UTUnitTypeChecker.HindleyMilner
UTVarTypeChecker.HindleyMilner
UTypeTypeChecker.HindleyMilner
valueCodeGen.TimedValue
VarDeclTransformations.Ll.Lfr
VarDeclarationTransformations.Ll.Lfr
withBindingTypeChecker.HindleyMilner
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index)
mini-ml-0.1.0.0: MiniML compiler

Index

=:=TypeChecker.HindleyMilner
A0CodeGen.RiscV.Lib.Types
A1CodeGen.RiscV.Lib.Types
A2CodeGen.RiscV.Lib.Types
A3CodeGen.RiscV.Lib.Types
A4CodeGen.RiscV.Lib.Types
A5CodeGen.RiscV.Lib.Types
A6CodeGen.RiscV.Lib.Types
A7CodeGen.RiscV.Lib.Types
AddCodeGen.RiscV.Lib.Types
addCodeGen.RiscV.Lib
AddiCodeGen.RiscV.Lib.Types
allDeclsWithArityStdLib
AndCodeGen.RiscV.Lib.Types
andCodeGen.RiscV.Lib
AndOpTrees.Common
applyBindingsTypeChecker.HindleyMilner
ArithmeticOperatorTrees.Common
ArithOpTrees.Common
ArityTrees.Common
arrowParser.Lexer
AsmBuilderCodeGen.RiscV.Lib.Monad, CodeGen.RiscV.Lib
AsmBuilderT 
1 (Type/Class)CodeGen.RiscV.Lib.Monad, CodeGen.RiscV.Lib
2 (Data Constructor)CodeGen.RiscV.Lib.Monad
AtomBoolTransformations.Anf.Anf
AtomicExpressionTransformations.Anf.Anf
AtomIdTransformations.Anf.Anf
AtomIntTransformations.Anf.Anf
AtomUnitTransformations.Anf.Anf
BeqzCodeGen.RiscV.Lib.Types
BinaryOperatorTrees.Common
BooleanOperatorTrees.Common
boolLitPParser.Lexer
BoolOpTrees.Common
BSCodeGen.RiscV.Lib.Monad
BuilderStateCodeGen.RiscV.Lib.Monad
CallCodeGen.RiscV.Lib.Types
callCodeGen.RiscV.Lib
ccAstTransformations.Cc.Cc
checkProgramTypeChecker.TypeChecker
choice'Parser.Utils
codeCodeGen.Module
CodeLineCodeGen.RiscV.Lib.Types, CodeGen.RiscV.Lib
colonParser.Lexer
CompAppTransformations.Anf.Anf
ComparisonOperatorTrees.Common
CompBinOpTransformations.Anf.Anf
compErrMsgCodeGen.RunResult
CompilationErrorCodeGen.RunResult
compileCodeGen.RiscV.Lib
compileTCodeGen.RiscV.Lib
compileToBinaryCodeGen.Llvm.Runner
compileToLlvmIrCodeGen.Llvm.Runner
compileToModuleCodeGen.Module
compileToRiscVAsmCodeGen.RiscV.Runner
CompIteTransformations.Anf.Anf
ComplexExpressionTransformations.Anf.Anf
CompOpTrees.Common
compTimeCodeGen.RunResult
CompUnOpTransformations.Anf.Anf
Declaration 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Parser.Ast
DeclarationWithArityStdLib
DeclFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
declIdTransformations.Simplifier.SimplifiedAst
declsStdLib
DeclVar 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
DirDataCodeGen.RiscV.Lib.Types
DirDWordCodeGen.RiscV.Lib.Types
DirectiveCodeGen.RiscV.Lib.Types
DirectiveCodeLineCodeGen.RiscV.Lib.Types
DirGloblCodeGen.RiscV.Lib.Types
DirTextCodeGen.RiscV.Lib.Types
DivOpTrees.Common
dwordCodeGen.RiscV.Lib.Types
emptyBSCodeGen.RiscV.Lib.Monad
emptyFBSCodeGen.RiscV.Lib.Monad
emptyPBSCodeGen.RiscV.Lib.Monad
eq 
1 (Function)CodeGen.RiscV.Lib
2 (Function)Parser.Lexer
EqOpTrees.Common
exitCodeCodeGen.RunResult
ExprApp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprAtomTransformations.Anf.Anf
ExprBinOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprCompTransformations.Anf.Anf
Expression 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Transformations.Ll.Lfr
3 (Type/Class)Transformations.Anf.Anf
4 (Type/Class)Parser.Ast
ExprFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
ExprId 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprIte 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprLetIn 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Transformations.Anf.Anf
4 (Data Constructor)Parser.Ast
ExprPrimVal 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprUnOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
externFunctionCodeGen.RiscV.Lib
FBSCodeGen.RiscV.Lib.Monad
ForallTypeChecker.HindleyMilner
freshTypeChecker.HindleyMilner
Fun 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Parser.Ast
4 (Data Constructor)Parser.Ast
functionCodeGen.RiscV.Lib
functionBSCodeGen.RiscV.Lib.Monad
FunctionBuilderStateCodeGen.RiscV.Lib.Monad
functionCodeLinesCodeGen.RiscV.Lib.Monad
geCodeGen.RiscV.Lib
GenTrees.Common
genAnfTransformations.Anf.AnfGen
generalizeTypeChecker.HindleyMilner
genLlvmIrModuleCodeGen.Llvm.LlvmIrGen
GeOpTrees.Common
getAsmBuilderStateCodeGen.RiscV.Lib.Monad
GlobalDeclaration 
1 (Type/Class)Transformations.Ll.Lfr
2 (Type/Class)Transformations.Anf.Anf
globalVarCodeGen.RiscV.Lib
GlobFunDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GlobVarDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GpCodeGen.RiscV.Lib.Types
gtCodeGen.RiscV.Lib
GtOpTrees.Common
IdCntTrees.Common
idCntCodeGen.RiscV.Lib.Monad
IdentifierTrees.Common
Identifier'Trees.Common
identifierPParser.Lexer
ImmediateCodeGen.RiscV.Lib.Types
immediateCodeGen.RiscV.Lib
ImpossibleBinOpApplicationTypeChecker.HindleyMilner
ImpossibleUnOpApplicationTypeChecker.HindleyMilner
InferTypeChecker.HindleyMilner
inferProgramTypeChecker.TypeChecker
InfiniteTypeChecker.HindleyMilner
Instruction 
1 (Type/Class)CodeGen.RiscV.Lib.Types
2 (Data Constructor)CodeGen.RiscV.Lib.Types
InstructionCodeLineCodeGen.RiscV.Lib.Types
intLitPParser.Lexer
IsRecTrees.Common
iteCodeGen.RiscV.Lib
JCodeGen.RiscV.Lib.Types
kwBoolParser.Lexer
kwElseParser.Lexer
kwFunParser.Lexer
kwIfParser.Lexer
kwInParser.Lexer
kwIntParser.Lexer
kwLetParser.Lexer
kwRecParser.Lexer
kwThenParser.Lexer
kwUnitParser.Lexer
LaCodeGen.RiscV.Lib.Types
Label 
1 (Type/Class)CodeGen.RiscV.Lib.Types
2 (Data Constructor)CodeGen.RiscV.Lib.Types
LabelCodeLineCodeGen.RiscV.Lib.Types
LabeledDirectiveCodeLineCodeGen.RiscV.Lib.Types
LdCodeGen.RiscV.Lib.Types
leCodeGen.RiscV.Lib
leftParParser.Lexer
LeOpTrees.Common
lexemeParser.Lexer
LiCodeGen.RiscV.Lib.Types
liftM1'MonadUtils
liftM2'MonadUtils
liftM3'MonadUtils
llAstTransformations.Ll.Ll
locallyMonadUtils
lookupTypeChecker.HindleyMilner
ltCodeGen.RiscV.Lib
LtOpTrees.Common
mainFunctionCodeGen.RiscV.Lib
manyParensParser.Utils
measureTimeCodeGen.TimedValue
measureTimedValueCodeGen.TimedValue
MemoryCodeGen.RiscV.Lib.Types
MinusOpTrees.Common
MismatchTypeChecker.HindleyMilner
mkVarNameTypeChecker.HindleyMilner
modifyAsmBuilderStateCodeGen.RiscV.Lib.Monad
Module 
1 (Type/Class)CodeGen.Module
2 (Data Constructor)CodeGen.Module
MonadAsmBuilderCodeGen.RiscV.Lib.Monad
MulCodeGen.RiscV.Lib.Types
mulCodeGen.RiscV.Lib
MulOpTrees.Common
Nanoseconds 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
neCodeGen.RiscV.Lib
NegCodeGen.RiscV.Lib.Types
negCodeGen.RiscV.Lib
NeOpTrees.Common
OffsetCodeGen.RiscV.Lib.Types
OpCodeCodeGen.RiscV.Lib.Types
OperandCodeGen.RiscV.Lib.Types, CodeGen.RiscV.Lib
optional'Parser.Utils
OrCodeGen.RiscV.Lib.Types
orCodeGen.RiscV.Lib
OrOpTrees.Common
parensParser.Utils
parseProgramParser.Parser
ParserParser.Lexer
PBSCodeGen.RiscV.Lib.Monad
PlusOpTrees.Common
PolyTypeChecker.HindleyMilner
PolytypeTypeChecker.HindleyMilner
ppCodeLinesCodeGen.RiscV.Lib.Types, CodeGen.RiscV.Lib
ppLlvmModuleCodeGen.Llvm.LlvmIrGen
ppRiscVAsmCodeGen.RiscV.AsmGen
prettyTypeChecker.PrettyPrinter
prettyPrintTransformations.Anf.PrettyPrinter
PrimitiveValueTrees.Common
PrimValBoolTrees.Common
PrimValIntTrees.Common
PrimValUnitTrees.Common
printCRuntimeCodeGen.Runtime.PrintRuntime
Program 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Transformations.Ll.Lfr
4 (Data Constructor)Transformations.Ll.Lfr
5 (Type/Class)Transformations.Anf.Anf
6 (Data Constructor)Transformations.Anf.Anf
7 (Type/Class)Parser.Ast
8 (Data Constructor)Parser.Ast
programBSCodeGen.RiscV.Lib.Monad
ProgramBuilderStateCodeGen.RiscV.Lib.Monad
RaCodeGen.RiscV.Lib.Types
Register 
1 (Type/Class)CodeGen.RiscV.Lib.Types
2 (Data Constructor)CodeGen.RiscV.Lib.Types
RegisterWithOffsetCodeGen.RiscV.Lib.Types
relabelAstTransformations.Relabeler.Relabeler
RetCodeGen.RiscV.Lib.Types
rightParParser.Lexer
runCodeGen.Llvm.Runner
RunResultCodeGen.RunResult
runTimeCodeGen.RunResult
RuntimeErrorCodeGen.RunResult
S0CodeGen.RiscV.Lib.Types
S1CodeGen.RiscV.Lib.Types
S10CodeGen.RiscV.Lib.Types
S11CodeGen.RiscV.Lib.Types
S2CodeGen.RiscV.Lib.Types
S3CodeGen.RiscV.Lib.Types
S4CodeGen.RiscV.Lib.Types
S5CodeGen.RiscV.Lib.Types
S6CodeGen.RiscV.Lib.Types
S7CodeGen.RiscV.Lib.Types
S8CodeGen.RiscV.Lib.Types
S9CodeGen.RiscV.Lib.Types
scParser.Lexer
SdCodeGen.RiscV.Lib.Types
sectionDataCodeGen.RiscV.Lib.Monad
sectionTextCodeGen.RiscV.Lib.Monad
semicolon2Parser.Lexer
SeqzCodeGen.RiscV.Lib.Types
simplifyAstTransformations.Simplifier.Simplifier
SltCodeGen.RiscV.Lib.Types
SnezCodeGen.RiscV.Lib.Types
someParensParser.Utils
SpCodeGen.RiscV.Lib.Types
stackPointerOffsetCodeGen.RiscV.Lib.Monad
StatementParser.Ast
stderrCodeGen.RunResult
stdoutCodeGen.RunResult
StmtDeclParser.Ast
StmtExprParser.Ast
storeToLabeledAddrCodeGen.RiscV.Lib
SubCodeGen.RiscV.Lib.Types
subCodeGen.RiscV.Lib
SuccessCodeGen.RunResult
SymbolCodeGen.RiscV.Lib.Types
symbolParser.Lexer
T0CodeGen.RiscV.Lib.Types
T1CodeGen.RiscV.Lib.Types
T2CodeGen.RiscV.Lib.Types
T3CodeGen.RiscV.Lib.Types
T4CodeGen.RiscV.Lib.Types
T5CodeGen.RiscV.Lib.Types
T6CodeGen.RiscV.Lib.Types
TBoolTrees.Common
TBoolFTypeChecker.HindleyMilner
TFunTrees.Common
TFunFTypeChecker.HindleyMilner
timeCodeGen.TimedValue
TimedValue 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
TIntTrees.Common
TIntFTypeChecker.HindleyMilner
toPolytypeTypeChecker.HindleyMilner
toUTypeTypeChecker.HindleyMilner
TpCodeGen.RiscV.Lib.Types
TUnitTrees.Common
TUnitFTypeChecker.HindleyMilner
TVarFTypeChecker.HindleyMilner
TxtTrees.Common
TypeTrees.Common
TypedDeclarationStdLib
typedDeclsStdLib
TypeErrorTypeChecker.HindleyMilner
TypeFTypeChecker.HindleyMilner
UnaryOperatorTrees.Common
unAsmBuilderTCodeGen.RiscV.Lib.Monad
UnboundVarTypeChecker.HindleyMilner
unitLitPParser.Lexer
UnMinusOpTrees.Common
UnreachableTypeChecker.HindleyMilner
UTBoolTypeChecker.HindleyMilner
UTermTypeChecker.HindleyMilner
UTFunTypeChecker.HindleyMilner
UTIntTypeChecker.HindleyMilner
UTUnitTypeChecker.HindleyMilner
UTVarTypeChecker.HindleyMilner
UTypeTypeChecker.HindleyMilner
valueCodeGen.TimedValue
VarDeclTransformations.Ll.Lfr
VarDeclarationTransformations.Ll.Lfr
withBindingTypeChecker.HindleyMilner
ZeroCodeGen.RiscV.Lib.Types
\ No newline at end of file diff --git a/doc-index-B.html b/doc-index-B.html index d3d1ce0..3ee4c0d 100644 --- a/doc-index-B.html +++ b/doc-index-B.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - B)
mini-ml-0.1.0.0: MiniML compiler

Index - B

BinaryOperatorTrees.Common
BooleanOperatorTrees.Common
boolLitPParser.Lexer
BoolOpTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - B)
mini-ml-0.1.0.0: MiniML compiler

Index - B

BeqzCodeGen.RiscV.Lib.Types
BinaryOperatorTrees.Common
BooleanOperatorTrees.Common
boolLitPParser.Lexer
BoolOpTrees.Common
BSCodeGen.RiscV.Lib.Monad
BuilderStateCodeGen.RiscV.Lib.Monad
\ No newline at end of file diff --git a/doc-index-C.html b/doc-index-C.html index 738ab58..67449a6 100644 --- a/doc-index-C.html +++ b/doc-index-C.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - C)
mini-ml-0.1.0.0: MiniML compiler

Index - C

ccAstTransformations.Cc.Cc
checkProgramTypeChecker.TypeChecker
choice'Parser.Utils
codeCodeGen.Module
colonParser.Lexer
CompAppTransformations.Anf.Anf
ComparisonOperatorTrees.Common
CompBinOpTransformations.Anf.Anf
compErrMsgCodeGen.RunResult
CompilationErrorCodeGen.RunResult
compileToBinaryCodeGen.Llvm.Runner
compileToLlvmIrCodeGen.Llvm.Runner
compileToModuleCodeGen.Module
CompIteTransformations.Anf.Anf
ComplexExpressionTransformations.Anf.Anf
CompOpTrees.Common
compTimeCodeGen.RunResult
CompUnOpTransformations.Anf.Anf
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - C)
mini-ml-0.1.0.0: MiniML compiler

Index - C

CallCodeGen.RiscV.Lib.Types
callCodeGen.RiscV.Lib
ccAstTransformations.Cc.Cc
checkProgramTypeChecker.TypeChecker
choice'Parser.Utils
codeCodeGen.Module
CodeLineCodeGen.RiscV.Lib.Types, CodeGen.RiscV.Lib
colonParser.Lexer
CompAppTransformations.Anf.Anf
ComparisonOperatorTrees.Common
CompBinOpTransformations.Anf.Anf
compErrMsgCodeGen.RunResult
CompilationErrorCodeGen.RunResult
compileCodeGen.RiscV.Lib
compileTCodeGen.RiscV.Lib
compileToBinaryCodeGen.Llvm.Runner
compileToLlvmIrCodeGen.Llvm.Runner
compileToModuleCodeGen.Module
compileToRiscVAsmCodeGen.RiscV.Runner
CompIteTransformations.Anf.Anf
ComplexExpressionTransformations.Anf.Anf
CompOpTrees.Common
compTimeCodeGen.RunResult
CompUnOpTransformations.Anf.Anf
\ No newline at end of file diff --git a/doc-index-D.html b/doc-index-D.html index 9525977..a0d397c 100644 --- a/doc-index-D.html +++ b/doc-index-D.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - D)
mini-ml-0.1.0.0: MiniML compiler

Index - D

Declaration 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Parser.Ast
DeclarationWithArityStdLib
DeclFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
declIdTransformations.Simplifier.SimplifiedAst
declsStdLib
DeclVar 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
DivOpTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - D)
mini-ml-0.1.0.0: MiniML compiler

Index - D

Declaration 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Parser.Ast
DeclarationWithArityStdLib
DeclFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
declIdTransformations.Simplifier.SimplifiedAst
declsStdLib
DeclVar 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
DirDataCodeGen.RiscV.Lib.Types
DirDWordCodeGen.RiscV.Lib.Types
DirectiveCodeGen.RiscV.Lib.Types
DirectiveCodeLineCodeGen.RiscV.Lib.Types
DirGloblCodeGen.RiscV.Lib.Types
DirTextCodeGen.RiscV.Lib.Types
DivOpTrees.Common
dwordCodeGen.RiscV.Lib.Types
\ No newline at end of file diff --git a/doc-index-E.html b/doc-index-E.html index d241662..bc9a3cd 100644 --- a/doc-index-E.html +++ b/doc-index-E.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - E)
mini-ml-0.1.0.0: MiniML compiler

Index - E

eqParser.Lexer
EqOpTrees.Common
exitCodeCodeGen.RunResult
ExprApp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprAtomTransformations.Anf.Anf
ExprBinOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprCompTransformations.Anf.Anf
Expression 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Transformations.Ll.Lfr
3 (Type/Class)Transformations.Anf.Anf
4 (Type/Class)Parser.Ast
ExprFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
ExprId 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprIte 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprLetIn 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Transformations.Anf.Anf
4 (Data Constructor)Parser.Ast
ExprPrimVal 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprUnOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - E)
mini-ml-0.1.0.0: MiniML compiler

Index - E

emptyBSCodeGen.RiscV.Lib.Monad
emptyFBSCodeGen.RiscV.Lib.Monad
emptyPBSCodeGen.RiscV.Lib.Monad
eq 
1 (Function)CodeGen.RiscV.Lib
2 (Function)Parser.Lexer
EqOpTrees.Common
exitCodeCodeGen.RunResult
ExprApp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprAtomTransformations.Anf.Anf
ExprBinOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprCompTransformations.Anf.Anf
Expression 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Type/Class)Transformations.Ll.Lfr
3 (Type/Class)Transformations.Anf.Anf
4 (Type/Class)Parser.Ast
ExprFun 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Parser.Ast
ExprId 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprIte 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprLetIn 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Transformations.Anf.Anf
4 (Data Constructor)Parser.Ast
ExprPrimVal 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
ExprUnOp 
1 (Data Constructor)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Ll.Lfr
3 (Data Constructor)Parser.Ast
externFunctionCodeGen.RiscV.Lib
\ No newline at end of file diff --git a/doc-index-F.html b/doc-index-F.html index f002981..38f26dc 100644 --- a/doc-index-F.html +++ b/doc-index-F.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - F)
mini-ml-0.1.0.0: MiniML compiler

Index - F

ForallTypeChecker.HindleyMilner
freshTypeChecker.HindleyMilner
Fun 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Parser.Ast
4 (Data Constructor)Parser.Ast
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - F)
mini-ml-0.1.0.0: MiniML compiler

Index - F

FBSCodeGen.RiscV.Lib.Monad
ForallTypeChecker.HindleyMilner
freshTypeChecker.HindleyMilner
Fun 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Parser.Ast
4 (Data Constructor)Parser.Ast
functionCodeGen.RiscV.Lib
functionBSCodeGen.RiscV.Lib.Monad
FunctionBuilderStateCodeGen.RiscV.Lib.Monad
functionCodeLinesCodeGen.RiscV.Lib.Monad
\ No newline at end of file diff --git a/doc-index-G.html b/doc-index-G.html index 440255e..0482afb 100644 --- a/doc-index-G.html +++ b/doc-index-G.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - G)
mini-ml-0.1.0.0: MiniML compiler

Index - G

GenTrees.Common
genAnfTransformations.Anf.AnfGen
generalizeTypeChecker.HindleyMilner
genLlvmIrModuleCodeGen.Llvm.LlvmIrGen
GeOpTrees.Common
GlobalDeclaration 
1 (Type/Class)Transformations.Ll.Lfr
2 (Type/Class)Transformations.Anf.Anf
GlobFunDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GlobVarDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GtOpTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - G)
mini-ml-0.1.0.0: MiniML compiler

Index - G

geCodeGen.RiscV.Lib
GenTrees.Common
genAnfTransformations.Anf.AnfGen
generalizeTypeChecker.HindleyMilner
genLlvmIrModuleCodeGen.Llvm.LlvmIrGen
GeOpTrees.Common
getAsmBuilderStateCodeGen.RiscV.Lib.Monad
GlobalDeclaration 
1 (Type/Class)Transformations.Ll.Lfr
2 (Type/Class)Transformations.Anf.Anf
globalVarCodeGen.RiscV.Lib
GlobFunDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GlobVarDecl 
1 (Data Constructor)Transformations.Ll.Lfr
2 (Data Constructor)Transformations.Anf.Anf
GpCodeGen.RiscV.Lib.Types
gtCodeGen.RiscV.Lib
GtOpTrees.Common
\ No newline at end of file diff --git a/doc-index-I.html b/doc-index-I.html index 5a58d0d..f3e3c52 100644 --- a/doc-index-I.html +++ b/doc-index-I.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - I)
mini-ml-0.1.0.0: MiniML compiler

Index - I

IdCntTrees.Common
IdentifierTrees.Common
Identifier'Trees.Common
identifierPParser.Lexer
ImpossibleBinOpApplicationTypeChecker.HindleyMilner
ImpossibleUnOpApplicationTypeChecker.HindleyMilner
InferTypeChecker.HindleyMilner
inferProgramTypeChecker.TypeChecker
InfiniteTypeChecker.HindleyMilner
intLitPParser.Lexer
IsRecTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - I)
mini-ml-0.1.0.0: MiniML compiler

Index - I

IdCntTrees.Common
idCntCodeGen.RiscV.Lib.Monad
IdentifierTrees.Common
Identifier'Trees.Common
identifierPParser.Lexer
ImmediateCodeGen.RiscV.Lib.Types
immediateCodeGen.RiscV.Lib
ImpossibleBinOpApplicationTypeChecker.HindleyMilner
ImpossibleUnOpApplicationTypeChecker.HindleyMilner
InferTypeChecker.HindleyMilner
inferProgramTypeChecker.TypeChecker
InfiniteTypeChecker.HindleyMilner
Instruction 
1 (Type/Class)CodeGen.RiscV.Lib.Types
2 (Data Constructor)CodeGen.RiscV.Lib.Types
InstructionCodeLineCodeGen.RiscV.Lib.Types
intLitPParser.Lexer
IsRecTrees.Common
iteCodeGen.RiscV.Lib
\ No newline at end of file diff --git a/doc-index-J.html b/doc-index-J.html new file mode 100644 index 0000000..eb4a209 --- /dev/null +++ b/doc-index-J.html @@ -0,0 +1 @@ +mini-ml-0.1.0.0: MiniML compiler (Index - J)
mini-ml-0.1.0.0: MiniML compiler

Index - J

JCodeGen.RiscV.Lib.Types
\ No newline at end of file diff --git a/doc-index-K.html b/doc-index-K.html index 7ace68f..840779a 100644 --- a/doc-index-K.html +++ b/doc-index-K.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - K)
mini-ml-0.1.0.0: MiniML compiler

Index - K

kwBoolParser.Lexer
kwElseParser.Lexer
kwFunParser.Lexer
kwIfParser.Lexer
kwInParser.Lexer
kwIntParser.Lexer
kwLetParser.Lexer
kwRecParser.Lexer
kwThenParser.Lexer
kwUnitParser.Lexer
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - K)
mini-ml-0.1.0.0: MiniML compiler

Index - K

kwBoolParser.Lexer
kwElseParser.Lexer
kwFunParser.Lexer
kwIfParser.Lexer
kwInParser.Lexer
kwIntParser.Lexer
kwLetParser.Lexer
kwRecParser.Lexer
kwThenParser.Lexer
kwUnitParser.Lexer
\ No newline at end of file diff --git a/doc-index-L.html b/doc-index-L.html index 8f69f41..14061d6 100644 --- a/doc-index-L.html +++ b/doc-index-L.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - L)
mini-ml-0.1.0.0: MiniML compiler

Index - L

leftParParser.Lexer
LeOpTrees.Common
lexemeParser.Lexer
liftM1'MonadUtils
liftM2'MonadUtils
liftM3'MonadUtils
llAstTransformations.Ll.Ll
locallyMonadUtils
lookupTypeChecker.HindleyMilner
LtOpTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - L)
mini-ml-0.1.0.0: MiniML compiler

Index - L

LaCodeGen.RiscV.Lib.Types
Label 
1 (Type/Class)CodeGen.RiscV.Lib.Types
2 (Data Constructor)CodeGen.RiscV.Lib.Types
LabelCodeLineCodeGen.RiscV.Lib.Types
LabeledDirectiveCodeLineCodeGen.RiscV.Lib.Types
LdCodeGen.RiscV.Lib.Types
leCodeGen.RiscV.Lib
leftParParser.Lexer
LeOpTrees.Common
lexemeParser.Lexer
LiCodeGen.RiscV.Lib.Types
liftM1'MonadUtils
liftM2'MonadUtils
liftM3'MonadUtils
llAstTransformations.Ll.Ll
locallyMonadUtils
lookupTypeChecker.HindleyMilner
ltCodeGen.RiscV.Lib
LtOpTrees.Common
\ No newline at end of file diff --git a/doc-index-M.html b/doc-index-M.html index 6ee79e0..5d6ec8b 100644 --- a/doc-index-M.html +++ b/doc-index-M.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - M)
mini-ml-0.1.0.0: MiniML compiler

Index - M

manyParensParser.Utils
measureTimeCodeGen.TimedValue
measureTimedValueCodeGen.TimedValue
MinusOpTrees.Common
MismatchTypeChecker.HindleyMilner
mkVarNameTypeChecker.HindleyMilner
Module 
1 (Type/Class)CodeGen.Module
2 (Data Constructor)CodeGen.Module
MulOpTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - M)
mini-ml-0.1.0.0: MiniML compiler

Index - M

mainFunctionCodeGen.RiscV.Lib
manyParensParser.Utils
measureTimeCodeGen.TimedValue
measureTimedValueCodeGen.TimedValue
MemoryCodeGen.RiscV.Lib.Types
MinusOpTrees.Common
MismatchTypeChecker.HindleyMilner
mkVarNameTypeChecker.HindleyMilner
modifyAsmBuilderStateCodeGen.RiscV.Lib.Monad
Module 
1 (Type/Class)CodeGen.Module
2 (Data Constructor)CodeGen.Module
MonadAsmBuilderCodeGen.RiscV.Lib.Monad
MulCodeGen.RiscV.Lib.Types
mulCodeGen.RiscV.Lib
MulOpTrees.Common
\ No newline at end of file diff --git a/doc-index-N.html b/doc-index-N.html index 94be206..c8eef1b 100644 --- a/doc-index-N.html +++ b/doc-index-N.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - N)
mini-ml-0.1.0.0: MiniML compiler

Index - N

Nanoseconds 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
NeOpTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - N)
mini-ml-0.1.0.0: MiniML compiler

Index - N

Nanoseconds 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
neCodeGen.RiscV.Lib
NegCodeGen.RiscV.Lib.Types
negCodeGen.RiscV.Lib
NeOpTrees.Common
\ No newline at end of file diff --git a/doc-index-O.html b/doc-index-O.html index c745454..512012c 100644 --- a/doc-index-O.html +++ b/doc-index-O.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - O)
mini-ml-0.1.0.0: MiniML compiler

Index - O

optional'Parser.Utils
OrOpTrees.Common
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - O)
mini-ml-0.1.0.0: MiniML compiler

Index - O

OffsetCodeGen.RiscV.Lib.Types
OpCodeCodeGen.RiscV.Lib.Types
OperandCodeGen.RiscV.Lib.Types, CodeGen.RiscV.Lib
optional'Parser.Utils
OrCodeGen.RiscV.Lib.Types
orCodeGen.RiscV.Lib
OrOpTrees.Common
\ No newline at end of file diff --git a/doc-index-P.html b/doc-index-P.html index 657e1af..09970f8 100644 --- a/doc-index-P.html +++ b/doc-index-P.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - P)
mini-ml-0.1.0.0: MiniML compiler

Index - P

parensParser.Utils
parseProgramParser.Parser
ParserParser.Lexer
PlusOpTrees.Common
PolyTypeChecker.HindleyMilner
PolytypeTypeChecker.HindleyMilner
ppLlvmModuleCodeGen.Llvm.LlvmIrGen
prettyTypeChecker.PrettyPrinter
prettyPrintTransformations.Anf.PrettyPrinter
PrimitiveValueTrees.Common
PrimValBoolTrees.Common
PrimValIntTrees.Common
PrimValUnitTrees.Common
Program 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Transformations.Ll.Lfr
4 (Data Constructor)Transformations.Ll.Lfr
5 (Type/Class)Transformations.Anf.Anf
6 (Data Constructor)Transformations.Anf.Anf
7 (Type/Class)Parser.Ast
8 (Data Constructor)Parser.Ast
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - P)
mini-ml-0.1.0.0: MiniML compiler

Index - P

parensParser.Utils
parseProgramParser.Parser
ParserParser.Lexer
PBSCodeGen.RiscV.Lib.Monad
PlusOpTrees.Common
PolyTypeChecker.HindleyMilner
PolytypeTypeChecker.HindleyMilner
ppCodeLinesCodeGen.RiscV.Lib.Types, CodeGen.RiscV.Lib
ppLlvmModuleCodeGen.Llvm.LlvmIrGen
ppRiscVAsmCodeGen.RiscV.AsmGen
prettyTypeChecker.PrettyPrinter
prettyPrintTransformations.Anf.PrettyPrinter
PrimitiveValueTrees.Common
PrimValBoolTrees.Common
PrimValIntTrees.Common
PrimValUnitTrees.Common
printCRuntimeCodeGen.Runtime.PrintRuntime
Program 
1 (Type/Class)Transformations.Simplifier.SimplifiedAst
2 (Data Constructor)Transformations.Simplifier.SimplifiedAst
3 (Type/Class)Transformations.Ll.Lfr
4 (Data Constructor)Transformations.Ll.Lfr
5 (Type/Class)Transformations.Anf.Anf
6 (Data Constructor)Transformations.Anf.Anf
7 (Type/Class)Parser.Ast
8 (Data Constructor)Parser.Ast
programBSCodeGen.RiscV.Lib.Monad
ProgramBuilderStateCodeGen.RiscV.Lib.Monad
\ No newline at end of file diff --git a/doc-index-R.html b/doc-index-R.html index 4c7f82e..b20729a 100644 --- a/doc-index-R.html +++ b/doc-index-R.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - R)
mini-ml-0.1.0.0: MiniML compiler

Index - R

relabelAstTransformations.Relabeler.Relabeler
rightParParser.Lexer
runCodeGen.Llvm.Runner
RunResultCodeGen.RunResult
runTimeCodeGen.RunResult
RuntimeErrorCodeGen.RunResult
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - R)
mini-ml-0.1.0.0: MiniML compiler

Index - R

RaCodeGen.RiscV.Lib.Types
Register 
1 (Type/Class)CodeGen.RiscV.Lib.Types
2 (Data Constructor)CodeGen.RiscV.Lib.Types
RegisterWithOffsetCodeGen.RiscV.Lib.Types
relabelAstTransformations.Relabeler.Relabeler
RetCodeGen.RiscV.Lib.Types
rightParParser.Lexer
runCodeGen.Llvm.Runner
RunResultCodeGen.RunResult
runTimeCodeGen.RunResult
RuntimeErrorCodeGen.RunResult
\ No newline at end of file diff --git a/doc-index-S.html b/doc-index-S.html index 2b66f57..6002ac1 100644 --- a/doc-index-S.html +++ b/doc-index-S.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - S)
mini-ml-0.1.0.0: MiniML compiler

Index - S

scParser.Lexer
semicolon2Parser.Lexer
simplifyAstTransformations.Simplifier.Simplifier
someParensParser.Utils
StatementParser.Ast
stderrCodeGen.RunResult
stdoutCodeGen.RunResult
StmtDeclParser.Ast
StmtExprParser.Ast
SuccessCodeGen.RunResult
symbolParser.Lexer
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - S)
mini-ml-0.1.0.0: MiniML compiler

Index - S

S0CodeGen.RiscV.Lib.Types
S1CodeGen.RiscV.Lib.Types
S10CodeGen.RiscV.Lib.Types
S11CodeGen.RiscV.Lib.Types
S2CodeGen.RiscV.Lib.Types
S3CodeGen.RiscV.Lib.Types
S4CodeGen.RiscV.Lib.Types
S5CodeGen.RiscV.Lib.Types
S6CodeGen.RiscV.Lib.Types
S7CodeGen.RiscV.Lib.Types
S8CodeGen.RiscV.Lib.Types
S9CodeGen.RiscV.Lib.Types
scParser.Lexer
SdCodeGen.RiscV.Lib.Types
sectionDataCodeGen.RiscV.Lib.Monad
sectionTextCodeGen.RiscV.Lib.Monad
semicolon2Parser.Lexer
SeqzCodeGen.RiscV.Lib.Types
simplifyAstTransformations.Simplifier.Simplifier
SltCodeGen.RiscV.Lib.Types
SnezCodeGen.RiscV.Lib.Types
someParensParser.Utils
SpCodeGen.RiscV.Lib.Types
stackPointerOffsetCodeGen.RiscV.Lib.Monad
StatementParser.Ast
stderrCodeGen.RunResult
stdoutCodeGen.RunResult
StmtDeclParser.Ast
StmtExprParser.Ast
storeToLabeledAddrCodeGen.RiscV.Lib
SubCodeGen.RiscV.Lib.Types
subCodeGen.RiscV.Lib
SuccessCodeGen.RunResult
SymbolCodeGen.RiscV.Lib.Types
symbolParser.Lexer
\ No newline at end of file diff --git a/doc-index-T.html b/doc-index-T.html index 6254cf2..0c7de30 100644 --- a/doc-index-T.html +++ b/doc-index-T.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - T)
mini-ml-0.1.0.0: MiniML compiler

Index - T

TBoolTrees.Common
TBoolFTypeChecker.HindleyMilner
TFunTrees.Common
TFunFTypeChecker.HindleyMilner
timeCodeGen.TimedValue
TimedValue 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
TIntTrees.Common
TIntFTypeChecker.HindleyMilner
toPolytypeTypeChecker.HindleyMilner
toUTypeTypeChecker.HindleyMilner
TUnitTrees.Common
TUnitFTypeChecker.HindleyMilner
TVarFTypeChecker.HindleyMilner
TxtTrees.Common
TypeTrees.Common
TypedDeclarationStdLib
typedDeclsStdLib
TypeErrorTypeChecker.HindleyMilner
TypeFTypeChecker.HindleyMilner
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - T)
mini-ml-0.1.0.0: MiniML compiler

Index - T

T0CodeGen.RiscV.Lib.Types
T1CodeGen.RiscV.Lib.Types
T2CodeGen.RiscV.Lib.Types
T3CodeGen.RiscV.Lib.Types
T4CodeGen.RiscV.Lib.Types
T5CodeGen.RiscV.Lib.Types
T6CodeGen.RiscV.Lib.Types
TBoolTrees.Common
TBoolFTypeChecker.HindleyMilner
TFunTrees.Common
TFunFTypeChecker.HindleyMilner
timeCodeGen.TimedValue
TimedValue 
1 (Type/Class)CodeGen.TimedValue
2 (Data Constructor)CodeGen.TimedValue
TIntTrees.Common
TIntFTypeChecker.HindleyMilner
toPolytypeTypeChecker.HindleyMilner
toUTypeTypeChecker.HindleyMilner
TpCodeGen.RiscV.Lib.Types
TUnitTrees.Common
TUnitFTypeChecker.HindleyMilner
TVarFTypeChecker.HindleyMilner
TxtTrees.Common
TypeTrees.Common
TypedDeclarationStdLib
typedDeclsStdLib
TypeErrorTypeChecker.HindleyMilner
TypeFTypeChecker.HindleyMilner
\ No newline at end of file diff --git a/doc-index-U.html b/doc-index-U.html index abb87f4..116b347 100644 --- a/doc-index-U.html +++ b/doc-index-U.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - U)
mini-ml-0.1.0.0: MiniML compiler

Index - U

UnaryOperatorTrees.Common
UnboundVarTypeChecker.HindleyMilner
unitLitPParser.Lexer
UnMinusOpTrees.Common
UnreachableTypeChecker.HindleyMilner
UTBoolTypeChecker.HindleyMilner
UTermTypeChecker.HindleyMilner
UTFunTypeChecker.HindleyMilner
UTIntTypeChecker.HindleyMilner
UTUnitTypeChecker.HindleyMilner
UTVarTypeChecker.HindleyMilner
UTypeTypeChecker.HindleyMilner
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - U)
mini-ml-0.1.0.0: MiniML compiler

Index - U

UnaryOperatorTrees.Common
unAsmBuilderTCodeGen.RiscV.Lib.Monad
UnboundVarTypeChecker.HindleyMilner
unitLitPParser.Lexer
UnMinusOpTrees.Common
UnreachableTypeChecker.HindleyMilner
UTBoolTypeChecker.HindleyMilner
UTermTypeChecker.HindleyMilner
UTFunTypeChecker.HindleyMilner
UTIntTypeChecker.HindleyMilner
UTUnitTypeChecker.HindleyMilner
UTVarTypeChecker.HindleyMilner
UTypeTypeChecker.HindleyMilner
\ No newline at end of file diff --git a/doc-index-V.html b/doc-index-V.html index a17df26..b0641eb 100644 --- a/doc-index-V.html +++ b/doc-index-V.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - V)
mini-ml-0.1.0.0: MiniML compiler

Index - V

valueCodeGen.TimedValue
VarDeclTransformations.Ll.Lfr
VarDeclarationTransformations.Ll.Lfr
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - V)
mini-ml-0.1.0.0: MiniML compiler

Index - V

valueCodeGen.TimedValue
VarDeclTransformations.Ll.Lfr
VarDeclarationTransformations.Ll.Lfr
\ No newline at end of file diff --git a/doc-index-W.html b/doc-index-W.html index 66de623..59b6b1d 100644 --- a/doc-index-W.html +++ b/doc-index-W.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index - W)
mini-ml-0.1.0.0: MiniML compiler

Index - W

withBindingTypeChecker.HindleyMilner
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index - W)
mini-ml-0.1.0.0: MiniML compiler

Index - W

withBindingTypeChecker.HindleyMilner
\ No newline at end of file diff --git a/doc-index-Z.html b/doc-index-Z.html new file mode 100644 index 0000000..c042cb1 --- /dev/null +++ b/doc-index-Z.html @@ -0,0 +1 @@ +mini-ml-0.1.0.0: MiniML compiler (Index - Z)
mini-ml-0.1.0.0: MiniML compiler

Index - Z

ZeroCodeGen.RiscV.Lib.Types
\ No newline at end of file diff --git a/doc-index.html b/doc-index.html index 2ed8528..ddf43fb 100644 --- a/doc-index.html +++ b/doc-index.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler (Index)
mini-ml-0.1.0.0: MiniML compiler
\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler (Index)
mini-ml-0.1.0.0: MiniML compiler
\ No newline at end of file diff --git a/doc-index.json b/doc-index.json index f3a16eb..fac4f71 100644 --- a/doc-index.json +++ b/doc-index.json @@ -1 +1 @@ -[{"display_html":"data TimedValue a = TimedValue {}","name":"TimedValue value time TimedValue","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#t:TimedValue"},{"display_html":"newtype Nanoseconds = Nanoseconds Integer","name":"Nanoseconds Nanoseconds","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#t:Nanoseconds"},{"display_html":"measureTimedValue :: IO a -> IO (TimedValue a)","name":"measureTimedValue","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#v:measureTimedValue"},{"display_html":"measureTime :: IO () -> IO Nanoseconds","name":"measureTime","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#v:measureTime"},{"display_html":"data RunResult","name":"RunResult exitCode compErrMsg runTime compTime stderr stdout RuntimeError CompilationError Success","module":"CodeGen.RunResult","link":"CodeGen-RunResult.html#t:RunResult"},{"display_html":"liftM1' :: Monad m => (a' -> m a) -> (a -> b) -> a' -> m b","name":"liftM1'","module":"MonadUtils","link":"MonadUtils.html#v:liftM1-39-"},{"display_html":"liftM2' :: Monad m => (a' -> m a) -> (a -> a -> b) -> a' -> a' -> m b","name":"liftM2'","module":"MonadUtils","link":"MonadUtils.html#v:liftM2-39-"},{"display_html":"liftM3' :: Monad m => (a' -> m a) -> (a -> a -> a -> b) -> a' -> a' -> a' -> m b","name":"liftM3'","module":"MonadUtils","link":"MonadUtils.html#v:liftM3-39-"},{"display_html":"locally :: MonadState s m => m a -> m a","name":"locally","module":"MonadUtils","link":"MonadUtils.html#v:locally"},{"display_html":"type Identifier = Text","name":"Identifier","module":"Trees.Common","link":"Trees-Common.html#t:Identifier"},{"display_html":"data Identifier'","name":"Identifier' Gen Txt","module":"Trees.Common","link":"Trees-Common.html#t:Identifier-39-"},{"display_html":"type IdCnt = Int","name":"IdCnt","module":"Trees.Common","link":"Trees-Common.html#t:IdCnt"},{"display_html":"data BinaryOperator","name":"BinaryOperator CompOp ArithOp BoolOp","module":"Trees.Common","link":"Trees-Common.html#t:BinaryOperator"},{"display_html":"data UnaryOperator = UnMinusOp","name":"UnaryOperator UnMinusOp","module":"Trees.Common","link":"Trees-Common.html#t:UnaryOperator"},{"display_html":"data BooleanOperator","name":"BooleanOperator OrOp AndOp","module":"Trees.Common","link":"Trees-Common.html#t:BooleanOperator"},{"display_html":"data ArithmeticOperator","name":"ArithmeticOperator DivOp MulOp MinusOp PlusOp","module":"Trees.Common","link":"Trees-Common.html#t:ArithmeticOperator"},{"display_html":"data ComparisonOperator","name":"ComparisonOperator GeOp GtOp LeOp LtOp NeOp EqOp","module":"Trees.Common","link":"Trees-Common.html#t:ComparisonOperator"},{"display_html":"type IsRec = Bool","name":"IsRec","module":"Trees.Common","link":"Trees-Common.html#t:IsRec"},{"display_html":"data Type","name":"Type TFun TInt TBool TUnit","module":"Trees.Common","link":"Trees-Common.html#t:Type"},{"display_html":"type Arity = Int","name":"Arity","module":"Trees.Common","link":"Trees-Common.html#t:Arity"},{"display_html":"data PrimitiveValue","name":"PrimitiveValue PrimValInt PrimValBool PrimValUnit","module":"Trees.Common","link":"Trees-Common.html#t:PrimitiveValue"},{"display_html":"data Program = Program [Declaration] IdCnt","name":"Program Program","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Program"},{"display_html":"data Declaration","name":"Declaration DeclFun DeclVar","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Declaration"},{"display_html":"declId :: Declaration -> Identifier'","name":"declId","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#v:declId"},{"display_html":"data Expression","name":"Expression ExprFun ExprLetIn ExprIte ExprApp ExprUnOp ExprBinOp ExprPrimVal ExprId","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Expression"},{"display_html":"data Fun = Fun (NonEmpty Identifier') Expression","name":"Fun Fun","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Fun"},{"display_html":"relabelAst :: Program -> Program","name":"relabelAst","module":"Transformations.Relabeler.Relabeler","link":"Transformations-Relabeler-Relabeler.html#v:relabelAst"},{"display_html":"data Program = Program [GlobalDeclaration] IdCnt","name":"Program Program","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:Program"},{"display_html":"data GlobalDeclaration","name":"GlobalDeclaration GlobFunDecl GlobVarDecl","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:GlobalDeclaration"},{"display_html":"data VarDeclaration = VarDecl Identifier' Expression","name":"VarDeclaration VarDecl","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:VarDeclaration"},{"display_html":"data Expression","name":"Expression ExprLetIn ExprIte ExprApp ExprUnOp ExprBinOp ExprPrimVal ExprId","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:Expression"},{"display_html":"llAst :: Program -> Program","name":"llAst","module":"Transformations.Ll.Ll","link":"Transformations-Ll-Ll.html#v:llAst"},{"display_html":"newtype Program = Program [GlobalDeclaration]","name":"Program Program","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:Program"},{"display_html":"data GlobalDeclaration","name":"GlobalDeclaration GlobFunDecl GlobVarDecl","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:GlobalDeclaration"},{"display_html":"data Expression","name":"Expression ExprComp ExprAtom ExprLetIn","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:Expression"},{"display_html":"data AtomicExpression","name":"AtomicExpression AtomInt AtomBool AtomUnit AtomId","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:AtomicExpression"},{"display_html":"data ComplexExpression","name":"ComplexExpression CompUnOp CompBinOp CompIte CompApp","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:ComplexExpression"},{"display_html":"prettyPrint :: Program -> String","name":"prettyPrint","module":"Transformations.Anf.PrettyPrinter","link":"Transformations-Anf-PrettyPrinter.html#v:prettyPrint"},{"display_html":"genAnf :: Program -> Program","name":"genAnf","module":"Transformations.Anf.AnfGen","link":"Transformations-Anf-AnfGen.html#v:genAnf"},{"display_html":"type TypedDeclaration = (Identifier, Type)","name":"TypedDeclaration","module":"StdLib","link":"StdLib.html#t:TypedDeclaration"},{"display_html":"typedDecls :: [TypedDeclaration]","name":"typedDecls","module":"StdLib","link":"StdLib.html#v:typedDecls"},{"display_html":"decls :: [Identifier]","name":"decls","module":"StdLib","link":"StdLib.html#v:decls"},{"display_html":"type DeclarationWithArity = (Identifier, Arity)","name":"DeclarationWithArity","module":"StdLib","link":"StdLib.html#t:DeclarationWithArity"},{"display_html":"allDeclsWithArity :: [DeclarationWithArity]","name":"allDeclsWithArity","module":"StdLib","link":"StdLib.html#v:allDeclsWithArity"},{"display_html":"ccAst :: Program -> Program","name":"ccAst","module":"Transformations.Cc.Cc","link":"Transformations-Cc-Cc.html#v:ccAst"},{"display_html":"type Parser = Parsec Void Text","name":"Parser","module":"Parser.Lexer","link":"Parser-Lexer.html#t:Parser"},{"display_html":"sc :: Parser ()","name":"sc","module":"Parser.Lexer","link":"Parser-Lexer.html#v:sc"},{"display_html":"lexeme :: Parser a -> Parser a","name":"lexeme","module":"Parser.Lexer","link":"Parser-Lexer.html#v:lexeme"},{"display_html":"symbol :: Text -> Parser Text","name":"symbol","module":"Parser.Lexer","link":"Parser-Lexer.html#v:symbol"},{"display_html":"colon :: Parser Text","name":"colon","module":"Parser.Lexer","link":"Parser-Lexer.html#v:colon"},{"display_html":"semicolon2 :: Parser Text","name":"semicolon2","module":"Parser.Lexer","link":"Parser-Lexer.html#v:semicolon2"},{"display_html":"arrow :: Parser Text","name":"arrow","module":"Parser.Lexer","link":"Parser-Lexer.html#v:arrow"},{"display_html":"eq :: Parser Text","name":"eq","module":"Parser.Lexer","link":"Parser-Lexer.html#v:eq"},{"display_html":"leftPar :: Parser Text","name":"leftPar","module":"Parser.Lexer","link":"Parser-Lexer.html#v:leftPar"},{"display_html":"rightPar :: Parser Text","name":"rightPar","module":"Parser.Lexer","link":"Parser-Lexer.html#v:rightPar"},{"display_html":"unitLitP :: Parser Text","name":"unitLitP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:unitLitP"},{"display_html":"boolLitP :: Parser Bool","name":"boolLitP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:boolLitP"},{"display_html":"intLitP :: Parser Int64","name":"intLitP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:intLitP"},{"display_html":"identifierP :: Parser Identifier","name":"identifierP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:identifierP"},{"display_html":"kwLet :: Parser Text","name":"kwLet","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwLet"},{"display_html":"kwRec :: Parser Text","name":"kwRec","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwRec"},{"display_html":"kwIn :: Parser Text","name":"kwIn","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwIn"},{"display_html":"kwIf :: Parser Text","name":"kwIf","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwIf"},{"display_html":"kwThen :: Parser Text","name":"kwThen","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwThen"},{"display_html":"kwElse :: Parser Text","name":"kwElse","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwElse"},{"display_html":"kwFun :: Parser Text","name":"kwFun","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwFun"},{"display_html":"kwUnit :: Parser Text","name":"kwUnit","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwUnit"},{"display_html":"kwBool :: Parser Text","name":"kwBool","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwBool"},{"display_html":"kwInt :: Parser Text","name":"kwInt","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwInt"},{"display_html":"choice' :: (Foldable f, Functor f) => f (Parser a) -> Parser a","name":"choice'","module":"Parser.Utils","link":"Parser-Utils.html#v:choice-39-"},{"display_html":"optional' :: Parser a -> Parser (Maybe a)","name":"optional'","module":"Parser.Utils","link":"Parser-Utils.html#v:optional-39-"},{"display_html":"parens :: Parser a -> Parser a","name":"parens","module":"Parser.Utils","link":"Parser-Utils.html#v:parens"},{"display_html":"manyParens :: Parser a -> Parser a","name":"manyParens","module":"Parser.Utils","link":"Parser-Utils.html#v:manyParens"},{"display_html":"someParens :: Parser a -> Parser a","name":"someParens","module":"Parser.Utils","link":"Parser-Utils.html#v:someParens"},{"display_html":"newtype Program = Program [Statement]","name":"Program Program","module":"Parser.Ast","link":"Parser-Ast.html#t:Program"},{"display_html":"data Statement","name":"Statement StmtExpr StmtDecl","module":"Parser.Ast","link":"Parser-Ast.html#t:Statement"},{"display_html":"data Declaration","name":"Declaration DeclFun DeclVar","module":"Parser.Ast","link":"Parser-Ast.html#t:Declaration"},{"display_html":"data Expression","name":"Expression ExprFun ExprLetIn ExprIte ExprApp ExprUnOp ExprBinOp ExprPrimVal ExprId","module":"Parser.Ast","link":"Parser-Ast.html#t:Expression"},{"display_html":"data Fun = Fun (NonEmpty (Identifier, Maybe Type)) (Maybe Type) Expression","name":"Fun Fun","module":"Parser.Ast","link":"Parser-Ast.html#t:Fun"},{"display_html":"simplifyAst :: Program -> Program","name":"simplifyAst","module":"Transformations.Simplifier.Simplifier","link":"Transformations-Simplifier-Simplifier.html#v:simplifyAst"},{"display_html":"parseProgram :: Text -> Maybe Program","name":"parseProgram","module":"Parser.Parser","link":"Parser-Parser.html#v:parseProgram"},{"display_html":"data TypeF a","name":"TypeF TVarF TUnitF TBoolF TIntF TFunF","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:TypeF"},{"display_html":"type UType = UTerm TypeF IntVar","name":"UType","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UType"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data Poly t = Forall [Identifier] t","name":"Poly Forall","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:Poly"},{"display_html":"type Polytype = Poly Type","name":"Polytype","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:Polytype"},{"display_html":"toUType :: Type -> UType","name":"toUType","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:toUType"},{"display_html":"toPolytype :: UPolytype -> Polytype","name":"toPolytype","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:toPolytype"},{"display_html":"type Infer = ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity))","name":"Infer","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:Infer"},{"display_html":"lookup :: Identifier -> Infer UType","name":"lookup","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:lookup"},{"display_html":"withBinding :: MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a","name":"withBinding","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:withBinding"},{"display_html":"fresh :: Infer UType","name":"fresh","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:fresh"},{"display_html":"data TypeError where","name":"TypeError UnboundVar Unreachable Infinite ImpossibleBinOpApplication ImpossibleUnOpApplication Mismatch","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:TypeError"},{"display_html":"(=:=) :: UType -> UType -> Infer UType","name":"=:=","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:-61-:-61-"},{"display_html":"applyBindings :: UType -> Infer UType","name":"applyBindings","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:applyBindings"},{"display_html":"mkVarName :: String -> IntVar -> Identifier","name":"mkVarName","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:mkVarName"},{"display_html":"generalize :: UType -> Infer UPolytype","name":"generalize","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:generalize"},{"display_html":"checkProgram :: Program -> Either TypeError ()","name":"checkProgram","module":"TypeChecker.TypeChecker","link":"TypeChecker-TypeChecker.html#v:checkProgram"},{"display_html":"inferProgram :: Program -> Either TypeError Polytype","name":"inferProgram","module":"TypeChecker.TypeChecker","link":"TypeChecker-TypeChecker.html#v:inferProgram"},{"display_html":"newtype Module = Module {}","name":"Module Module code","module":"CodeGen.Module","link":"CodeGen-Module.html#t:Module"},{"display_html":"compileToModule :: Text -> Except Text Module","name":"compileToModule","module":"CodeGen.Module","link":"CodeGen-Module.html#v:compileToModule"},{"display_html":"genLlvmIrModule :: Module -> Module","name":"genLlvmIrModule","module":"CodeGen.Llvm.LlvmIrGen","link":"CodeGen-Llvm-LlvmIrGen.html#v:genLlvmIrModule"},{"display_html":"ppLlvmModule :: Module -> Text","name":"ppLlvmModule","module":"CodeGen.Llvm.LlvmIrGen","link":"CodeGen-Llvm-LlvmIrGen.html#v:ppLlvmModule"},{"display_html":"run :: Text -> IO RunResult","name":"run","module":"CodeGen.Llvm.Runner","link":"CodeGen-Llvm-Runner.html#v:run"},{"display_html":"compileToBinary :: Text -> FilePath -> IO (TimedValue (Either Text ()))","name":"compileToBinary","module":"CodeGen.Llvm.Runner","link":"CodeGen-Llvm-Runner.html#v:compileToBinary"},{"display_html":"compileToLlvmIr :: Text -> FilePath -> IO (TimedValue (Either Text ()))","name":"compileToLlvmIr","module":"CodeGen.Llvm.Runner","link":"CodeGen-Llvm-Runner.html#v:compileToLlvmIr"}] \ No newline at end of file +[{"display_html":"ppCodeLines :: [CodeLine] -> Text","name":"ppCodeLines","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#v:ppCodeLines"},{"display_html":"data CodeLine","name":"CodeLine DirectiveCodeLine InstructionCodeLine LabelCodeLine LabeledDirectiveCodeLine","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:CodeLine"},{"display_html":"newtype Label = Label Text","name":"Label Label","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:Label"},{"display_html":"data Instruction = Instruction OpCode [Operand]","name":"Instruction Instruction","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:Instruction"},{"display_html":"data Directive","name":"Directive DirGlobl DirDWord DirData DirText","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:Directive"},{"display_html":"data OpCode","name":"OpCode J Beqz Addi La Li Ld Sd Slt Snez Seqz Neg Ret Call Or Sub Mul Add And","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:OpCode"},{"display_html":"data Operand","name":"Operand RegisterWithOffset Register Immediate Symbol","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:Operand"},{"display_html":"pattern Memory :: Offset -> Operand","name":"Memory","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#v:Memory"},{"display_html":"type Offset = Int64","name":"Offset","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:Offset"},{"display_html":"data Register","name":"Register T6 T5 T4 T3 S11 S10 S9 S8 S7 S6 S5 S4 S3 S2 A7 A6 A5 A4 A3 A2 A1 A0 S0 T2 T1 T0 Tp Gp Ra Sp Zero S1","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#t:Register"},{"display_html":"dword :: Int64","name":"dword","module":"CodeGen.RiscV.Lib.Types","link":"CodeGen-RiscV-Lib-Types.html#v:dword"},{"display_html":"newtype AsmBuilderT m a = AsmBuilderT {}","name":"AsmBuilderT unAsmBuilderT AsmBuilderT","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#t:AsmBuilderT"},{"display_html":"data BuilderState = BS {}","name":"BuilderState idCnt functionBS programBS BS","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#t:BuilderState"},{"display_html":"data ProgramBuilderState = PBS {}","name":"ProgramBuilderState sectionData sectionText PBS","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#t:ProgramBuilderState"},{"display_html":"data FunctionBuilderState = FBS {}","name":"FunctionBuilderState stackPointerOffset functionCodeLines FBS","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#t:FunctionBuilderState"},{"display_html":"emptyBS :: BuilderState","name":"emptyBS","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#v:emptyBS"},{"display_html":"emptyPBS :: ProgramBuilderState","name":"emptyPBS","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#v:emptyPBS"},{"display_html":"emptyFBS :: FunctionBuilderState","name":"emptyFBS","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#v:emptyFBS"},{"display_html":"type AsmBuilder = AsmBuilderT Identity","name":"AsmBuilder","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#t:AsmBuilder"},{"display_html":"class Monad m => MonadAsmBuilder m where","name":"MonadAsmBuilder modifyAsmBuilderState getAsmBuilderState","module":"CodeGen.RiscV.Lib.Monad","link":"CodeGen-RiscV-Lib-Monad.html#t:MonadAsmBuilder"},{"display_html":"compileT :: Monad m => AsmBuilderT m a -> m [CodeLine]","name":"compileT","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:compileT"},{"display_html":"compile :: AsmBuilder a -> [CodeLine]","name":"compile","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:compile"},{"display_html":"mainFunction :: MonadAsmBuilder m => (() -> m ()) -> m ()","name":"mainFunction","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:mainFunction"},{"display_html":"function :: MonadAsmBuilder m => Text -> Int64 -> ([Operand] -> m Operand) -> m Operand","name":"function","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:function"},{"display_html":"globalVar :: MonadAsmBuilder m => Text -> m Operand","name":"globalVar","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:globalVar"},{"display_html":"externFunction :: MonadAsmBuilder m => Text -> m Operand","name":"externFunction","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:externFunction"},{"display_html":"storeToLabeledAddr :: MonadAsmBuilder m => Operand -> Operand -> m ()","name":"storeToLabeledAddr","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:storeToLabeledAddr"},{"display_html":"immediate :: MonadAsmBuilder m => Int64 -> m Operand","name":"immediate","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:immediate"},{"display_html":"and :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"and","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:and"},{"display_html":"or :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"or","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:or"},{"display_html":"add :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"add","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:add"},{"display_html":"sub :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"sub","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:sub"},{"display_html":"mul :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"mul","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:mul"},{"display_html":"neg :: MonadAsmBuilder m => Operand -> m Operand","name":"neg","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:neg"},{"display_html":"eq :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"eq","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:eq"},{"display_html":"ne :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"ne","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:ne"},{"display_html":"lt :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"lt","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:lt"},{"display_html":"le :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"le","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:le"},{"display_html":"gt :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"gt","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:gt"},{"display_html":"ge :: MonadAsmBuilder m => Operand -> Operand -> m Operand","name":"ge","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:ge"},{"display_html":"call :: MonadAsmBuilder m => Operand -> [Operand] -> m Operand","name":"call","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:call"},{"display_html":"ite :: MonadAsmBuilder m => Operand -> (() -> m Operand) -> (() -> m Operand) -> m Operand","name":"ite","module":"CodeGen.RiscV.Lib","link":"CodeGen-RiscV-Lib.html#v:ite"},{"display_html":"printCRuntime :: FilePath -> IO ()","name":"printCRuntime","module":"CodeGen.Runtime.PrintRuntime","link":"CodeGen-Runtime-PrintRuntime.html#v:printCRuntime"},{"display_html":"data TimedValue a = TimedValue {}","name":"TimedValue value time TimedValue","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#t:TimedValue"},{"display_html":"newtype Nanoseconds = Nanoseconds Integer","name":"Nanoseconds Nanoseconds","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#t:Nanoseconds"},{"display_html":"measureTimedValue :: IO a -> IO (TimedValue a)","name":"measureTimedValue","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#v:measureTimedValue"},{"display_html":"measureTime :: IO () -> IO Nanoseconds","name":"measureTime","module":"CodeGen.TimedValue","link":"CodeGen-TimedValue.html#v:measureTime"},{"display_html":"data RunResult","name":"RunResult exitCode compErrMsg runTime compTime stderr stdout RuntimeError CompilationError Success","module":"CodeGen.RunResult","link":"CodeGen-RunResult.html#t:RunResult"},{"display_html":"liftM1' :: Monad m => (a' -> m a) -> (a -> b) -> a' -> m b","name":"liftM1'","module":"MonadUtils","link":"MonadUtils.html#v:liftM1-39-"},{"display_html":"liftM2' :: Monad m => (a' -> m a) -> (a -> a -> b) -> a' -> a' -> m b","name":"liftM2'","module":"MonadUtils","link":"MonadUtils.html#v:liftM2-39-"},{"display_html":"liftM3' :: Monad m => (a' -> m a) -> (a -> a -> a -> b) -> a' -> a' -> a' -> m b","name":"liftM3'","module":"MonadUtils","link":"MonadUtils.html#v:liftM3-39-"},{"display_html":"locally :: MonadState s m => m a -> m a","name":"locally","module":"MonadUtils","link":"MonadUtils.html#v:locally"},{"display_html":"type Identifier = Text","name":"Identifier","module":"Trees.Common","link":"Trees-Common.html#t:Identifier"},{"display_html":"data Identifier'","name":"Identifier' Gen Txt","module":"Trees.Common","link":"Trees-Common.html#t:Identifier-39-"},{"display_html":"type IdCnt = Int","name":"IdCnt","module":"Trees.Common","link":"Trees-Common.html#t:IdCnt"},{"display_html":"data BinaryOperator","name":"BinaryOperator CompOp ArithOp BoolOp","module":"Trees.Common","link":"Trees-Common.html#t:BinaryOperator"},{"display_html":"data UnaryOperator = UnMinusOp","name":"UnaryOperator UnMinusOp","module":"Trees.Common","link":"Trees-Common.html#t:UnaryOperator"},{"display_html":"data BooleanOperator","name":"BooleanOperator OrOp AndOp","module":"Trees.Common","link":"Trees-Common.html#t:BooleanOperator"},{"display_html":"data ArithmeticOperator","name":"ArithmeticOperator DivOp MulOp MinusOp PlusOp","module":"Trees.Common","link":"Trees-Common.html#t:ArithmeticOperator"},{"display_html":"data ComparisonOperator","name":"ComparisonOperator GeOp GtOp LeOp LtOp NeOp EqOp","module":"Trees.Common","link":"Trees-Common.html#t:ComparisonOperator"},{"display_html":"type IsRec = Bool","name":"IsRec","module":"Trees.Common","link":"Trees-Common.html#t:IsRec"},{"display_html":"data Type","name":"Type TFun TInt TBool TUnit","module":"Trees.Common","link":"Trees-Common.html#t:Type"},{"display_html":"type Arity = Int","name":"Arity","module":"Trees.Common","link":"Trees-Common.html#t:Arity"},{"display_html":"data PrimitiveValue","name":"PrimitiveValue PrimValInt PrimValBool PrimValUnit","module":"Trees.Common","link":"Trees-Common.html#t:PrimitiveValue"},{"display_html":"data Program = Program [Declaration] IdCnt","name":"Program Program","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Program"},{"display_html":"data Declaration","name":"Declaration DeclFun DeclVar","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Declaration"},{"display_html":"declId :: Declaration -> Identifier'","name":"declId","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#v:declId"},{"display_html":"data Expression","name":"Expression ExprFun ExprLetIn ExprIte ExprApp ExprUnOp ExprBinOp ExprPrimVal ExprId","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Expression"},{"display_html":"data Fun = Fun (NonEmpty Identifier') Expression","name":"Fun Fun","module":"Transformations.Simplifier.SimplifiedAst","link":"Transformations-Simplifier-SimplifiedAst.html#t:Fun"},{"display_html":"relabelAst :: Program -> Program","name":"relabelAst","module":"Transformations.Relabeler.Relabeler","link":"Transformations-Relabeler-Relabeler.html#v:relabelAst"},{"display_html":"data Program = Program [GlobalDeclaration] IdCnt","name":"Program Program","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:Program"},{"display_html":"data GlobalDeclaration","name":"GlobalDeclaration GlobFunDecl GlobVarDecl","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:GlobalDeclaration"},{"display_html":"data VarDeclaration = VarDecl Identifier' Expression","name":"VarDeclaration VarDecl","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:VarDeclaration"},{"display_html":"data Expression","name":"Expression ExprLetIn ExprIte ExprApp ExprUnOp ExprBinOp ExprPrimVal ExprId","module":"Transformations.Ll.Lfr","link":"Transformations-Ll-Lfr.html#t:Expression"},{"display_html":"llAst :: Program -> Program","name":"llAst","module":"Transformations.Ll.Ll","link":"Transformations-Ll-Ll.html#v:llAst"},{"display_html":"newtype Program = Program [GlobalDeclaration]","name":"Program Program","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:Program"},{"display_html":"data GlobalDeclaration","name":"GlobalDeclaration GlobFunDecl GlobVarDecl","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:GlobalDeclaration"},{"display_html":"data Expression","name":"Expression ExprComp ExprAtom ExprLetIn","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:Expression"},{"display_html":"data AtomicExpression","name":"AtomicExpression AtomInt AtomBool AtomUnit AtomId","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:AtomicExpression"},{"display_html":"data ComplexExpression","name":"ComplexExpression CompUnOp CompBinOp CompIte CompApp","module":"Transformations.Anf.Anf","link":"Transformations-Anf-Anf.html#t:ComplexExpression"},{"display_html":"prettyPrint :: Program -> String","name":"prettyPrint","module":"Transformations.Anf.PrettyPrinter","link":"Transformations-Anf-PrettyPrinter.html#v:prettyPrint"},{"display_html":"genAnf :: Program -> Program","name":"genAnf","module":"Transformations.Anf.AnfGen","link":"Transformations-Anf-AnfGen.html#v:genAnf"},{"display_html":"type TypedDeclaration = (Identifier, Type)","name":"TypedDeclaration","module":"StdLib","link":"StdLib.html#t:TypedDeclaration"},{"display_html":"typedDecls :: [TypedDeclaration]","name":"typedDecls","module":"StdLib","link":"StdLib.html#v:typedDecls"},{"display_html":"decls :: [Identifier]","name":"decls","module":"StdLib","link":"StdLib.html#v:decls"},{"display_html":"type DeclarationWithArity = (Identifier, Arity)","name":"DeclarationWithArity","module":"StdLib","link":"StdLib.html#t:DeclarationWithArity"},{"display_html":"allDeclsWithArity :: [DeclarationWithArity]","name":"allDeclsWithArity","module":"StdLib","link":"StdLib.html#v:allDeclsWithArity"},{"display_html":"ccAst :: Program -> Program","name":"ccAst","module":"Transformations.Cc.Cc","link":"Transformations-Cc-Cc.html#v:ccAst"},{"display_html":"type Parser = Parsec Void Text","name":"Parser","module":"Parser.Lexer","link":"Parser-Lexer.html#t:Parser"},{"display_html":"sc :: Parser ()","name":"sc","module":"Parser.Lexer","link":"Parser-Lexer.html#v:sc"},{"display_html":"lexeme :: Parser a -> Parser a","name":"lexeme","module":"Parser.Lexer","link":"Parser-Lexer.html#v:lexeme"},{"display_html":"symbol :: Text -> Parser Text","name":"symbol","module":"Parser.Lexer","link":"Parser-Lexer.html#v:symbol"},{"display_html":"colon :: Parser Text","name":"colon","module":"Parser.Lexer","link":"Parser-Lexer.html#v:colon"},{"display_html":"semicolon2 :: Parser Text","name":"semicolon2","module":"Parser.Lexer","link":"Parser-Lexer.html#v:semicolon2"},{"display_html":"arrow :: Parser Text","name":"arrow","module":"Parser.Lexer","link":"Parser-Lexer.html#v:arrow"},{"display_html":"eq :: Parser Text","name":"eq","module":"Parser.Lexer","link":"Parser-Lexer.html#v:eq"},{"display_html":"leftPar :: Parser Text","name":"leftPar","module":"Parser.Lexer","link":"Parser-Lexer.html#v:leftPar"},{"display_html":"rightPar :: Parser Text","name":"rightPar","module":"Parser.Lexer","link":"Parser-Lexer.html#v:rightPar"},{"display_html":"unitLitP :: Parser Text","name":"unitLitP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:unitLitP"},{"display_html":"boolLitP :: Parser Bool","name":"boolLitP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:boolLitP"},{"display_html":"intLitP :: Parser Int64","name":"intLitP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:intLitP"},{"display_html":"identifierP :: Parser Identifier","name":"identifierP","module":"Parser.Lexer","link":"Parser-Lexer.html#v:identifierP"},{"display_html":"kwLet :: Parser Text","name":"kwLet","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwLet"},{"display_html":"kwRec :: Parser Text","name":"kwRec","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwRec"},{"display_html":"kwIn :: Parser Text","name":"kwIn","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwIn"},{"display_html":"kwIf :: Parser Text","name":"kwIf","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwIf"},{"display_html":"kwThen :: Parser Text","name":"kwThen","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwThen"},{"display_html":"kwElse :: Parser Text","name":"kwElse","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwElse"},{"display_html":"kwFun :: Parser Text","name":"kwFun","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwFun"},{"display_html":"kwUnit :: Parser Text","name":"kwUnit","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwUnit"},{"display_html":"kwBool :: Parser Text","name":"kwBool","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwBool"},{"display_html":"kwInt :: Parser Text","name":"kwInt","module":"Parser.Lexer","link":"Parser-Lexer.html#v:kwInt"},{"display_html":"choice' :: (Foldable f, Functor f) => f (Parser a) -> Parser a","name":"choice'","module":"Parser.Utils","link":"Parser-Utils.html#v:choice-39-"},{"display_html":"optional' :: Parser a -> Parser (Maybe a)","name":"optional'","module":"Parser.Utils","link":"Parser-Utils.html#v:optional-39-"},{"display_html":"parens :: Parser a -> Parser a","name":"parens","module":"Parser.Utils","link":"Parser-Utils.html#v:parens"},{"display_html":"manyParens :: Parser a -> Parser a","name":"manyParens","module":"Parser.Utils","link":"Parser-Utils.html#v:manyParens"},{"display_html":"someParens :: Parser a -> Parser a","name":"someParens","module":"Parser.Utils","link":"Parser-Utils.html#v:someParens"},{"display_html":"newtype Program = Program [Statement]","name":"Program Program","module":"Parser.Ast","link":"Parser-Ast.html#t:Program"},{"display_html":"data Statement","name":"Statement StmtExpr StmtDecl","module":"Parser.Ast","link":"Parser-Ast.html#t:Statement"},{"display_html":"data Declaration","name":"Declaration DeclFun DeclVar","module":"Parser.Ast","link":"Parser-Ast.html#t:Declaration"},{"display_html":"data Expression","name":"Expression ExprFun ExprLetIn ExprIte ExprApp ExprUnOp ExprBinOp ExprPrimVal ExprId","module":"Parser.Ast","link":"Parser-Ast.html#t:Expression"},{"display_html":"data Fun = Fun (NonEmpty (Identifier, Maybe Type)) (Maybe Type) Expression","name":"Fun Fun","module":"Parser.Ast","link":"Parser-Ast.html#t:Fun"},{"display_html":"simplifyAst :: Program -> Program","name":"simplifyAst","module":"Transformations.Simplifier.Simplifier","link":"Transformations-Simplifier-Simplifier.html#v:simplifyAst"},{"display_html":"parseProgram :: Text -> Maybe Program","name":"parseProgram","module":"Parser.Parser","link":"Parser-Parser.html#v:parseProgram"},{"display_html":"data TypeF a","name":"TypeF TVarF TUnitF TBoolF TIntF TFunF","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:TypeF"},{"display_html":"type UType = UTerm TypeF IntVar","name":"UType","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UType"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data UTerm (t :: Type -> Type) v where","name":"UTerm UTVar UTUnit UTBool UTInt UTFun","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:UTerm"},{"display_html":"data Poly t = Forall [Identifier] t","name":"Poly Forall","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:Poly"},{"display_html":"type Polytype = Poly Type","name":"Polytype","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:Polytype"},{"display_html":"toUType :: Type -> UType","name":"toUType","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:toUType"},{"display_html":"toPolytype :: UPolytype -> Polytype","name":"toPolytype","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:toPolytype"},{"display_html":"type Infer = ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity))","name":"Infer","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:Infer"},{"display_html":"lookup :: Identifier -> Infer UType","name":"lookup","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:lookup"},{"display_html":"withBinding :: MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a","name":"withBinding","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:withBinding"},{"display_html":"fresh :: Infer UType","name":"fresh","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:fresh"},{"display_html":"data TypeError where","name":"TypeError UnboundVar Unreachable Infinite ImpossibleBinOpApplication ImpossibleUnOpApplication Mismatch","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#t:TypeError"},{"display_html":"(=:=) :: UType -> UType -> Infer UType","name":"=:=","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:-61-:-61-"},{"display_html":"applyBindings :: UType -> Infer UType","name":"applyBindings","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:applyBindings"},{"display_html":"mkVarName :: String -> IntVar -> Identifier","name":"mkVarName","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:mkVarName"},{"display_html":"generalize :: UType -> Infer UPolytype","name":"generalize","module":"TypeChecker.HindleyMilner","link":"TypeChecker-HindleyMilner.html#v:generalize"},{"display_html":"checkProgram :: Program -> Either TypeError ()","name":"checkProgram","module":"TypeChecker.TypeChecker","link":"TypeChecker-TypeChecker.html#v:checkProgram"},{"display_html":"inferProgram :: Program -> Either TypeError Polytype","name":"inferProgram","module":"TypeChecker.TypeChecker","link":"TypeChecker-TypeChecker.html#v:inferProgram"},{"display_html":"newtype Module = Module {}","name":"Module Module code","module":"CodeGen.Module","link":"CodeGen-Module.html#t:Module"},{"display_html":"compileToModule :: Text -> Except Text Module","name":"compileToModule","module":"CodeGen.Module","link":"CodeGen-Module.html#v:compileToModule"},{"display_html":"ppRiscVAsm :: Module -> Text","name":"ppRiscVAsm","module":"CodeGen.RiscV.AsmGen","link":"CodeGen-RiscV-AsmGen.html#v:ppRiscVAsm"},{"display_html":"compileToRiscVAsm :: Text -> FilePath -> IO (TimedValue (Either Text ()))","name":"compileToRiscVAsm","module":"CodeGen.RiscV.Runner","link":"CodeGen-RiscV-Runner.html#v:compileToRiscVAsm"},{"display_html":"genLlvmIrModule :: Module -> Module","name":"genLlvmIrModule","module":"CodeGen.Llvm.LlvmIrGen","link":"CodeGen-Llvm-LlvmIrGen.html#v:genLlvmIrModule"},{"display_html":"ppLlvmModule :: Module -> Text","name":"ppLlvmModule","module":"CodeGen.Llvm.LlvmIrGen","link":"CodeGen-Llvm-LlvmIrGen.html#v:ppLlvmModule"},{"display_html":"run :: Text -> IO RunResult","name":"run","module":"CodeGen.Llvm.Runner","link":"CodeGen-Llvm-Runner.html#v:run"},{"display_html":"compileToBinary :: Text -> FilePath -> IO (TimedValue (Either Text ()))","name":"compileToBinary","module":"CodeGen.Llvm.Runner","link":"CodeGen-Llvm-Runner.html#v:compileToBinary"},{"display_html":"compileToLlvmIr :: Text -> FilePath -> IO (TimedValue (Either Text ()))","name":"compileToLlvmIr","module":"CodeGen.Llvm.Runner","link":"CodeGen-Llvm-Runner.html#v:compileToLlvmIr"}] \ No newline at end of file diff --git a/index.html b/index.html index ff61f0d..5de5e97 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -mini-ml-0.1.0.0: MiniML compiler
mini-ml-0.1.0.0: MiniML compiler

mini-ml-0.1.0.0: MiniML compiler

MiniML is a minimal dialect of ML (Meta Language).

Modules

\ No newline at end of file +mini-ml-0.1.0.0: MiniML compiler
mini-ml-0.1.0.0: MiniML compiler

mini-ml-0.1.0.0: MiniML compiler

MiniML is a minimal dialect of ML (Meta Language).

Modules

\ No newline at end of file diff --git a/mini-ml.haddock b/mini-ml.haddock index ed85e00..b018648 100644 Binary files a/mini-ml.haddock and b/mini-ml.haddock differ diff --git a/src/CodeGen.Llvm.LlvmIrGen.html b/src/CodeGen.Llvm.LlvmIrGen.html index 91f97b2..9157464 100644 --- a/src/CodeGen.Llvm.LlvmIrGen.html +++ b/src/CodeGen.Llvm.LlvmIrGen.html @@ -54,8 +54,8 @@ genModule :: Module -> LLVM.Module genModule :: Module -> Module -genModule (Module (Program [GlobalDeclaration] -decls)) = (State Env Module -> Env -> Module) +genModule (Module (Program [GlobalDeclaration] +decls)) = (State Env Module -> Env -> Module) -> Env -> State Env Module -> Module forall a b c. (a -> b -> c) -> b -> a -> c flip State Env Module -> Env -> Module @@ -95,7 +95,7 @@ (a -> m b) -> t a -> m () mapM_ GlobalDeclaration -> ModuleBuilderT (StateT Env Identity) () genGlobDecl [GlobalDeclaration] -decls +decls -- In the `main` we define our global variables. Name @@ -125,8 +125,8 @@ (Foldable t, Monad m) => (a -> m b) -> t a -> m () mapM_ GlobalDeclaration -> IRBuilderT Llvm () -gVarDef [GlobalDeclaration] -decls +gVarDef [GlobalDeclaration] +decls Operand -> IRBuilderT Llvm () forall (m :: * -> *). (HasCallStack, MonadIRBuilder m) => @@ -135,25 +135,25 @@ LLVM.int64 Integer 0) where - gVarDef :: GlobalDeclaration -> CodeGenM () - gVarDef :: GlobalDeclaration -> IRBuilderT Llvm () -gVarDef = \case - GlobVarDecl Identifier' -ident Expression -value -> do - Operand -operand <- Identifier' -> IRBuilderT Llvm Operand + gVarDef :: GlobalDeclaration -> CodeGenM () + gVarDef :: GlobalDeclaration -> IRBuilderT Llvm () +gVarDef = \case + GlobVarDecl Identifier' +ident Expression +value -> do + Operand +operand <- Identifier' -> IRBuilderT Llvm Operand forall (m :: * -> *). MonadState Env m => Identifier' -> m Operand findGlobVar Identifier' -ident - Operand -value' <- Expression -> IRBuilderT Llvm Operand +ident + Operand +value' <- Expression -> IRBuilderT Llvm Operand genExpr Expression -value +value Operand -> Operand -> IRBuilderT Llvm () store' Operand -operand Operand -value' +operand Operand +value' GlobalDeclaration _ -> () -> IRBuilderT Llvm () forall a. a -> IRBuilderT Llvm a @@ -162,11 +162,11 @@ genStdLibDecl :: StdLib.DeclarationWithArity -> Llvm () genStdLibDecl :: DeclarationWithArity -> ModuleBuilderT (StateT Env Identity) () -genStdLibDecl DeclarationWithArity -decl = DeclarationWithArity +genStdLibDecl DeclarationWithArity +decl = DeclarationWithArity -> ModuleBuilderT (StateT Env Identity) Operand -declareAsExtern DeclarationWithArity -decl ModuleBuilderT (StateT Env Identity) Operand +declareAsExtern DeclarationWithArity +decl ModuleBuilderT (StateT Env Identity) Operand -> (Operand -> ModuleBuilderT (StateT Env Identity) ()) -> ModuleBuilderT (StateT Env Identity) () forall a b. @@ -176,15 +176,15 @@ forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b >>= DeclarationWithArity -> Operand -> ModuleBuilderT (StateT Env Identity) () -register DeclarationWithArity -decl +register DeclarationWithArity +decl where - declareAsExtern :: StdLib.DeclarationWithArity -> Llvm LLVM.Operand - declareAsExtern :: DeclarationWithArity + declareAsExtern :: StdLib.DeclarationWithArity -> Llvm LLVM.Operand + declareAsExtern :: DeclarationWithArity -> ModuleBuilderT (StateT Env Identity) Operand -declareAsExtern (Identifier -ident, Arity -arity) = +declareAsExtern (Identifier +ident, Arity +arity) = Name -> [Type] -> Type -> ModuleBuilderT (StateT Env Identity) Operand forall (m :: * -> *). @@ -193,40 +193,40 @@ LLVM.extern (Identifier -> Name LLVM.Name Identifier -ident) +ident) (Arity -> Type -> [Type] forall a. Arity -> a -> [a] replicate Arity -arity Type +arity Type LLVM.i64) Type LLVM.i64 - register :: StdLib.DeclarationWithArity -> LLVM.Operand -> Llvm () - register :: DeclarationWithArity + register :: StdLib.DeclarationWithArity -> LLVM.Operand -> Llvm () + register :: DeclarationWithArity -> Operand -> ModuleBuilderT (StateT Env Identity) () -register (Identifier -ident, Arity -arity) Operand -fun = Identifier' +register (Identifier +ident, Arity +arity) Operand +fun = Identifier' -> Operand -> Arity -> ModuleBuilderT (StateT Env Identity) () forall (m :: * -> *). MonadState Env m => Identifier' -> Operand -> Arity -> m () regFun (Identifier -> Identifier' Txt Identifier -ident) Operand -fun Arity -arity +ident) Operand +fun Arity +arity genGlobDecl :: GlobalDeclaration -> Llvm () genGlobDecl :: GlobalDeclaration -> ModuleBuilderT (StateT Env Identity) () genGlobDecl = \case - GlobVarDecl Identifier' -ident Expression + GlobVarDecl Identifier' +ident Expression _ -> do - Operand -var <- Name + Operand +var <- Name -> Type -> Constant -> ModuleBuilderT (StateT Env Identity) Operand forall (m :: * -> *). MonadModuleBuilder m => @@ -239,7 +239,7 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> String genId Identifier' -ident) Type +ident) Type LLVM.i64 (Alignment -> Integer -> Constant LLVM.Int Alignment 64 Integer @@ -249,26 +249,26 @@ MonadState Env m => Identifier' -> Operand -> m () regGlobVar Identifier' -ident Operand -var - GlobFunDecl Identifier' -ident [Identifier'] -params Expression -body -> mdo +ident Operand +var + GlobFunDecl Identifier' +ident [Identifier'] +params Expression +body -> mdo Identifier' -> Operand -> Arity -> ModuleBuilderT (StateT Env Identity) () forall (m :: * -> *). MonadState Env m => Identifier' -> Operand -> Arity -> m () regFun Identifier' -ident Operand -fun ([Identifier'] -> Arity +ident Operand +fun ([Identifier'] -> Arity forall a. [a] -> Arity forall (t :: * -> *) a. Foldable t => t a -> Arity length [Identifier'] -params) - Operand -fun <- ModuleBuilderT (StateT Env Identity) Operand +params) + Operand +fun <- ModuleBuilderT (StateT Env Identity) Operand -> ModuleBuilderT (StateT Env Identity) Operand forall s (m :: * -> *) a. MonadState s m => m a -> m a locally (ModuleBuilderT (StateT Env Identity) Operand @@ -298,7 +298,7 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> String genId Identifier' -ident) +ident) ((Type LLVM.i64,) (ParameterName -> (Type, ParameterName)) -> (Identifier' -> ParameterName) @@ -318,7 +318,7 @@ -> [Identifier'] -> [(Type, ParameterName)] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Identifier'] -params) +params) Type LLVM.i64 (([Operand] -> IRBuilderT Llvm ()) @@ -326,8 +326,8 @@ -> ([Operand] -> IRBuilderT Llvm ()) -> ModuleBuilderT (StateT Env Identity) Operand forall a b. (a -> b) -> a -> b -$ \[Operand] -args -> do +$ \[Operand] +args -> do ((Identifier', Operand) -> IRBuilderT Llvm ()) -> [(Identifier', Operand)] -> IRBuilderT Llvm () forall (t :: * -> *) (m :: * -> *) a b. @@ -341,20 +341,20 @@ MonadState Env m => Identifier' -> Operand -> m () regLocVar) ([Identifier'] -params [Identifier'] -> [Operand] -> [(Identifier', Operand)] +params [Identifier'] -> [Operand] -> [(Identifier', Operand)] forall a b. [a] -> [b] -> [(a, b)] `zip` [Operand] -args) - Operand -body' <- Expression -> IRBuilderT Llvm Operand +args) + Operand +body' <- Expression -> IRBuilderT Llvm Operand genExpr Expression -body +body Operand -> IRBuilderT Llvm () forall (m :: * -> *). (HasCallStack, MonadIRBuilder m) => Operand -> m () LLVM.ret Operand -body' +body' () -> ModuleBuilderT (StateT Env Identity) () forall a. a -> Llvm a forall (m :: * -> *) a. Monad m => a -> m a @@ -363,15 +363,15 @@ genId :: Identifier' -> String genId :: Identifier' -> String genId = \case - Txt Identifier -txt -> Identifier -> String + Txt Identifier +txt -> Identifier -> String Txt.unpack Identifier -txt - Gen Arity -n Identifier -txt -> Identifier -> String +txt + Gen Arity +n Identifier +txt -> Identifier -> String Txt.unpack Identifier -txt String -> String -> String +txt String -> String -> String forall a. Semigroup a => a -> a -> a <> String "." String -> String -> String @@ -379,45 +379,45 @@ <> Arity -> String forall a. Show a => a -> String show Arity -n +n genExpr :: Expression -> CodeGenM LLVM.Operand genExpr :: Expression -> IRBuilderT Llvm Operand genExpr = \case - ExprAtom AtomicExpression -atom -> AtomicExpression -> IRBuilderT Llvm Operand + ExprAtom AtomicExpression +atom -> AtomicExpression -> IRBuilderT Llvm Operand genAtom AtomicExpression -atom - ExprComp ComplexExpression -ce -> ComplexExpression -> IRBuilderT Llvm Operand +atom + ExprComp ComplexExpression +ce -> ComplexExpression -> IRBuilderT Llvm Operand genComp ComplexExpression -ce - ExprLetIn (Identifier' -ident, Expression -val) Expression -expr -> do - Operand -val' <- Expression -> IRBuilderT Llvm Operand +ce + ExprLetIn (Identifier' +ident, Expression +val) Expression +expr -> do + Operand +val' <- Expression -> IRBuilderT Llvm Operand genExpr Expression -val +val Identifier' -> Operand -> IRBuilderT Llvm () forall (m :: * -> *). MonadState Env m => Identifier' -> Operand -> m () regLocVar Identifier' -ident Operand -val' +ident Operand +val' Expression -> IRBuilderT Llvm Operand genExpr Expression -expr +expr genAtom :: AtomicExpression -> CodeGenM LLVM.Operand genAtom :: AtomicExpression -> IRBuilderT Llvm Operand genAtom = \case - AtomId Identifier' -ident -> Identifier' -> IRBuilderT Llvm Operand + AtomId Identifier' +ident -> Identifier' -> IRBuilderT Llvm Operand findAny Identifier' -ident +ident AtomicExpression AtomUnit -> Operand -> IRBuilderT Llvm Operand forall a. a -> IRBuilderT Llvm a @@ -428,8 +428,8 @@ $ Integer -> Operand LLVM.int64 Integer 0 - AtomBool Bool -bool -> Operand -> IRBuilderT Llvm Operand + AtomBool Bool +bool -> Operand -> IRBuilderT Llvm Operand forall a. a -> IRBuilderT Llvm a forall (m :: * -> *) a. Monad m => a -> m a return (Operand -> IRBuilderT Llvm Operand) @@ -441,9 +441,9 @@ $ Bool -> Integer forall a. Num a => Bool -> a fromBool Bool -bool - AtomInt Int64 -int -> Operand -> IRBuilderT Llvm Operand +bool + AtomInt Int64 +int -> Operand -> IRBuilderT Llvm Operand forall a. a -> IRBuilderT Llvm a forall (m :: * -> *) a. Monad m => a -> m a return (Operand -> IRBuilderT Llvm Operand) @@ -455,24 +455,24 @@ $ Int64 -> Integer forall a. Integral a => a -> Integer toInteger Int64 -int +int genComp :: ComplexExpression -> CodeGenM LLVM.Operand genComp :: ComplexExpression -> IRBuilderT Llvm Operand genComp = \case - CompApp Identifier' -f AtomicExpression -arg -> do - Operand -f' <- Identifier' -> IRBuilderT Llvm Operand + CompApp Identifier' +f AtomicExpression +arg -> do + Operand +f' <- Identifier' -> IRBuilderT Llvm Operand findAny Identifier' -f - Operand -arg' <- AtomicExpression -> IRBuilderT Llvm Operand +f + Operand +arg' <- AtomicExpression -> IRBuilderT Llvm Operand genAtom AtomicExpression -arg - Operand -applyF <- Identifier' -> IRBuilderT Llvm Operand +arg + Operand +applyF <- Identifier' -> IRBuilderT Llvm Operand findFun (Identifier -> Identifier' Txt Identifier "miniml_apply") @@ -481,21 +481,21 @@ (HasCallStack, MonadIRBuilder m) => Operand -> [Operand] -> m Operand LLVM.call Operand -applyF [Operand -f', Operand -arg'] - CompIte AtomicExpression -c Expression -t Expression -e -> mdo - Operand -rv <- IRBuilderT Llvm Operand +applyF [Operand +f', Operand +arg'] + CompIte AtomicExpression +c Expression +t Expression +e -> mdo + Operand +rv <- IRBuilderT Llvm Operand allocate' - Operand -c' <- AtomicExpression -> IRBuilderT Llvm Operand + Operand +c' <- AtomicExpression -> IRBuilderT Llvm Operand genAtom AtomicExpression -c IRBuilderT Llvm Operand +c IRBuilderT Llvm Operand -> (Operand -> IRBuilderT Llvm Operand) -> IRBuilderT Llvm Operand forall a b. IRBuilderT Llvm a -> (a -> IRBuilderT Llvm b) -> IRBuilderT Llvm b @@ -507,74 +507,74 @@ (HasCallStack, MonadIRBuilder m) => Operand -> Name -> Name -> m () LLVM.condBr Operand -c' Name -tBlock Name -eBlock +c' Name +tBlock Name +eBlock - Name -tBlock <- Identifier -> IRBuilderT Llvm Name + Name +tBlock <- Identifier -> IRBuilderT Llvm Name forall (m :: * -> *). MonadIRBuilder m => Identifier -> m Name LLVM.blockNamed Identifier "if.then" Operand -> Operand -> IRBuilderT Llvm () store' Operand -rv (Operand -> IRBuilderT Llvm ()) +rv (Operand -> IRBuilderT Llvm ()) -> IRBuilderT Llvm Operand -> IRBuilderT Llvm () forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< Expression -> IRBuilderT Llvm Operand genExpr Expression -t +t Name -> IRBuilderT Llvm () forall (m :: * -> *). (MonadIRBuilder m, HasCallStack) => Name -> m () LLVM.br Name -end +end - Name -eBlock <- Identifier -> IRBuilderT Llvm Name + Name +eBlock <- Identifier -> IRBuilderT Llvm Name forall (m :: * -> *). MonadIRBuilder m => Identifier -> m Name LLVM.blockNamed Identifier "if.else" Operand -> Operand -> IRBuilderT Llvm () store' Operand -rv (Operand -> IRBuilderT Llvm ()) +rv (Operand -> IRBuilderT Llvm ()) -> IRBuilderT Llvm Operand -> IRBuilderT Llvm () forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< Expression -> IRBuilderT Llvm Operand genExpr Expression -e +e Name -> IRBuilderT Llvm () forall (m :: * -> *). (MonadIRBuilder m, HasCallStack) => Name -> m () LLVM.br Name -end +end - Name -end <- Identifier -> IRBuilderT Llvm Name + Name +end <- Identifier -> IRBuilderT Llvm Name forall (m :: * -> *). MonadIRBuilder m => Identifier -> m Name LLVM.blockNamed Identifier "if.end" Operand -> IRBuilderT Llvm Operand load' Operand -rv - CompBinOp BinaryOperator -op AtomicExpression -lhs AtomicExpression -rhs -> do - Operand -lhs' <- AtomicExpression -> IRBuilderT Llvm Operand +rv + CompBinOp BinaryOperator +op AtomicExpression +lhs AtomicExpression +rhs -> do + Operand +lhs' <- AtomicExpression -> IRBuilderT Llvm Operand genAtom AtomicExpression -lhs - Operand -rhs' <- AtomicExpression -> IRBuilderT Llvm Operand +lhs + Operand +rhs' <- AtomicExpression -> IRBuilderT Llvm Operand genAtom AtomicExpression -rhs - let opF :: Operand -> Operand -> IRBuilderT Llvm Operand -opF = case BinaryOperator -op of +rhs + let opF :: Operand -> Operand -> IRBuilderT Llvm Operand +opF = case BinaryOperator +op of BoolOp BooleanOperator AndOp -> Operand -> Operand -> IRBuilderT Llvm Operand forall (m :: * -> *). @@ -607,11 +607,11 @@ LLVM.mul ArithOp ArithmeticOperator DivOp -> - ( \Operand -lhs'' Operand -rhs'' -> do - Operand -divF <- Identifier' -> IRBuilderT Llvm Operand + ( \Operand +lhs'' Operand +rhs'' -> do + Operand +divF <- Identifier' -> IRBuilderT Llvm Operand findFun (Identifier -> Identifier' Txt Identifier "miniml_div") @@ -620,15 +620,15 @@ (HasCallStack, MonadIRBuilder m) => Operand -> [Operand] -> m Operand LLVM.call Operand -divF [Operand -lhs'', Operand -rhs''] +divF [Operand +lhs'', Operand +rhs''] ) - CompOp ComparisonOperator -cOp -> - let cOpF :: Operand -> Operand -> IRBuilderT Llvm Operand -cOpF = case ComparisonOperator -cOp of + CompOp ComparisonOperator +cOp -> + let cOpF :: Operand -> Operand -> IRBuilderT Llvm Operand +cOpF = case ComparisonOperator +cOp of ComparisonOperator EqOp -> ComparisonType -> Operand -> Operand -> IRBuilderT Llvm Operand forall (m :: * -> *). @@ -671,12 +671,12 @@ ComparisonType -> Operand -> Operand -> m Operand LLVM.icmp ComparisonType LLVM.SGE - in (\Operand -a Operand -b -> Operand -> Operand -> IRBuilderT Llvm Operand -cOpF Operand -a Operand -b IRBuilderT Llvm Operand + in (\Operand +a Operand +b -> Operand -> Operand -> IRBuilderT Llvm Operand +cOpF Operand +a Operand +b IRBuilderT Llvm Operand -> (Operand -> IRBuilderT Llvm Operand) -> IRBuilderT Llvm Operand forall a b. IRBuilderT Llvm a -> (a -> IRBuilderT Llvm b) -> IRBuilderT Llvm b @@ -684,19 +684,19 @@ >>= Operand -> IRBuilderT Llvm Operand boolToInt) Operand -> Operand -> IRBuilderT Llvm Operand -opF Operand -lhs' Operand -rhs' - CompUnOp UnaryOperator -op AtomicExpression -x -> do - Operand -x' <- AtomicExpression -> IRBuilderT Llvm Operand +opF Operand +lhs' Operand +rhs' + CompUnOp UnaryOperator +op AtomicExpression +x -> do + Operand +x' <- AtomicExpression -> IRBuilderT Llvm Operand genAtom AtomicExpression -x - let opF :: Operand -> IRBuilderT Llvm Operand -opF = case UnaryOperator -op of +x + let opF :: Operand -> IRBuilderT Llvm Operand +opF = case UnaryOperator +op of UnaryOperator UnMinusOp -> Operand -> Operand -> IRBuilderT Llvm Operand forall (m :: * -> *). @@ -706,45 +706,45 @@ LLVM.int64 (-Integer 1)) Operand -> IRBuilderT Llvm Operand -opF Operand -x' +opF Operand +x' -- Vars & Funs findAny :: Identifier' -> CodeGenM LLVM.Operand findAny :: Identifier' -> IRBuilderT Llvm Operand -findAny Identifier' -ident = do - Maybe Operand -maybeLocVar <- (Env -> Maybe Operand) -> IRBuilderT Llvm (Maybe Operand) +findAny Identifier' +ident = do + Maybe Operand +maybeLocVar <- (Env -> Maybe Operand) -> IRBuilderT Llvm (Maybe Operand) forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets ((Map Identifier' Operand -> Identifier' -> Maybe Operand forall k a. Ord k => Map k a -> k -> Maybe a Map.!? Identifier' -ident) (Map Identifier' Operand -> Maybe Operand) +ident) (Map Identifier' Operand -> Maybe Operand) -> (Env -> Map Identifier' Operand) -> Env -> Maybe Operand forall b c a. (b -> c) -> (a -> b) -> a -> c . Env -> Map Identifier' Operand locVars) case Maybe Operand -maybeLocVar of - Just Operand -locVar -> Operand -> IRBuilderT Llvm Operand +maybeLocVar of + Just Operand +locVar -> Operand -> IRBuilderT Llvm Operand forall a. a -> IRBuilderT Llvm a forall (m :: * -> *) a. Monad m => a -> m a return Operand -locVar +locVar Maybe Operand Nothing -> do - Maybe (Operand, Arity) -maybeFun <- (Env -> Maybe (Operand, Arity)) + Maybe (Operand, Arity) +maybeFun <- (Env -> Maybe (Operand, Arity)) -> IRBuilderT Llvm (Maybe (Operand, Arity)) forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets ((Map Identifier' (Operand, Arity) -> Identifier' -> Maybe (Operand, Arity) forall k a. Ord k => Map k a -> k -> Maybe a Map.!? Identifier' -ident) (Map Identifier' (Operand, Arity) -> Maybe (Operand, Arity)) +ident) (Map Identifier' (Operand, Arity) -> Maybe (Operand, Arity)) -> (Env -> Map Identifier' (Operand, Arity)) -> Env -> Maybe (Operand, Arity) @@ -752,34 +752,34 @@ . Env -> Map Identifier' (Operand, Arity) funs) case Maybe (Operand, Arity) -maybeFun of - Just (Operand -fun, Arity -arity) -> do - Operand -funToPafF <- Identifier' -> IRBuilderT Llvm Operand +maybeFun of + Just (Operand +fun, Arity +arity) -> do + Operand +funToPafF <- Identifier' -> IRBuilderT Llvm Operand findFun (Identifier -> Identifier' Txt Identifier "miniml_fun_to_paf") - Operand -fun' <- Operand -> Type -> IRBuilderT Llvm Operand + Operand +fun' <- Operand -> Type -> IRBuilderT Llvm Operand forall (m :: * -> *). (MonadIRBuilder m, HasCallStack) => Operand -> Type -> m Operand LLVM.ptrtoint Operand -fun Type +fun Type LLVM.i64 Operand -> [Operand] -> IRBuilderT Llvm Operand forall (m :: * -> *). (HasCallStack, MonadIRBuilder m) => Operand -> [Operand] -> m Operand LLVM.call Operand -funToPafF [Operand -fun', Integer -> Operand +funToPafF [Operand +fun', Integer -> Operand LLVM.int64 (Arity -> Integer forall a. Integral a => a -> Integer toInteger Arity -arity)] +arity)] Maybe (Operand, Arity) Nothing -> Operand -> IRBuilderT Llvm Operand load' (Operand -> IRBuilderT Llvm Operand) @@ -788,17 +788,17 @@ =<< Identifier' -> IRBuilderT Llvm Operand forall (m :: * -> *). MonadState Env m => Identifier' -> m Operand findGlobVar Identifier' -ident +ident -findGlobVar :: (MonadState Env m) => Identifier' -> m LLVM.Operand +findGlobVar :: (MonadState Env m) => Identifier' -> m LLVM.Operand findGlobVar :: forall (m :: * -> *). MonadState Env m => Identifier' -> m Operand -findGlobVar Identifier' -ident = (Env -> Operand) -> m Operand +findGlobVar Identifier' +ident = (Env -> Operand) -> m Operand forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets ((Map Identifier' Operand -> Identifier' -> Operand forall k a. Ord k => Map k a -> k -> a Map.! Identifier' -ident) (Map Identifier' Operand -> Operand) +ident) (Map Identifier' Operand -> Operand) -> (Env -> Map Identifier' Operand) -> Env -> Operand forall b c a. (b -> c) -> (a -> b) -> a -> c . Env -> Map Identifier' Operand @@ -806,8 +806,8 @@ findFun :: Identifier' -> CodeGenM LLVM.Operand findFun :: Identifier' -> IRBuilderT Llvm Operand -findFun Identifier' -ident = (Env -> Operand) -> IRBuilderT Llvm Operand +findFun Identifier' +ident = (Env -> Operand) -> IRBuilderT Llvm Operand forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets ((Operand, Arity) -> Operand forall a b. (a, b) -> a @@ -817,7 +817,7 @@ . (Map Identifier' (Operand, Arity) -> Identifier' -> (Operand, Arity) forall k a. Ord k => Map k a -> k -> a Map.! Identifier' -ident) (Map Identifier' (Operand, Arity) -> (Operand, Arity)) +ident) (Map Identifier' (Operand, Arity) -> (Operand, Arity)) -> (Env -> Map Identifier' (Operand, Arity)) -> Env -> (Operand, Arity) @@ -825,78 +825,78 @@ . Env -> Map Identifier' (Operand, Arity) funs) -regLocVar :: (MonadState Env m) => Identifier' -> LLVM.Operand -> m () +regLocVar :: (MonadState Env m) => Identifier' -> LLVM.Operand -> m () regLocVar :: forall (m :: * -> *). MonadState Env m => Identifier' -> Operand -> m () -regLocVar Identifier' -ident Operand -var = (Env -> Env) -> m () +regLocVar Identifier' +ident Operand +var = (Env -> Env) -> m () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((Env -> Env) -> m ()) -> (Env -> Env) -> m () forall a b. (a -> b) -> a -> b $ - \Env -env -> Env -env {locVars :: Map Identifier' Operand + \Env +env -> Env +env {locVars :: Map Identifier' Operand locVars = Identifier' -> Operand -> Map Identifier' Operand -> Map Identifier' Operand forall k a. Ord k => k -> a -> Map k a -> Map k a Map.insert Identifier' -ident Operand -var (Env -> Map Identifier' Operand +ident Operand +var (Env -> Map Identifier' Operand locVars Env -env)} +env)} -regGlobVar :: (MonadState Env m) => Identifier' -> LLVM.Operand -> m () +regGlobVar :: (MonadState Env m) => Identifier' -> LLVM.Operand -> m () regGlobVar :: forall (m :: * -> *). MonadState Env m => Identifier' -> Operand -> m () -regGlobVar Identifier' -ident Operand -gVar = (Env -> Env) -> m () +regGlobVar Identifier' +ident Operand +gVar = (Env -> Env) -> m () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((Env -> Env) -> m ()) -> (Env -> Env) -> m () forall a b. (a -> b) -> a -> b $ - \Env -env -> Env -env {globVars :: Map Identifier' Operand + \Env +env -> Env +env {globVars :: Map Identifier' Operand globVars = Identifier' -> Operand -> Map Identifier' Operand -> Map Identifier' Operand forall k a. Ord k => k -> a -> Map k a -> Map k a Map.insert Identifier' -ident Operand -gVar (Env -> Map Identifier' Operand +ident Operand +gVar (Env -> Map Identifier' Operand globVars Env -env)} +env)} -regFun :: (MonadState Env m) => Identifier' -> LLVM.Operand -> Arity -> m () +regFun :: (MonadState Env m) => Identifier' -> LLVM.Operand -> Arity -> m () regFun :: forall (m :: * -> *). MonadState Env m => Identifier' -> Operand -> Arity -> m () -regFun Identifier' -ident Operand -fun Arity -paramsCnt = (Env -> Env) -> m () +regFun Identifier' +ident Operand +fun Arity +paramsCnt = (Env -> Env) -> m () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((Env -> Env) -> m ()) -> (Env -> Env) -> m () forall a b. (a -> b) -> a -> b $ - \Env -env -> Env -env {funs :: Map Identifier' (Operand, Arity) + \Env +env -> Env +env {funs :: Map Identifier' (Operand, Arity) funs = Identifier' -> (Operand, Arity) -> Map Identifier' (Operand, Arity) -> Map Identifier' (Operand, Arity) forall k a. Ord k => k -> a -> Map k a -> Map k a Map.insert Identifier' -ident (Operand -fun, Arity -paramsCnt) (Env -> Map Identifier' (Operand, Arity) +ident (Operand +fun, Arity +paramsCnt) (Env -> Map Identifier' (Operand, Arity) funs Env -env)} +env)} -- Allocation utils @@ -914,24 +914,24 @@ load' :: LLVM.Operand -> CodeGenM LLVM.Operand load' :: Operand -> IRBuilderT Llvm Operand -load' Operand -addr = Operand -> Alignment -> IRBuilderT Llvm Operand +load' Operand +addr = Operand -> Alignment -> IRBuilderT Llvm Operand forall (m :: * -> *). (HasCallStack, MonadIRBuilder m) => Operand -> Alignment -> m Operand LLVM.load Operand -addr Alignment +addr Alignment 0 store' :: LLVM.Operand -> LLVM.Operand -> CodeGenM () store' :: Operand -> Operand -> IRBuilderT Llvm () -store' Operand -addr = Operand -> Alignment -> Operand -> IRBuilderT Llvm () +store' Operand +addr = Operand -> Alignment -> Operand -> IRBuilderT Llvm () forall (m :: * -> *). (MonadIRBuilder m, HasCallStack) => Operand -> Alignment -> Operand -> m () LLVM.store Operand -addr Alignment +addr Alignment 0 -- Conversion utils diff --git a/src/CodeGen.Llvm.Runner.html b/src/CodeGen.Llvm.Runner.html index 51cbf82..04acc05 100644 --- a/src/CodeGen.Llvm.Runner.html +++ b/src/CodeGen.Llvm.Runner.html @@ -21,71 +21,71 @@ run :: Text -> IO RR.RunResult run :: Text -> IO RunResult -run Text -text = do - TimedValue Either Text () -compResult Nanoseconds -compTime <- Text -> String -> IO (TimedValue (Either Text ())) +run Text +text = do + TimedValue Either Text () +compResult Nanoseconds +compTime <- Text -> String -> IO (TimedValue (Either Text ())) compileToBinary Text -text String -outputFilePath +text String +outputFilePath case Either Text () -compResult of +compResult of Right () -> do - TimedValue Either (String, String, Int) String -runResult Nanoseconds -runTime <- IO (TimedValue (Either (String, String, Int) String)) -runCompiledModule + TimedValue Either (String, String, Int) String +runResult Nanoseconds +runTime <- IO (TimedValue (Either (String, String, Int) String)) +runCompiledModule RunResult -> IO RunResult forall a. a -> IO a forall (m :: * -> *) a. Monad m => a -> m a return (RunResult -> IO RunResult) -> RunResult -> IO RunResult forall a b. (a -> b) -> a -> b $ case Either (String, String, Int) String -runResult of - Right String -out -> +runResult of + Right String +out -> RR.Success { stdout :: Text RR.stdout = String -> Text forall a b. ConvertibleStrings a b => a -> b cs String -out, +out, compTime :: Nanoseconds RR.compTime = Nanoseconds -compTime, +compTime, runTime :: Nanoseconds RR.runTime = Nanoseconds -runTime +runTime } - Left (String -out, String -err, Int -code) -> + Left (String +out, String +err, Int +code) -> RR.RuntimeError { stdout :: Text RR.stdout = String -> Text forall a b. ConvertibleStrings a b => a -> b cs String -out, +out, stderr :: Text RR.stderr = String -> Text forall a b. ConvertibleStrings a b => a -> b cs String -err, +err, exitCode :: Int RR.exitCode = Int -code, +code, compTime :: Nanoseconds RR.compTime = Nanoseconds -compTime, +compTime, runTime :: Nanoseconds RR.runTime = Nanoseconds -runTime +runTime } - Left Text -compErrMsg -> + Left Text +compErrMsg -> RunResult -> IO RunResult forall a. a -> IO a forall (m :: * -> *) a. Monad m => a -> m a @@ -95,22 +95,22 @@ RR.CompilationError { compErrMsg :: Text RR.compErrMsg = Text -compErrMsg, +compErrMsg, compTime :: Nanoseconds RR.compTime = Nanoseconds -compTime +compTime } where - outputFilePath :: FilePath - outputFilePath :: String -outputFilePath = String + outputFilePath :: FilePath + outputFilePath :: String +outputFilePath = String "./program" - runCompiledModule :: IO (TimedValue (Either (String, String, Int) String)) - runCompiledModule :: IO (TimedValue (Either (String, String, Int) String)) -runCompiledModule = do - TimedValue (Either (String, String, Int) String) -measuredResult <- IO (Either (String, String, Int) String) + runCompiledModule :: IO (TimedValue (Either (String, String, Int) String)) + runCompiledModule :: IO (TimedValue (Either (String, String, Int) String)) +runCompiledModule = do + TimedValue (Either (String, String, Int) String) +measuredResult <- IO (Either (String, String, Int) String) -> IO (TimedValue (Either (String, String, Int) String)) forall a. IO a -> IO (TimedValue a) measureTimedValue (IO (Either (String, String, Int) String) @@ -119,12 +119,12 @@ -> IO (TimedValue (Either (String, String, Int) String)) forall a b. (a -> b) -> a -> b $ do - (ExitCode -exitCode, String -stdout, String -stderr) <- String -> [String] -> String -> IO (ExitCode, String, String) + (ExitCode +exitCode, String +stdout, String +stderr) <- String -> [String] -> String -> IO (ExitCode, String, String) readProcessWithExitCode String -outputFilePath [] [] +outputFilePath [] [] Either (String, String, Int) String -> IO (Either (String, String, Int) String) forall a. a -> IO a @@ -135,36 +135,36 @@ -> IO (Either (String, String, Int) String) forall a b. (a -> b) -> a -> b $ case ExitCode -exitCode of +exitCode of ExitCode ExitSuccess -> String -> Either (String, String, Int) String forall a b. b -> Either a b Right String -stdout - ExitFailure Int -ec -> (String, String, Int) -> Either (String, String, Int) String +stdout + ExitFailure Int +ec -> (String, String, Int) -> Either (String, String, Int) String forall a b. a -> Either a b Left (String -stdout, String -stderr, Int -ec) +stdout, String +stderr, Int +ec) String -> IO () removePathForcibly String -outputFilePath +outputFilePath TimedValue (Either (String, String, Int) String) -> IO (TimedValue (Either (String, String, Int) String)) forall a. a -> IO a forall (m :: * -> *) a. Monad m => a -> m a return TimedValue (Either (String, String, Int) String) -measuredResult +measuredResult compileToBinary :: Text -> FilePath -> IO (TimedValue (Either Text ())) compileToBinary :: Text -> String -> IO (TimedValue (Either Text ())) -compileToBinary Text -text String -outputFilePath = IO (Either Text ()) -> IO (TimedValue (Either Text ())) +compileToBinary Text +text String +outputFilePath = IO (Either Text ()) -> IO (TimedValue (Either Text ())) forall a. IO a -> IO (TimedValue a) measureTimedValue (IO (Either Text ()) -> IO (TimedValue (Either Text ()))) -> IO (Either Text ()) -> IO (TimedValue (Either Text ())) @@ -187,10 +187,10 @@ -> Except Text (IO ()) -> Either Text (IO ()) forall a b. (a -> b) -> a -> b $ do - Text -llvmIrText <- Text -> Except Text Text + Text +llvmIrText <- Text -> Except Text Text compileToLlvmIr' Text -text +text IO () -> Except Text (IO ()) forall a. a -> ExceptT Text Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -204,44 +204,44 @@ "build") String -> IO () removePathForcibly ((String -> IO ()) -> IO ()) -> (String -> IO ()) -> IO () forall a b. (a -> b) -> a -> b -$ \String -buildDir -> +$ \String +buildDir -> String -> IO () -> IO () forall a. String -> IO a -> IO a withCurrentDirectory String -buildDir (IO () -> IO ()) -> IO () -> IO () +buildDir (IO () -> IO ()) -> IO () -> IO () forall a b. (a -> b) -> a -> b $ do - (String -llvm, Handle -llvmHandle) <- String -> String -> IO (String, Handle) + (String +llvm, Handle +llvmHandle) <- String -> String -> IO (String, Handle) mkstemps String "module" String ".ll" Handle -> Text -> IO () Txt.hPutStrLn Handle -llvmHandle Text -llvmIrText +llvmHandle Text +llvmIrText Handle -> IO () hClose Handle -llvmHandle +llvmHandle - (String -runtime, Handle -runtimeHandle) <- String -> String -> IO (String, Handle) + (String +runtime, Handle +runtimeHandle) <- String -> String -> IO (String, Handle) mkstemps String "runtime" String ".c" - let runtimeFileText :: Text -runtimeFileText = ByteString -> Text + let runtimeFileText :: Text +runtimeFileText = ByteString -> Text Txt.decodeUtf8 $(makeRelativeToProject "lib/CodeGen/Runtime/runtime.c" >>= embedFile) Handle -> Text -> IO () Txt.hPutStrLn Handle -runtimeHandle Text -runtimeFileText +runtimeHandle Text +runtimeFileText Handle -> IO () hClose Handle -runtimeHandle +runtimeHandle String -> [String] -> IO () callProcess String @@ -249,19 +249,19 @@ "-Wno-override-module", String "-O3", String "-lm", String -llvm, String -runtime, String +llvm, String +runtime, String "-o", String "../" String -> String -> String forall a. Semigroup a => a -> a -> a <> String -outputFilePath] +outputFilePath] compileToLlvmIr :: Text -> FilePath -> IO (TimedValue (Either Text ())) compileToLlvmIr :: Text -> String -> IO (TimedValue (Either Text ())) -compileToLlvmIr Text -text String -outputFilePath = IO (Either Text ()) -> IO (TimedValue (Either Text ())) +compileToLlvmIr Text +text String +outputFilePath = IO (Either Text ()) -> IO (TimedValue (Either Text ())) forall a. IO a -> IO (TimedValue a) measureTimedValue (IO (Either Text ()) -> IO (TimedValue (Either Text ()))) -> IO (Either Text ()) -> IO (TimedValue (Either Text ())) @@ -284,10 +284,10 @@ -> Except Text (IO ()) -> Either Text (IO ()) forall a b. (a -> b) -> a -> b $ do - Text -llvmIrText <- Text -> Except Text Text + Text +llvmIrText <- Text -> Except Text Text compileToLlvmIr' Text -text +text IO () -> Except Text (IO ()) forall a. a -> ExceptT Text Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -297,26 +297,26 @@ String -> IOMode -> (Handle -> IO ()) -> IO () forall r. String -> IOMode -> (Handle -> IO r) -> IO r withFile String -outputFilePath IOMode +outputFilePath IOMode WriteMode ((Handle -> IO ()) -> IO ()) -> (Handle -> IO ()) -> IO () forall a b. (a -> b) -> a -> b -$ \Handle -handle -> do +$ \Handle +handle -> do Handle -> Text -> IO () Txt.hPutStrLn Handle -handle Text -llvmIrText +handle Text +llvmIrText -- * Internal compileToLlvmIr' :: Text -> Except Text Text compileToLlvmIr' :: Text -> Except Text Text -compileToLlvmIr' Text -text = do - Module -irModule <- Text -> Except Text Module +compileToLlvmIr' Text +text = do + Module +irModule <- Text -> Except Text Module compileToModule Text -text +text Text -> Except Text Text forall a. a -> ExceptT Text Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -327,5 +327,5 @@ forall a b. (a -> b) -> a -> b $ Module -> Module genLlvmIrModule Module -irModule +irModule \ No newline at end of file diff --git a/src/CodeGen.Module.html b/src/CodeGen.Module.html index 49ad562..161a676 100644 --- a/src/CodeGen.Module.html +++ b/src/CodeGen.Module.html @@ -23,7 +23,7 @@ newtype Module = Module {Module -> Program code :: Anf.Program} - deriving (Int -> Module -> ShowS + deriving (Int -> Module -> ShowS [Module] -> ShowS Module -> String (Int -> Module -> ShowS) @@ -36,7 +36,7 @@ show :: Module -> String $cshowList :: [Module] -> ShowS showList :: [Module] -> ShowS -Show, Module -> Module -> Bool +Show, Module -> Module -> Bool (Module -> Module -> Bool) -> (Module -> Module -> Bool) -> Eq Module forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -48,14 +48,14 @@ compileToModule :: Text -> Except Text Module compileToModule :: Text -> Except Text Module -compileToModule Text -text = do - Program -program <- Text -> Except Text Program +compileToModule Text +text = do + Program +program <- Text -> Except Text Program parseAndVerify Text -text - let astToAnf :: Program -> Program -astToAnf = Program -> Program +text + let astToAnf :: Program -> Program +astToAnf = Program -> Program genAnf (Program -> Program) -> (Program -> Program) -> Program -> Program forall b c a. (b -> c) -> (a -> b) -> a -> c . Program -> Program @@ -69,37 +69,37 @@ forall b c a. (b -> c) -> (a -> b) -> a -> c . Program -> Program simplifyAst - anf :: Program -anf = Program -> Program -astToAnf Program -program - irMod :: Module -irMod = Program -> Module + anf :: Program +anf = Program -> Program +astToAnf Program +program + irMod :: Module +irMod = Program -> Module Module Program -anf +anf in Module -> Except Text Module forall a. a -> ExceptT Text Identity a forall (m :: * -> *) a. Monad m => a -> m a return Module -irMod +irMod parseAndVerify :: Text -> Except Text Program parseAndVerify :: Text -> Except Text Program -parseAndVerify Text -text = case Text -> Maybe Program +parseAndVerify Text +text = case Text -> Maybe Program parseProgram Text -text of - Just Program -program -> case Program -> Either TypeError () +text of + Just Program +program -> case Program -> Either TypeError () checkProgram Program -program of +program of Right () -> Program -> Except Text Program forall a. a -> ExceptT Text Identity a forall (m :: * -> *) a. Monad m => a -> m a return Program -program - Left TypeError -e -> Text -> Except Text Program +program + Left TypeError +e -> Text -> Except Text Program forall (m :: * -> *) e a. Monad m => e -> ExceptT e m a throwE (Text -> Except Text Program) -> Text -> Except Text Program forall a b. (a -> b) -> a -> b @@ -110,7 +110,7 @@ Txt.pack (TypeError -> String forall p. Pretty p => p -> String TC.pretty TypeError -e) +e) Maybe Program Nothing -> Text -> Except Text Program forall (m :: * -> *) e a. Monad m => e -> ExceptT e m a diff --git a/src/CodeGen.RiscV.AsmGen.html b/src/CodeGen.RiscV.AsmGen.html new file mode 100644 index 0000000..143d94d --- /dev/null +++ b/src/CodeGen.RiscV.AsmGen.html @@ -0,0 +1,708 @@ +
{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE RecursiveDo #-}
+
+module CodeGen.RiscV.AsmGen (ppRiscVAsm) where
+
+import CodeGen.Module (Module (..))
+import qualified CodeGen.RiscV.Lib as Rv
+import Control.Monad.State (MonadState, State, evalState, gets, modify)
+import Data.Map (Map)
+import qualified Data.Map as Map
+import Data.Text (Text)
+import qualified Data.Text as Txt
+import Foreign (fromBool)
+import MonadUtils (locally)
+import qualified StdLib
+import Transformations.Anf.Anf
+import Trees.Common
+
+ppRiscVAsm :: Module -> Text
+ppRiscVAsm :: Module -> Identifier
+ppRiscVAsm Module
+m = [CodeLine] -> Identifier
+Rv.ppCodeLines ([CodeLine] -> Identifier) -> [CodeLine] -> Identifier
+forall a b. (a -> b) -> a -> b
+$ Module -> [CodeLine]
+genModule Module
+m
+
+-- The Code
+
+type CodeGenM = Rv.AsmBuilderT (State Env)
+
+data Env = Env
+  { Env -> Map Identifier' Operand
+locVars :: Map Identifier' Rv.Operand,
+    Env -> Map Identifier' Operand
+globVars :: Map Identifier' Rv.Operand,
+    Env -> Map Identifier' (Operand, Arity)
+funs :: Map Identifier' (Rv.Operand, Arity)
+  }
+
+genModule :: Module -> [Rv.CodeLine]
+genModule :: Module -> [CodeLine]
+genModule (Module (Program [GlobalDeclaration]
+decls)) = (State Env [CodeLine] -> Env -> [CodeLine])
+-> Env -> State Env [CodeLine] -> [CodeLine]
+forall a b c. (a -> b -> c) -> b -> a -> c
+flip State Env [CodeLine] -> Env -> [CodeLine]
+forall s a. State s a -> s -> a
+evalState (Map Identifier' Operand
+-> Map Identifier' Operand
+-> Map Identifier' (Operand, Arity)
+-> Env
+Env Map Identifier' Operand
+forall k a. Map k a
+Map.empty Map Identifier' Operand
+forall k a. Map k a
+Map.empty Map Identifier' (Operand, Arity)
+forall k a. Map k a
+Map.empty) (State Env [CodeLine] -> [CodeLine])
+-> State Env [CodeLine] -> [CodeLine]
+forall a b. (a -> b) -> a -> b
+$
+  AsmBuilderT (State Env) () -> State Env [CodeLine]
+forall (m :: * -> *) a. Monad m => AsmBuilderT m a -> m [CodeLine]
+Rv.compileT (AsmBuilderT (State Env) () -> State Env [CodeLine])
+-> AsmBuilderT (State Env) () -> State Env [CodeLine]
+forall a b. (a -> b) -> a -> b
+$ do
+    (DeclarationWithArity -> AsmBuilderT (State Env) ())
+-> [DeclarationWithArity] -> AsmBuilderT (State Env) ()
+forall (t :: * -> *) (m :: * -> *) a b.
+(Foldable t, Monad m) =>
+(a -> m b) -> t a -> m ()
+mapM_ DeclarationWithArity -> AsmBuilderT (State Env) ()
+genStdLibDecl [DeclarationWithArity]
+StdLib.allDeclsWithArity
+    (GlobalDeclaration -> AsmBuilderT (State Env) ())
+-> [GlobalDeclaration] -> AsmBuilderT (State Env) ()
+forall (t :: * -> *) (m :: * -> *) a b.
+(Foldable t, Monad m) =>
+(a -> m b) -> t a -> m ()
+mapM_ GlobalDeclaration -> AsmBuilderT (State Env) ()
+genGlobDecl [GlobalDeclaration]
+decls
+
+    -- In the `main` we define our global variables.
+    (() -> AsmBuilderT (State Env) ()) -> AsmBuilderT (State Env) ()
+forall (m :: * -> *). MonadAsmBuilder m => (() -> m ()) -> m ()
+Rv.mainFunction ((() -> AsmBuilderT (State Env) ()) -> AsmBuilderT (State Env) ())
+-> (() -> AsmBuilderT (State Env) ()) -> AsmBuilderT (State Env) ()
+forall a b. (a -> b) -> a -> b
+$ \()
+_ -> (GlobalDeclaration -> AsmBuilderT (State Env) ())
+-> [GlobalDeclaration] -> AsmBuilderT (State Env) ()
+forall (t :: * -> *) (m :: * -> *) a b.
+(Foldable t, Monad m) =>
+(a -> m b) -> t a -> m ()
+mapM_ GlobalDeclaration -> AsmBuilderT (State Env) ()
+gVarDef [GlobalDeclaration]
+decls
+  where
+    gVarDef :: GlobalDeclaration -> CodeGenM ()
+    gVarDef :: GlobalDeclaration -> AsmBuilderT (State Env) ()
+gVarDef = \case
+      GlobVarDecl Identifier'
+ident Expression
+value -> do
+        Operand
+addr <- Identifier' -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadState Env m => Identifier' -> m Operand
+findGlobVar Identifier'
+ident
+        Operand
+value' <- Expression -> AsmBuilderT (State Env) Operand
+genExpr Expression
+value
+        Operand -> Operand -> AsmBuilderT (State Env) ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m ()
+Rv.storeToLabeledAddr Operand
+addr Operand
+value'
+      GlobalDeclaration
+_ -> () -> AsmBuilderT (State Env) ()
+forall a. a -> AsmBuilderT (State Env) a
+forall (m :: * -> *) a. Monad m => a -> m a
+return ()
+
+genStdLibDecl :: StdLib.DeclarationWithArity -> CodeGenM ()
+genStdLibDecl :: DeclarationWithArity -> AsmBuilderT (State Env) ()
+genStdLibDecl DeclarationWithArity
+decl = DeclarationWithArity -> AsmBuilderT (State Env) Operand
+declareAsExtern DeclarationWithArity
+decl AsmBuilderT (State Env) Operand
+-> (Operand -> AsmBuilderT (State Env) ())
+-> AsmBuilderT (State Env) ()
+forall a b.
+AsmBuilderT (State Env) a
+-> (a -> AsmBuilderT (State Env) b) -> AsmBuilderT (State Env) b
+forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
+>>= DeclarationWithArity -> Operand -> AsmBuilderT (State Env) ()
+register DeclarationWithArity
+decl
+  where
+    declareAsExtern :: StdLib.DeclarationWithArity -> CodeGenM Rv.Operand
+    declareAsExtern :: DeclarationWithArity -> AsmBuilderT (State Env) Operand
+declareAsExtern (Identifier
+ident, Arity
+_) = Identifier -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadAsmBuilder m => Identifier -> m Operand
+Rv.externFunction Identifier
+ident
+
+    register :: StdLib.DeclarationWithArity -> Rv.Operand -> CodeGenM ()
+    register :: DeclarationWithArity -> Operand -> AsmBuilderT (State Env) ()
+register (Identifier
+ident, Arity
+arity) Operand
+fun = Identifier' -> Operand -> Arity -> AsmBuilderT (State Env) ()
+forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> Arity -> m ()
+regFun (Identifier -> Identifier'
+Txt Identifier
+ident) Operand
+fun Arity
+arity
+
+genGlobDecl :: GlobalDeclaration -> CodeGenM ()
+genGlobDecl :: GlobalDeclaration -> AsmBuilderT (State Env) ()
+genGlobDecl = \case
+  GlobVarDecl Identifier'
+ident Expression
+_ -> do
+    Operand
+var <- Identifier -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadAsmBuilder m => Identifier -> m Operand
+Rv.globalVar (String -> Identifier
+Txt.pack (String -> Identifier) -> String -> Identifier
+forall a b. (a -> b) -> a -> b
+$ Identifier' -> String
+genId Identifier'
+ident)
+    Identifier' -> Operand -> AsmBuilderT (State Env) ()
+forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> m ()
+regGlobVar Identifier'
+ident Operand
+var
+  GlobFunDecl Identifier'
+ident [Identifier']
+params Expression
+body -> mdo
+    Identifier' -> Operand -> Arity -> AsmBuilderT (State Env) ()
+forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> Arity -> m ()
+regFun Identifier'
+ident Operand
+fun ([Identifier'] -> Arity
+forall a. [a] -> Arity
+forall (t :: * -> *) a. Foldable t => t a -> Arity
+length [Identifier']
+params)
+    Operand
+fun <- AsmBuilderT (State Env) Operand -> AsmBuilderT (State Env) Operand
+forall s (m :: * -> *) a. MonadState s m => m a -> m a
+locally (AsmBuilderT (State Env) Operand
+ -> AsmBuilderT (State Env) Operand)
+-> AsmBuilderT (State Env) Operand
+-> AsmBuilderT (State Env) Operand
+forall a b. (a -> b) -> a -> b
+$ do
+      Identifier
+-> Int64
+-> ([Operand] -> AsmBuilderT (State Env) Operand)
+-> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Identifier -> Int64 -> ([Operand] -> m Operand) -> m Operand
+Rv.function
+        (String -> Identifier
+Txt.pack (String -> Identifier) -> String -> Identifier
+forall a b. (a -> b) -> a -> b
+$ Identifier' -> String
+genId Identifier'
+ident)
+        (Arity -> Int64
+forall a b. (Integral a, Num b) => a -> b
+fromIntegral (Arity -> Int64) -> Arity -> Int64
+forall a b. (a -> b) -> a -> b
+$ [Identifier'] -> Arity
+forall a. [a] -> Arity
+forall (t :: * -> *) a. Foldable t => t a -> Arity
+length [Identifier']
+params)
+        (([Operand] -> AsmBuilderT (State Env) Operand)
+ -> AsmBuilderT (State Env) Operand)
+-> ([Operand] -> AsmBuilderT (State Env) Operand)
+-> AsmBuilderT (State Env) Operand
+forall a b. (a -> b) -> a -> b
+$ \[Operand]
+args -> do
+          ((Identifier', Operand) -> AsmBuilderT (State Env) ())
+-> [(Identifier', Operand)] -> AsmBuilderT (State Env) ()
+forall (t :: * -> *) (m :: * -> *) a b.
+(Foldable t, Monad m) =>
+(a -> m b) -> t a -> m ()
+mapM_ ((Identifier' -> Operand -> AsmBuilderT (State Env) ())
+-> (Identifier', Operand) -> AsmBuilderT (State Env) ()
+forall a b c. (a -> b -> c) -> (a, b) -> c
+uncurry Identifier' -> Operand -> AsmBuilderT (State Env) ()
+forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> m ()
+regLocVar) ([Identifier']
+params [Identifier'] -> [Operand] -> [(Identifier', Operand)]
+forall a b. [a] -> [b] -> [(a, b)]
+`zip` [Operand]
+args)
+          Expression -> AsmBuilderT (State Env) Operand
+genExpr Expression
+body
+    () -> AsmBuilderT (State Env) ()
+forall a. a -> AsmBuilderT (State Env) a
+forall (m :: * -> *) a. Monad m => a -> m a
+return ()
+
+genId :: Identifier' -> String
+genId :: Identifier' -> String
+genId = \case
+  Txt Identifier
+txt -> Identifier -> String
+Txt.unpack Identifier
+txt
+  Gen Arity
+n Identifier
+txt -> Identifier -> String
+Txt.unpack Identifier
+txt String -> String -> String
+forall a. Semigroup a => a -> a -> a
+<> String
+"_" String -> String -> String
+forall a. Semigroup a => a -> a -> a
+<> Arity -> String
+forall a. Show a => a -> String
+show Arity
+n
+
+genExpr :: Expression -> CodeGenM Rv.Operand
+genExpr :: Expression -> AsmBuilderT (State Env) Operand
+genExpr = \case
+  ExprAtom AtomicExpression
+atom -> AtomicExpression -> AsmBuilderT (State Env) Operand
+genAtom AtomicExpression
+atom
+  ExprComp ComplexExpression
+ce -> ComplexExpression -> AsmBuilderT (State Env) Operand
+genComp ComplexExpression
+ce
+  ExprLetIn (Identifier'
+ident, Expression
+val) Expression
+expr -> do
+    Operand
+val' <- Expression -> AsmBuilderT (State Env) Operand
+genExpr Expression
+val
+    Identifier' -> Operand -> AsmBuilderT (State Env) ()
+forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> m ()
+regLocVar Identifier'
+ident Operand
+val'
+    Expression -> AsmBuilderT (State Env) Operand
+genExpr Expression
+expr
+
+genAtom :: AtomicExpression -> CodeGenM Rv.Operand
+genAtom :: AtomicExpression -> AsmBuilderT (State Env) Operand
+genAtom = \case
+  AtomId Identifier'
+ident -> Identifier' -> AsmBuilderT (State Env) Operand
+findAny Identifier'
+ident
+  AtomicExpression
+AtomUnit -> Int64 -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Operand
+Rv.immediate Int64
+0
+  AtomBool Bool
+bool -> Int64 -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Operand
+Rv.immediate (Int64 -> AsmBuilderT (State Env) Operand)
+-> Int64 -> AsmBuilderT (State Env) Operand
+forall a b. (a -> b) -> a -> b
+$ Bool -> Int64
+forall a. Num a => Bool -> a
+fromBool Bool
+bool
+  AtomInt Int64
+int -> Int64 -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Operand
+Rv.immediate Int64
+int
+
+genComp :: ComplexExpression -> CodeGenM Rv.Operand
+genComp :: ComplexExpression -> AsmBuilderT (State Env) Operand
+genComp = \case
+  CompApp Identifier'
+f AtomicExpression
+arg -> do
+    Operand
+f' <- Identifier' -> AsmBuilderT (State Env) Operand
+findAny Identifier'
+f
+    Operand
+arg' <- AtomicExpression -> AsmBuilderT (State Env) Operand
+genAtom AtomicExpression
+arg
+    Operand
+applyF <- Identifier' -> AsmBuilderT (State Env) Operand
+findFun (Identifier -> Identifier'
+Txt Identifier
+"miniml_apply")
+    Operand -> [Operand] -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> [Operand] -> m Operand
+Rv.call Operand
+applyF [Operand
+f', Operand
+arg']
+  CompIte AtomicExpression
+c Expression
+t Expression
+e -> do
+    Operand
+c' <- AtomicExpression -> AsmBuilderT (State Env) Operand
+genAtom AtomicExpression
+c
+    Operand
+-> (() -> AsmBuilderT (State Env) Operand)
+-> (() -> AsmBuilderT (State Env) Operand)
+-> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> (() -> m Operand) -> (() -> m Operand) -> m Operand
+Rv.ite Operand
+c' (\()
+_ -> Expression -> AsmBuilderT (State Env) Operand
+genExpr Expression
+t) (\()
+_ -> Expression -> AsmBuilderT (State Env) Operand
+genExpr Expression
+e)
+  CompBinOp BinaryOperator
+op AtomicExpression
+lhs AtomicExpression
+rhs -> do
+    Operand
+lhs' <- AtomicExpression -> AsmBuilderT (State Env) Operand
+genAtom AtomicExpression
+lhs
+    Operand
+rhs' <- AtomicExpression -> AsmBuilderT (State Env) Operand
+genAtom AtomicExpression
+rhs
+    let opF :: Operand -> Operand -> AsmBuilderT (State Env) Operand
+opF = case BinaryOperator
+op of
+          BoolOp BooleanOperator
+AndOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.and
+          BoolOp BooleanOperator
+OrOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.or
+          ArithOp ArithmeticOperator
+PlusOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.add
+          ArithOp ArithmeticOperator
+MinusOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.sub
+          ArithOp ArithmeticOperator
+MulOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.mul
+          ArithOp ArithmeticOperator
+DivOp ->
+            ( \Operand
+lhs'' Operand
+rhs'' -> do
+                Operand
+divF <- Identifier' -> AsmBuilderT (State Env) Operand
+findFun (Identifier -> Identifier'
+Txt Identifier
+"miniml_div")
+                Operand -> [Operand] -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> [Operand] -> m Operand
+Rv.call Operand
+divF [Operand
+lhs'', Operand
+rhs'']
+            )
+          CompOp ComparisonOperator
+EqOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.eq
+          CompOp ComparisonOperator
+NeOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.ne
+          CompOp ComparisonOperator
+LtOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.lt
+          CompOp ComparisonOperator
+LeOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.le
+          CompOp ComparisonOperator
+GtOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.gt
+          CompOp ComparisonOperator
+GeOp -> Operand -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+Rv.ge
+    Operand -> Operand -> AsmBuilderT (State Env) Operand
+opF Operand
+lhs' Operand
+rhs'
+  CompUnOp UnaryOperator
+op AtomicExpression
+x -> do
+    Operand
+x' <- AtomicExpression -> AsmBuilderT (State Env) Operand
+genAtom AtomicExpression
+x
+    let opF :: Operand -> AsmBuilderT (State Env) Operand
+opF = case UnaryOperator
+op of
+          UnaryOperator
+UnMinusOp -> Operand -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadAsmBuilder m => Operand -> m Operand
+Rv.neg
+    Operand -> AsmBuilderT (State Env) Operand
+opF Operand
+x'
+
+-- Vars & Funs
+
+findAny :: Identifier' -> CodeGenM Rv.Operand
+findAny :: Identifier' -> AsmBuilderT (State Env) Operand
+findAny Identifier'
+ident = do
+  Maybe Operand
+maybeLocVar <- (Env -> Maybe Operand) -> AsmBuilderT (State Env) (Maybe Operand)
+forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
+gets ((Map Identifier' Operand -> Identifier' -> Maybe Operand
+forall k a. Ord k => Map k a -> k -> Maybe a
+Map.!? Identifier'
+ident) (Map Identifier' Operand -> Maybe Operand)
+-> (Env -> Map Identifier' Operand) -> Env -> Maybe Operand
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. Env -> Map Identifier' Operand
+locVars)
+  case Maybe Operand
+maybeLocVar of
+    Just Operand
+locVar -> Operand -> AsmBuilderT (State Env) Operand
+forall a. a -> AsmBuilderT (State Env) a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Operand
+locVar
+    Maybe Operand
+Nothing -> do
+      Maybe (Operand, Arity)
+maybeFun <- (Env -> Maybe (Operand, Arity))
+-> AsmBuilderT (State Env) (Maybe (Operand, Arity))
+forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
+gets ((Map Identifier' (Operand, Arity)
+-> Identifier' -> Maybe (Operand, Arity)
+forall k a. Ord k => Map k a -> k -> Maybe a
+Map.!? Identifier'
+ident) (Map Identifier' (Operand, Arity) -> Maybe (Operand, Arity))
+-> (Env -> Map Identifier' (Operand, Arity))
+-> Env
+-> Maybe (Operand, Arity)
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. Env -> Map Identifier' (Operand, Arity)
+funs)
+      case Maybe (Operand, Arity)
+maybeFun of
+        Just (Operand
+fun, Arity
+arity) -> do
+          Operand
+funToPafF <- Identifier' -> AsmBuilderT (State Env) Operand
+findFun (Identifier -> Identifier'
+Txt Identifier
+"miniml_fun_to_paf")
+          Operand
+arity' <- Int64 -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Operand
+Rv.immediate (Int64 -> AsmBuilderT (State Env) Operand)
+-> Int64 -> AsmBuilderT (State Env) Operand
+forall a b. (a -> b) -> a -> b
+$ Arity -> Int64
+forall a b. (Integral a, Num b) => a -> b
+fromIntegral Arity
+arity
+          Operand -> [Operand] -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> [Operand] -> m Operand
+Rv.call Operand
+funToPafF [Operand
+fun, Operand
+arity']
+        Maybe (Operand, Arity)
+Nothing -> Identifier' -> AsmBuilderT (State Env) Operand
+forall (m :: * -> *). MonadState Env m => Identifier' -> m Operand
+findGlobVar Identifier'
+ident
+
+findGlobVar :: (MonadState Env m) => Identifier' -> m Rv.Operand
+findGlobVar :: forall (m :: * -> *). MonadState Env m => Identifier' -> m Operand
+findGlobVar Identifier'
+ident = (Env -> Operand) -> m Operand
+forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
+gets ((Map Identifier' Operand -> Identifier' -> Operand
+forall k a. Ord k => Map k a -> k -> a
+Map.! Identifier'
+ident) (Map Identifier' Operand -> Operand)
+-> (Env -> Map Identifier' Operand) -> Env -> Operand
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. Env -> Map Identifier' Operand
+globVars)
+
+findFun :: Identifier' -> CodeGenM Rv.Operand
+findFun :: Identifier' -> AsmBuilderT (State Env) Operand
+findFun Identifier'
+ident = (Env -> Operand) -> AsmBuilderT (State Env) Operand
+forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
+gets ((Operand, Arity) -> Operand
+forall a b. (a, b) -> a
+fst ((Operand, Arity) -> Operand)
+-> (Env -> (Operand, Arity)) -> Env -> Operand
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. (Map Identifier' (Operand, Arity) -> Identifier' -> (Operand, Arity)
+forall k a. Ord k => Map k a -> k -> a
+Map.! Identifier'
+ident) (Map Identifier' (Operand, Arity) -> (Operand, Arity))
+-> (Env -> Map Identifier' (Operand, Arity))
+-> Env
+-> (Operand, Arity)
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. Env -> Map Identifier' (Operand, Arity)
+funs)
+
+regLocVar :: (MonadState Env m) => Identifier' -> Rv.Operand -> m ()
+regLocVar :: forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> m ()
+regLocVar Identifier'
+ident Operand
+var = (Env -> Env) -> m ()
+forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
+modify ((Env -> Env) -> m ()) -> (Env -> Env) -> m ()
+forall a b. (a -> b) -> a -> b
+$
+  \Env
+env -> Env
+env {locVars :: Map Identifier' Operand
+locVars = Identifier'
+-> Operand -> Map Identifier' Operand -> Map Identifier' Operand
+forall k a. Ord k => k -> a -> Map k a -> Map k a
+Map.insert Identifier'
+ident Operand
+var (Env -> Map Identifier' Operand
+locVars Env
+env)}
+
+regGlobVar :: (MonadState Env m) => Identifier' -> Rv.Operand -> m ()
+regGlobVar :: forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> m ()
+regGlobVar Identifier'
+ident Operand
+gVar = (Env -> Env) -> m ()
+forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
+modify ((Env -> Env) -> m ()) -> (Env -> Env) -> m ()
+forall a b. (a -> b) -> a -> b
+$
+  \Env
+env -> Env
+env {globVars :: Map Identifier' Operand
+globVars = Identifier'
+-> Operand -> Map Identifier' Operand -> Map Identifier' Operand
+forall k a. Ord k => k -> a -> Map k a -> Map k a
+Map.insert Identifier'
+ident Operand
+gVar (Env -> Map Identifier' Operand
+globVars Env
+env)}
+
+regFun :: (MonadState Env m) => Identifier' -> Rv.Operand -> Arity -> m ()
+regFun :: forall (m :: * -> *).
+MonadState Env m =>
+Identifier' -> Operand -> Arity -> m ()
+regFun Identifier'
+ident Operand
+fun Arity
+paramsCnt = (Env -> Env) -> m ()
+forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
+modify ((Env -> Env) -> m ()) -> (Env -> Env) -> m ()
+forall a b. (a -> b) -> a -> b
+$
+  \Env
+env -> Env
+env {funs :: Map Identifier' (Operand, Arity)
+funs = Identifier'
+-> (Operand, Arity)
+-> Map Identifier' (Operand, Arity)
+-> Map Identifier' (Operand, Arity)
+forall k a. Ord k => k -> a -> Map k a -> Map k a
+Map.insert Identifier'
+ident (Operand
+fun, Arity
+paramsCnt) (Env -> Map Identifier' (Operand, Arity)
+funs Env
+env)}
+
\ No newline at end of file diff --git a/src/CodeGen.RiscV.Lib.Monad.html b/src/CodeGen.RiscV.Lib.Monad.html new file mode 100644 index 0000000..e0ea9f3 --- /dev/null +++ b/src/CodeGen.RiscV.Lib.Monad.html @@ -0,0 +1,294 @@ +
{-# LANGUAGE DefaultSignatures #-}
+{-# LANGUAGE DerivingVia #-}
+{-# LANGUAGE FlexibleInstances #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
+{-# LANGUAGE TypeOperators #-}
+{-# LANGUAGE UndecidableInstances #-}
+
+module CodeGen.RiscV.Lib.Monad where
+
+import CodeGen.RiscV.Lib.Types (CodeLine)
+import Control.Monad.Fix (MonadFix)
+import Control.Monad.Identity (Identity (..))
+import Control.Monad.State (MonadState (..), StateT (..), get, modify)
+import Control.Monad.Trans (MonadTrans (..))
+import Data.Int (Int64)
+
+newtype AsmBuilderT m a = AsmBuilderT {forall (m :: * -> *) a. AsmBuilderT m a -> StateT BuilderState m a
+unAsmBuilderT :: StateT BuilderState m a}
+  deriving ((forall a b. (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b)
+-> (forall a b. a -> AsmBuilderT m b -> AsmBuilderT m a)
+-> Functor (AsmBuilderT m)
+forall a b. a -> AsmBuilderT m b -> AsmBuilderT m a
+forall a b. (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+forall (m :: * -> *) a b.
+Functor m =>
+a -> AsmBuilderT m b -> AsmBuilderT m a
+forall (m :: * -> *) a b.
+Functor m =>
+(a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+forall (f :: * -> *).
+(forall a b. (a -> b) -> f a -> f b)
+-> (forall a b. a -> f b -> f a) -> Functor f
+$cfmap :: forall (m :: * -> *) a b.
+Functor m =>
+(a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+fmap :: forall a b. (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+$c<$ :: forall (m :: * -> *) a b.
+Functor m =>
+a -> AsmBuilderT m b -> AsmBuilderT m a
+<$ :: forall a b. a -> AsmBuilderT m b -> AsmBuilderT m a
+Functor, Functor (AsmBuilderT m)
+Functor (AsmBuilderT m)
+-> (forall a. a -> AsmBuilderT m a)
+-> (forall a b.
+    AsmBuilderT m (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b)
+-> (forall a b c.
+    (a -> b -> c)
+    -> AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m c)
+-> (forall a b.
+    AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b)
+-> (forall a b.
+    AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m a)
+-> Applicative (AsmBuilderT m)
+forall a. a -> AsmBuilderT m a
+forall a b. AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m a
+forall a b. AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+forall a b.
+AsmBuilderT m (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+forall a b c.
+(a -> b -> c)
+-> AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m c
+forall {m :: * -> *}. Monad m => Functor (AsmBuilderT m)
+forall (m :: * -> *) a. Monad m => a -> AsmBuilderT m a
+forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m a
+forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+forall (m :: * -> *) a b c.
+Monad m =>
+(a -> b -> c)
+-> AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m c
+forall (f :: * -> *).
+Functor f
+-> (forall a. a -> f a)
+-> (forall a b. f (a -> b) -> f a -> f b)
+-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
+-> (forall a b. f a -> f b -> f b)
+-> (forall a b. f a -> f b -> f a)
+-> Applicative f
+$cpure :: forall (m :: * -> *) a. Monad m => a -> AsmBuilderT m a
+pure :: forall a. a -> AsmBuilderT m a
+$c<*> :: forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+<*> :: forall a b.
+AsmBuilderT m (a -> b) -> AsmBuilderT m a -> AsmBuilderT m b
+$cliftA2 :: forall (m :: * -> *) a b c.
+Monad m =>
+(a -> b -> c)
+-> AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m c
+liftA2 :: forall a b c.
+(a -> b -> c)
+-> AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m c
+$c*> :: forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+*> :: forall a b. AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+$c<* :: forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m a
+<* :: forall a b. AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m a
+Applicative, Applicative (AsmBuilderT m)
+Applicative (AsmBuilderT m)
+-> (forall a b.
+    AsmBuilderT m a -> (a -> AsmBuilderT m b) -> AsmBuilderT m b)
+-> (forall a b.
+    AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b)
+-> (forall a. a -> AsmBuilderT m a)
+-> Monad (AsmBuilderT m)
+forall a. a -> AsmBuilderT m a
+forall a b. AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+forall a b.
+AsmBuilderT m a -> (a -> AsmBuilderT m b) -> AsmBuilderT m b
+forall (m :: * -> *). Monad m => Applicative (AsmBuilderT m)
+forall (m :: * -> *) a. Monad m => a -> AsmBuilderT m a
+forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> (a -> AsmBuilderT m b) -> AsmBuilderT m b
+forall (m :: * -> *).
+Applicative m
+-> (forall a b. m a -> (a -> m b) -> m b)
+-> (forall a b. m a -> m b -> m b)
+-> (forall a. a -> m a)
+-> Monad m
+$c>>= :: forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> (a -> AsmBuilderT m b) -> AsmBuilderT m b
+>>= :: forall a b.
+AsmBuilderT m a -> (a -> AsmBuilderT m b) -> AsmBuilderT m b
+$c>> :: forall (m :: * -> *) a b.
+Monad m =>
+AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+>> :: forall a b. AsmBuilderT m a -> AsmBuilderT m b -> AsmBuilderT m b
+$creturn :: forall (m :: * -> *) a. Monad m => a -> AsmBuilderT m a
+return :: forall a. a -> AsmBuilderT m a
+Monad, Monad (AsmBuilderT m)
+Monad (AsmBuilderT m)
+-> (forall a. (a -> AsmBuilderT m a) -> AsmBuilderT m a)
+-> MonadFix (AsmBuilderT m)
+forall a. (a -> AsmBuilderT m a) -> AsmBuilderT m a
+forall (m :: * -> *).
+Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
+forall {m :: * -> *}. MonadFix m => Monad (AsmBuilderT m)
+forall (m :: * -> *) a.
+MonadFix m =>
+(a -> AsmBuilderT m a) -> AsmBuilderT m a
+$cmfix :: forall (m :: * -> *) a.
+MonadFix m =>
+(a -> AsmBuilderT m a) -> AsmBuilderT m a
+mfix :: forall a. (a -> AsmBuilderT m a) -> AsmBuilderT m a
+MonadFix) via StateT BuilderState m
+
+data BuilderState = BS
+  { BuilderState -> ProgramBuilderState
+programBS :: ProgramBuilderState,
+    BuilderState -> FunctionBuilderState
+functionBS :: FunctionBuilderState,
+    BuilderState -> Integer
+idCnt :: Integer
+  }
+
+data ProgramBuilderState = PBS
+  { ProgramBuilderState -> [[CodeLine]]
+sectionText :: [[CodeLine]],
+    ProgramBuilderState -> [CodeLine]
+sectionData :: [CodeLine]
+  }
+
+data FunctionBuilderState = FBS
+  { FunctionBuilderState -> [[CodeLine]]
+functionCodeLines :: [[CodeLine]],
+    FunctionBuilderState -> Int64
+stackPointerOffset :: Int64 -- In double words
+  }
+
+emptyBS :: BuilderState
+emptyBS :: BuilderState
+emptyBS = ProgramBuilderState
+-> FunctionBuilderState -> Integer -> BuilderState
+BS ProgramBuilderState
+emptyPBS FunctionBuilderState
+emptyFBS Integer
+0
+
+emptyPBS :: ProgramBuilderState
+emptyPBS :: ProgramBuilderState
+emptyPBS = [[CodeLine]] -> [CodeLine] -> ProgramBuilderState
+PBS [] []
+
+emptyFBS :: FunctionBuilderState
+emptyFBS :: FunctionBuilderState
+emptyFBS = [[CodeLine]] -> Int64 -> FunctionBuilderState
+FBS [] Int64
+0
+
+instance (MonadState s m) => MonadState s (AsmBuilderT m) where
+  state :: forall a. (s -> (a, s)) -> AsmBuilderT m a
+state = m a -> AsmBuilderT m a
+forall (m :: * -> *) a. Monad m => m a -> AsmBuilderT m a
+forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
+(MonadTrans t, Monad m) =>
+m a -> t m a
+lift (m a -> AsmBuilderT m a)
+-> ((s -> (a, s)) -> m a) -> (s -> (a, s)) -> AsmBuilderT m a
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. (s -> (a, s)) -> m a
+forall a. (s -> (a, s)) -> m a
+forall s (m :: * -> *) a. MonadState s m => (s -> (a, s)) -> m a
+state
+
+instance MonadTrans AsmBuilderT where
+  lift :: forall (m :: * -> *) a. Monad m => m a -> AsmBuilderT m a
+lift = StateT BuilderState m a -> AsmBuilderT m a
+forall (m :: * -> *) a. StateT BuilderState m a -> AsmBuilderT m a
+AsmBuilderT (StateT BuilderState m a -> AsmBuilderT m a)
+-> (m a -> StateT BuilderState m a) -> m a -> AsmBuilderT m a
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. m a -> StateT BuilderState m a
+forall (m :: * -> *) a. Monad m => m a -> StateT BuilderState m a
+forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
+(MonadTrans t, Monad m) =>
+m a -> t m a
+lift
+
+type AsmBuilder = AsmBuilderT Identity
+
+class (Monad m) => MonadAsmBuilder m where
+  getAsmBuilderState :: m BuilderState
+
+  modifyAsmBuilderState :: (BuilderState -> BuilderState) -> m ()
+
+  default getAsmBuilderState ::
+    (MonadTrans t, MonadAsmBuilder m1, m ~ t m1) =>
+    m BuilderState
+  getAsmBuilderState = m1 BuilderState -> t m1 BuilderState
+forall (m :: * -> *) a. Monad m => m a -> t m a
+forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
+(MonadTrans t, Monad m) =>
+m a -> t m a
+lift m1 BuilderState
+forall (m :: * -> *). MonadAsmBuilder m => m BuilderState
+getAsmBuilderState
+
+  default modifyAsmBuilderState ::
+    (MonadTrans t, MonadAsmBuilder m1, m ~ t m1) =>
+    (BuilderState -> BuilderState) ->
+    m ()
+  modifyAsmBuilderState = m1 () -> m ()
+m1 () -> t m1 ()
+forall (m :: * -> *) a. Monad m => m a -> t m a
+forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
+(MonadTrans t, Monad m) =>
+m a -> t m a
+lift (m1 () -> m ())
+-> ((BuilderState -> BuilderState) -> m1 ())
+-> (BuilderState -> BuilderState)
+-> m ()
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. (BuilderState -> BuilderState) -> m1 ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState
+
+instance (Monad m) => MonadAsmBuilder (AsmBuilderT m) where
+  getAsmBuilderState :: AsmBuilderT m BuilderState
+getAsmBuilderState = StateT BuilderState m BuilderState -> AsmBuilderT m BuilderState
+forall (m :: * -> *) a. StateT BuilderState m a -> AsmBuilderT m a
+AsmBuilderT StateT BuilderState m BuilderState
+forall s (m :: * -> *). MonadState s m => m s
+get
+
+  modifyAsmBuilderState :: (BuilderState -> BuilderState) -> AsmBuilderT m ()
+modifyAsmBuilderState = StateT BuilderState m () -> AsmBuilderT m ()
+forall (m :: * -> *) a. StateT BuilderState m a -> AsmBuilderT m a
+AsmBuilderT (StateT BuilderState m () -> AsmBuilderT m ())
+-> ((BuilderState -> BuilderState) -> StateT BuilderState m ())
+-> (BuilderState -> BuilderState)
+-> AsmBuilderT m ()
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. (BuilderState -> BuilderState) -> StateT BuilderState m ()
+forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
+modify
+
+instance (MonadAsmBuilder m) => MonadAsmBuilder (StateT s m)
+
\ No newline at end of file diff --git a/src/CodeGen.RiscV.Lib.Types.html b/src/CodeGen.RiscV.Lib.Types.html new file mode 100644 index 0000000..2d63c32 --- /dev/null +++ b/src/CodeGen.RiscV.Lib.Types.html @@ -0,0 +1,437 @@ +
{-# LANGUAGE PatternSynonyms #-}
+
+module CodeGen.RiscV.Lib.Types where
+
+import Control.Arrow ((>>>))
+import Data.Char (toLower)
+import Data.Int (Int64)
+import Data.Text (Text)
+import Prettyprinter (Pretty (pretty), colon, comma, hsep, indent, layoutCompact, parens, punctuate, vsep, (<+>))
+import Prettyprinter.Render.Text (renderStrict)
+
+ppCodeLines :: [CodeLine] -> Text
+ppCodeLines :: [CodeLine] -> Text
+ppCodeLines =
+  (CodeLine -> Doc Any) -> [CodeLine] -> [Doc Any]
+forall a b. (a -> b) -> [a] -> [b]
+map CodeLine -> Doc Any
+forall a ann. Pretty a => a -> Doc ann
+forall ann. CodeLine -> Doc ann
+pretty
+    ([CodeLine] -> [Doc Any])
+-> ([Doc Any] -> Text) -> [CodeLine] -> Text
+forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
+Category cat =>
+cat a b -> cat b c -> cat a c
+>>> [Doc Any] -> Doc Any
+forall ann. [Doc ann] -> Doc ann
+vsep
+    ([Doc Any] -> Doc Any) -> (Doc Any -> Text) -> [Doc Any] -> Text
+forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
+Category cat =>
+cat a b -> cat b c -> cat a c
+>>> Doc Any -> SimpleDocStream Any
+forall ann1 ann2. Doc ann1 -> SimpleDocStream ann2
+layoutCompact
+    (Doc Any -> SimpleDocStream Any)
+-> (SimpleDocStream Any -> Text) -> Doc Any -> Text
+forall {k} (cat :: k -> k -> *) (a :: k) (b :: k) (c :: k).
+Category cat =>
+cat a b -> cat b c -> cat a c
+>>> SimpleDocStream Any -> Text
+forall ann. SimpleDocStream ann -> Text
+renderStrict
+
+data CodeLine
+  = LabeledDirectiveCodeLine Label Directive
+  | LabelCodeLine Label
+  | InstructionCodeLine Instruction
+  | DirectiveCodeLine Directive
+
+instance Pretty CodeLine where
+  pretty :: forall ann. CodeLine -> Doc ann
+pretty (LabeledDirectiveCodeLine Label
+l Directive
+d) = Label -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Label -> Doc ann
+pretty Label
+l Doc ann -> Doc ann -> Doc ann
+forall ann. Doc ann -> Doc ann -> Doc ann
+<+> Directive -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Directive -> Doc ann
+pretty Directive
+d
+  pretty (LabelCodeLine Label
+l) = Label -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Label -> Doc ann
+pretty Label
+l
+  pretty (InstructionCodeLine Instruction
+i) = Int -> Doc ann -> Doc ann
+forall ann. Int -> Doc ann -> Doc ann
+indent Int
+4 (Instruction -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Instruction -> Doc ann
+pretty Instruction
+i)
+  pretty (DirectiveCodeLine Directive
+d) = Directive -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Directive -> Doc ann
+pretty Directive
+d
+
+newtype Label = Label Text
+
+instance Pretty Label where
+  pretty :: forall ann. Label -> Doc ann
+pretty (Label Text
+txt) = Text -> Doc ann
+forall ann. Text -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty Text
+txt Doc ann -> Doc ann -> Doc ann
+forall a. Semigroup a => a -> a -> a
+<> Doc ann
+forall ann. Doc ann
+colon
+
+data Instruction = Instruction OpCode [Operand]
+
+instance Pretty Instruction where
+  pretty :: forall ann. Instruction -> Doc ann
+pretty (Instruction OpCode
+opCode [Operand]
+args) = [Doc ann] -> Doc ann
+forall ann. [Doc ann] -> Doc ann
+hsep ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
+forall a b. (a -> b) -> a -> b
+$ OpCode -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. OpCode -> Doc ann
+pretty OpCode
+opCode Doc ann -> [Doc ann] -> [Doc ann]
+forall a. a -> [a] -> [a]
+: Doc ann -> [Doc ann] -> [Doc ann]
+forall ann. Doc ann -> [Doc ann] -> [Doc ann]
+punctuate Doc ann
+forall ann. Doc ann
+comma (Operand -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Operand -> Doc ann
+pretty (Operand -> Doc ann) -> [Operand] -> [Doc ann]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> [Operand]
+args)
+
+data Directive
+  = DirText
+  | DirData
+  | DirDWord Int64
+  | DirGlobl Text
+
+instance Pretty Directive where
+  pretty :: forall ann. Directive -> Doc ann
+pretty Directive
+DirText = String -> Doc ann
+forall ann. String -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty String
+".section .text"
+  pretty Directive
+DirData = String -> Doc ann
+forall ann. String -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty String
+".section .data"
+  pretty (DirDWord Int64
+initVal) = String -> Doc ann
+forall ann. String -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty String
+".dword" Doc ann -> Doc ann -> Doc ann
+forall ann. Doc ann -> Doc ann -> Doc ann
+<+> Int64 -> Doc ann
+forall ann. Int64 -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty Int64
+initVal
+  pretty (DirGlobl Text
+name) = String -> Doc ann
+forall ann. String -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty String
+".globl" Doc ann -> Doc ann -> Doc ann
+forall ann. Doc ann -> Doc ann -> Doc ann
+<+> Text -> Doc ann
+forall ann. Text -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty Text
+name
+
+data OpCode
+  = And
+  | Or
+  | Add
+  | Sub
+  | Mul
+  | Neg
+  | Seqz
+  | Snez
+  | Slt
+  | Sd
+  | Ld
+  | Li
+  | La
+  | Addi
+  | Beqz
+  | J
+  | Call
+  | Ret
+  deriving (Int -> OpCode -> ShowS
+[OpCode] -> ShowS
+OpCode -> String
+(Int -> OpCode -> ShowS)
+-> (OpCode -> String) -> ([OpCode] -> ShowS) -> Show OpCode
+forall a.
+(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
+$cshowsPrec :: Int -> OpCode -> ShowS
+showsPrec :: Int -> OpCode -> ShowS
+$cshow :: OpCode -> String
+show :: OpCode -> String
+$cshowList :: [OpCode] -> ShowS
+showList :: [OpCode] -> ShowS
+Show)
+
+instance Pretty OpCode where
+  pretty :: forall ann. OpCode -> Doc ann
+pretty OpCode
+opCode = String -> Doc ann
+forall ann. String -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty (String -> Doc ann) -> String -> Doc ann
+forall a b. (a -> b) -> a -> b
+$ Char -> Char
+toLower (Char -> Char) -> ShowS
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> OpCode -> String
+forall a. Show a => a -> String
+show OpCode
+opCode
+
+data Operand
+  = Immediate Int64
+  | Register Register
+  | RegisterWithOffset Register Offset
+  | Symbol Text
+  deriving (Operand -> Operand -> Bool
+(Operand -> Operand -> Bool)
+-> (Operand -> Operand -> Bool) -> Eq Operand
+forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
+$c== :: Operand -> Operand -> Bool
+== :: Operand -> Operand -> Bool
+$c/= :: Operand -> Operand -> Bool
+/= :: Operand -> Operand -> Bool
+Eq, Eq Operand
+Eq Operand
+-> (Operand -> Operand -> Ordering)
+-> (Operand -> Operand -> Bool)
+-> (Operand -> Operand -> Bool)
+-> (Operand -> Operand -> Bool)
+-> (Operand -> Operand -> Bool)
+-> (Operand -> Operand -> Operand)
+-> (Operand -> Operand -> Operand)
+-> Ord Operand
+Operand -> Operand -> Bool
+Operand -> Operand -> Ordering
+Operand -> Operand -> Operand
+forall a.
+Eq a
+-> (a -> a -> Ordering)
+-> (a -> a -> Bool)
+-> (a -> a -> Bool)
+-> (a -> a -> Bool)
+-> (a -> a -> Bool)
+-> (a -> a -> a)
+-> (a -> a -> a)
+-> Ord a
+$ccompare :: Operand -> Operand -> Ordering
+compare :: Operand -> Operand -> Ordering
+$c< :: Operand -> Operand -> Bool
+< :: Operand -> Operand -> Bool
+$c<= :: Operand -> Operand -> Bool
+<= :: Operand -> Operand -> Bool
+$c> :: Operand -> Operand -> Bool
+> :: Operand -> Operand -> Bool
+$c>= :: Operand -> Operand -> Bool
+>= :: Operand -> Operand -> Bool
+$cmax :: Operand -> Operand -> Operand
+max :: Operand -> Operand -> Operand
+$cmin :: Operand -> Operand -> Operand
+min :: Operand -> Operand -> Operand
+Ord)
+
+pattern Memory :: Offset -> Operand
+pattern $mMemory :: forall {r}. Operand -> (Int64 -> r) -> ((# #) -> r) -> r
+$bMemory :: Int64 -> Operand
+Memory offset = RegisterWithOffset Sp offset
+
+instance Pretty Operand where
+  pretty :: forall ann. Operand -> Doc ann
+pretty (Immediate Int64
+i) = Int64 -> Doc ann
+forall ann. Int64 -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty Int64
+i
+  pretty (Register Register
+r) = Register -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Register -> Doc ann
+pretty Register
+r
+  pretty (RegisterWithOffset Register
+r Int64
+o) = Int64 -> Doc ann
+forall ann. Int64 -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty (Int64
+dword Int64 -> Int64 -> Int64
+forall a. Num a => a -> a -> a
+* Int64
+o) Doc ann -> Doc ann -> Doc ann
+forall a. Semigroup a => a -> a -> a
+<> Doc ann -> Doc ann
+forall ann. Doc ann -> Doc ann
+parens (Register -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+forall ann. Register -> Doc ann
+pretty Register
+r)
+  pretty (Symbol Text
+t) = Text -> Doc ann
+forall ann. Text -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty Text
+t
+
+type Offset = Int64
+
+data Register
+  = Zero -- zero == x0
+  | Ra -- ra == x1
+  | Sp -- sp == x2
+  | Gp -- gp == x3
+  | Tp -- tp == x4
+  | T0 -- t0 == x5
+  | T1 -- t1 == x6
+  | T2 -- t2 == x7
+  | S0 -- s0 == x8
+  | S1 -- s1 == x9
+  | A0 -- a0 == x10
+  | A1 -- a1 == x11
+  | A2 -- a2 == x12
+  | A3 -- a3 == x13
+  | A4 -- a4 == x14
+  | A5 -- a5 == x15
+  | A6 -- a6 == x16
+  | A7 -- a7 == x17
+  | S2 -- s2 == x18
+  | S3 -- s3 == x19
+  | S4 -- s4 == x20
+  | S5 -- s5 == x21
+  | S6 -- s6 == x22
+  | S7 -- s7 == x23
+  | S8 -- s8 == x24
+  | S9 -- s9 == x25
+  | S10 -- s10 == x26
+  | S11 -- s11 == x27
+  | T3 -- t3 == x28
+  | T4 -- t4 == x29
+  | T5 -- t5 == x30
+  | T6 -- t6 == x31
+  deriving (Register -> Register -> Bool
+(Register -> Register -> Bool)
+-> (Register -> Register -> Bool) -> Eq Register
+forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
+$c== :: Register -> Register -> Bool
+== :: Register -> Register -> Bool
+$c/= :: Register -> Register -> Bool
+/= :: Register -> Register -> Bool
+Eq, Eq Register
+Eq Register
+-> (Register -> Register -> Ordering)
+-> (Register -> Register -> Bool)
+-> (Register -> Register -> Bool)
+-> (Register -> Register -> Bool)
+-> (Register -> Register -> Bool)
+-> (Register -> Register -> Register)
+-> (Register -> Register -> Register)
+-> Ord Register
+Register -> Register -> Bool
+Register -> Register -> Ordering
+Register -> Register -> Register
+forall a.
+Eq a
+-> (a -> a -> Ordering)
+-> (a -> a -> Bool)
+-> (a -> a -> Bool)
+-> (a -> a -> Bool)
+-> (a -> a -> Bool)
+-> (a -> a -> a)
+-> (a -> a -> a)
+-> Ord a
+$ccompare :: Register -> Register -> Ordering
+compare :: Register -> Register -> Ordering
+$c< :: Register -> Register -> Bool
+< :: Register -> Register -> Bool
+$c<= :: Register -> Register -> Bool
+<= :: Register -> Register -> Bool
+$c> :: Register -> Register -> Bool
+> :: Register -> Register -> Bool
+$c>= :: Register -> Register -> Bool
+>= :: Register -> Register -> Bool
+$cmax :: Register -> Register -> Register
+max :: Register -> Register -> Register
+$cmin :: Register -> Register -> Register
+min :: Register -> Register -> Register
+Ord, Int -> Register -> ShowS
+[Register] -> ShowS
+Register -> String
+(Int -> Register -> ShowS)
+-> (Register -> String) -> ([Register] -> ShowS) -> Show Register
+forall a.
+(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
+$cshowsPrec :: Int -> Register -> ShowS
+showsPrec :: Int -> Register -> ShowS
+$cshow :: Register -> String
+show :: Register -> String
+$cshowList :: [Register] -> ShowS
+showList :: [Register] -> ShowS
+Show)
+
+instance Pretty Register where
+  pretty :: forall ann. Register -> Doc ann
+pretty Register
+opCode = String -> Doc ann
+forall ann. String -> Doc ann
+forall a ann. Pretty a => a -> Doc ann
+pretty (String -> Doc ann) -> String -> Doc ann
+forall a b. (a -> b) -> a -> b
+$ Char -> Char
+toLower (Char -> Char) -> ShowS
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Register -> String
+forall a. Show a => a -> String
+show Register
+opCode
+
+dword :: Int64
+dword :: Int64
+dword = Int64
+8
+
\ No newline at end of file diff --git a/src/CodeGen.RiscV.Lib.html b/src/CodeGen.RiscV.Lib.html new file mode 100644 index 0000000..35dca11 --- /dev/null +++ b/src/CodeGen.RiscV.Lib.html @@ -0,0 +1,1272 @@ +
{-# LANGUAGE OverloadedStrings #-}
+
+module CodeGen.RiscV.Lib
+  ( compileT,
+    compile,
+    ppCodeLines,
+    mainFunction,
+    function,
+    globalVar,
+    externFunction,
+    AsmBuilderT,
+    AsmBuilder,
+    Operand,
+    CodeLine,
+    immediate,
+    and,
+    or,
+    add,
+    sub,
+    mul,
+    neg,
+    eq,
+    ne,
+    lt,
+    le,
+    gt,
+    ge,
+    call,
+    ite,
+    storeToLabeledAddr,
+  )
+where
+
+import CodeGen.RiscV.Lib.Monad
+import CodeGen.RiscV.Lib.Types
+import Control.Monad (replicateM, void)
+import Control.Monad.Identity (Identity (..))
+import Control.Monad.State (execStateT)
+import Data.Int (Int64)
+import Data.Text (Text)
+import qualified Data.Text as Txt
+import Prelude hiding (and, or)
+
+-- | Compile the code
+compileT :: (Monad m) => AsmBuilderT m a -> m [CodeLine]
+compileT :: forall (m :: * -> *) a. Monad m => AsmBuilderT m a -> m [CodeLine]
+compileT AsmBuilderT m a
+m = BuilderState -> [CodeLine]
+concatCode (BuilderState -> [CodeLine]) -> m BuilderState -> m [CodeLine]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> AsmBuilderT m a -> m BuilderState
+forall (m :: * -> *) a.
+Monad m =>
+AsmBuilderT m a -> m BuilderState
+execAsmBuilderT AsmBuilderT m a
+m
+  where
+    execAsmBuilderT :: (Monad m) => AsmBuilderT m a -> m BuilderState
+    execAsmBuilderT :: forall (m :: * -> *) a.
+Monad m =>
+AsmBuilderT m a -> m BuilderState
+execAsmBuilderT AsmBuilderT m a
+m' = StateT BuilderState m a -> BuilderState -> m BuilderState
+forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m s
+execStateT (AsmBuilderT m a -> StateT BuilderState m a
+forall (m :: * -> *) a. AsmBuilderT m a -> StateT BuilderState m a
+unAsmBuilderT AsmBuilderT m a
+m') BuilderState
+emptyBS
+
+    concatCode :: BuilderState -> [CodeLine]
+    concatCode :: BuilderState -> [CodeLine]
+concatCode (BS (PBS [[CodeLine]]
+txt [CodeLine]
+dat) FunctionBuilderState
+_ Integer
+_) =
+      let txtCL :: [CodeLine]
+txtCL = Directive -> CodeLine
+DirectiveCodeLine Directive
+DirText CodeLine -> [CodeLine] -> [CodeLine]
+forall a. a -> [a] -> [a]
+: [[CodeLine]] -> [CodeLine]
+forall (t :: * -> *) a. Foldable t => t [a] -> [a]
+concat ([[CodeLine]] -> [[CodeLine]]
+forall a. [a] -> [a]
+reverse [[CodeLine]]
+txt)
+          datCL :: [CodeLine]
+datCL = Directive -> CodeLine
+DirectiveCodeLine Directive
+DirData CodeLine -> [CodeLine] -> [CodeLine]
+forall a. a -> [a] -> [a]
+: [CodeLine]
+dat
+       in [CodeLine]
+datCL [CodeLine] -> [CodeLine] -> [CodeLine]
+forall a. [a] -> [a] -> [a]
+++ [CodeLine]
+txtCL
+
+-- | Compile the code
+compile :: AsmBuilder a -> [CodeLine]
+compile :: forall a. AsmBuilder a -> [CodeLine]
+compile = Identity [CodeLine] -> [CodeLine]
+forall a. Identity a -> a
+runIdentity (Identity [CodeLine] -> [CodeLine])
+-> (AsmBuilder a -> Identity [CodeLine])
+-> AsmBuilder a
+-> [CodeLine]
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. AsmBuilder a -> Identity [CodeLine]
+forall (m :: * -> *) a. Monad m => AsmBuilderT m a -> m [CodeLine]
+compileT
+
+-- | Emit main function (entry point routine)
+mainFunction :: (MonadAsmBuilder m) => (() -> m ()) -> m ()
+mainFunction :: forall (m :: * -> *). MonadAsmBuilder m => (() -> m ()) -> m ()
+mainFunction () -> m ()
+body = do
+  m () -> m ()
+forall (f :: * -> *) a. Functor f => f a -> f ()
+void (m () -> m ()) -> m () -> m ()
+forall a b. (a -> b) -> a -> b
+$ () -> m ()
+body ()
+
+  BS ProgramBuilderState
+_ (FBS [[CodeLine]]
+cls Int64
+spo) Integer
+_ <- m BuilderState
+forall (m :: * -> *). MonadAsmBuilder m => m BuilderState
+getAsmBuilderState
+
+  let globalDir :: CodeLine
+globalDir = Directive -> CodeLine
+DirectiveCodeLine (Directive -> CodeLine) -> Directive -> CodeLine
+forall a b. (a -> b) -> a -> b
+$ Text -> Directive
+DirGlobl Text
+"_start"
+  let funLabel :: CodeLine
+funLabel = Label -> CodeLine
+LabelCodeLine (Label -> CodeLine) -> Label -> CodeLine
+forall a b. (a -> b) -> a -> b
+$ Text -> Label
+Label Text
+"_start"
+  let spPush :: CodeLine
+spPush = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Addi [Register -> Operand
+Register Register
+Sp, Register -> Operand
+Register Register
+Sp, Int64 -> Operand
+Immediate (Int64 -> Operand) -> Int64 -> Operand
+forall a b. (a -> b) -> a -> b
+$ -(Int64
+dword Int64 -> Int64 -> Int64
+forall a. Num a => a -> a -> a
+* Int64
+spo)]
+  let loadRetVal :: CodeLine
+loadRetVal = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Li [Register -> Operand
+Register Register
+A0, Int64 -> Operand
+Immediate Int64
+0]
+  let spPop :: CodeLine
+spPop = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Addi [Register -> Operand
+Register Register
+Sp, Register -> Operand
+Register Register
+Sp, Int64 -> Operand
+Immediate (Int64 -> Operand) -> Int64 -> Operand
+forall a b. (a -> b) -> a -> b
+$ Int64
+dword Int64 -> Int64 -> Int64
+forall a. Num a => a -> a -> a
+* Int64
+spo]
+
+  let ret :: [CodeLine]
+ret =
+        [ OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Li [Register -> Operand
+Register Register
+A0, Int64 -> Operand
+Immediate Int64
+0],
+          OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Call [Text -> Operand
+Symbol Text
+"exit"]
+        ]
+
+  let funCode :: [CodeLine]
+funCode = [CodeLine
+globalDir, CodeLine
+funLabel, CodeLine
+spPush] [CodeLine] -> [CodeLine] -> [CodeLine]
+forall a. [a] -> [a] -> [a]
+++ ([[CodeLine]] -> [CodeLine]
+forall (t :: * -> *) a. Foldable t => t [a] -> [a]
+concat ([[CodeLine]] -> [CodeLine])
+-> ([[CodeLine]] -> [[CodeLine]]) -> [[CodeLine]] -> [CodeLine]
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. [[CodeLine]] -> [[CodeLine]]
+forall a. [a] -> [a]
+reverse ([[CodeLine]] -> [CodeLine]) -> [[CodeLine]] -> [CodeLine]
+forall a b. (a -> b) -> a -> b
+$ ([CodeLine
+loadRetVal, CodeLine
+spPop] [CodeLine] -> [CodeLine] -> [CodeLine]
+forall a. [a] -> [a] -> [a]
+++ [CodeLine]
+ret) [CodeLine] -> [[CodeLine]] -> [[CodeLine]]
+forall a. a -> [a] -> [a]
+: [[CodeLine]]
+cls)
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushProgramCodeLines [CodeLine]
+funCode
+  (BuilderState -> BuilderState) -> m ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState ((BuilderState -> BuilderState) -> m ())
+-> (BuilderState -> BuilderState) -> m ()
+forall a b. (a -> b) -> a -> b
+$ \BuilderState
+bs -> BuilderState
+bs {functionBS :: FunctionBuilderState
+functionBS = FunctionBuilderState
+emptyFBS}
+
+-- | Emit main function (entry point routine)
+function :: (MonadAsmBuilder m) => Text -> Int64 -> ([Operand] -> m Operand) -> m Operand
+function :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Text -> Int64 -> ([Operand] -> m Operand) -> m Operand
+function Text
+name Int64
+paramCount [Operand] -> m Operand
+body = do
+  let args :: [Operand]
+args = Register -> Operand
+Register (Register -> Operand) -> [Register] -> [Operand]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int -> [Register] -> [Register]
+forall a. Int -> [a] -> [a]
+take (Int64 -> Int
+forall a b. (Integral a, Num b) => a -> b
+fromIntegral Int64
+paramCount) [Register
+A0, Register
+A1, Register
+A2, Register
+A3, Register
+A4, Register
+A5, Register
+A6]
+  [Operand]
+memArgs <- Int -> m Operand -> m [Operand]
+forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
+replicateM ([Operand] -> Int
+forall a. [a] -> Int
+forall (t :: * -> *) a. Foldable t => t a -> Int
+length [Operand]
+args) (Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1)
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines ([CodeLine] -> m ()) -> [CodeLine] -> m ()
+forall a b. (a -> b) -> a -> b
+$
+    (\(Operand
+reg, Operand
+mem) -> OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+reg, Operand
+mem]) ((Operand, Operand) -> CodeLine)
+-> [(Operand, Operand)] -> [CodeLine]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> [Operand]
+args [Operand] -> [Operand] -> [(Operand, Operand)]
+forall a b. [a] -> [b] -> [(a, b)]
+`zip` [Operand]
+memArgs
+
+  Operand
+retVal <- [Operand] -> m Operand
+body [Operand]
+memArgs
+
+  BS ProgramBuilderState
+_ (FBS [[CodeLine]]
+cls Int64
+spo) Integer
+_ <- m BuilderState
+forall (m :: * -> *). MonadAsmBuilder m => m BuilderState
+getAsmBuilderState
+
+  let funLabel :: CodeLine
+funLabel = Label -> CodeLine
+LabelCodeLine (Label -> CodeLine) -> Label -> CodeLine
+forall a b. (a -> b) -> a -> b
+$ Text -> Label
+Label Text
+name
+  let spPush :: CodeLine
+spPush = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Addi [Register -> Operand
+Register Register
+Sp, Register -> Operand
+Register Register
+Sp, Int64 -> Operand
+Immediate (Int64 -> Operand) -> Int64 -> Operand
+forall a b. (a -> b) -> a -> b
+$ -(Int64
+dword Int64 -> Int64 -> Int64
+forall a. Num a => a -> a -> a
+* Int64
+spo)]
+  let loadRetVal :: CodeLine
+loadRetVal = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Register -> Operand
+Register Register
+A0, Operand
+retVal]
+  let spPop :: CodeLine
+spPop = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Addi [Register -> Operand
+Register Register
+Sp, Register -> Operand
+Register Register
+Sp, Int64 -> Operand
+Immediate (Int64 -> Operand) -> Int64 -> Operand
+forall a b. (a -> b) -> a -> b
+$ Int64
+dword Int64 -> Int64 -> Int64
+forall a. Num a => a -> a -> a
+* Int64
+spo]
+  let ret :: CodeLine
+ret = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ret []
+
+  let funCode :: [CodeLine]
+funCode = [CodeLine
+funLabel, CodeLine
+spPush] [CodeLine] -> [CodeLine] -> [CodeLine]
+forall a. [a] -> [a] -> [a]
+++ ([[CodeLine]] -> [CodeLine]
+forall (t :: * -> *) a. Foldable t => t [a] -> [a]
+concat ([[CodeLine]] -> [CodeLine])
+-> ([[CodeLine]] -> [[CodeLine]]) -> [[CodeLine]] -> [CodeLine]
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. [[CodeLine]] -> [[CodeLine]]
+forall a. [a] -> [a]
+reverse ([[CodeLine]] -> [CodeLine]) -> [[CodeLine]] -> [CodeLine]
+forall a b. (a -> b) -> a -> b
+$ [CodeLine
+loadRetVal, CodeLine
+spPop, CodeLine
+ret] [CodeLine] -> [[CodeLine]] -> [[CodeLine]]
+forall a. a -> [a] -> [a]
+: [[CodeLine]]
+cls)
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushProgramCodeLines [CodeLine]
+funCode
+  (BuilderState -> BuilderState) -> m ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState ((BuilderState -> BuilderState) -> m ())
+-> (BuilderState -> BuilderState) -> m ()
+forall a b. (a -> b) -> a -> b
+$ \BuilderState
+bs -> BuilderState
+bs {functionBS :: FunctionBuilderState
+functionBS = FunctionBuilderState
+emptyFBS}
+
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return (Operand -> m Operand) -> Operand -> m Operand
+forall a b. (a -> b) -> a -> b
+$ Text -> Operand
+Symbol Text
+name
+
+-- | Emit uninitialized global variable
+globalVar :: (MonadAsmBuilder m) => Text -> m Operand
+globalVar :: forall (m :: * -> *). MonadAsmBuilder m => Text -> m Operand
+globalVar Text
+name = do
+  let gVarDir :: CodeLine
+gVarDir = Label -> Directive -> CodeLine
+LabeledDirectiveCodeLine (Text -> Label
+Label Text
+name) (Int64 -> Directive
+DirDWord Int64
+0)
+  (BuilderState -> BuilderState) -> m ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState ((BuilderState -> BuilderState) -> m ())
+-> (BuilderState -> BuilderState) -> m ()
+forall a b. (a -> b) -> a -> b
+$
+    \bs :: BuilderState
+bs@(BS ProgramBuilderState
+pbs FunctionBuilderState
+_ Integer
+_) ->
+      BuilderState
+bs {programBS :: ProgramBuilderState
+programBS = ProgramBuilderState
+pbs {sectionData :: [CodeLine]
+sectionData = CodeLine
+gVarDir CodeLine -> [CodeLine] -> [CodeLine]
+forall a. a -> [a] -> [a]
+: ProgramBuilderState -> [CodeLine]
+sectionData ProgramBuilderState
+pbs}}
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return (Operand -> m Operand) -> Operand -> m Operand
+forall a b. (a -> b) -> a -> b
+$ Text -> Operand
+Symbol Text
+name
+
+-- | Get external function operand
+externFunction :: (MonadAsmBuilder m) => Text -> m Operand
+externFunction :: forall (m :: * -> *). MonadAsmBuilder m => Text -> m Operand
+externFunction = Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return (Operand -> m Operand) -> (Text -> Operand) -> Text -> m Operand
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. Text -> Operand
+Symbol
+
+storeToLabeledAddr :: (MonadAsmBuilder m) => Operand -> Operand -> m ()
+storeToLabeledAddr :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m ()
+storeToLabeledAddr Operand
+addr Operand
+value = do
+  let regA :: Register
+regA = Register
+T0
+  let ra :: Operand
+ra = Register -> Operand
+Register Register
+regA
+  let rb :: Operand
+rb = Register -> Operand
+Register Register
+T1
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines
+    [ OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+La [Operand
+ra, Operand
+addr],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+rb, Operand
+value],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+rb, Register -> Int64 -> Operand
+RegisterWithOffset Register
+regA Int64
+0]
+    ]
+
+  () -> m ()
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return ()
+
+immediate :: (MonadAsmBuilder m) => Int64 -> m Operand
+immediate :: forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Operand
+immediate Int64
+value = do
+  let rd :: Operand
+rd = Register -> Operand
+Register Register
+T0
+
+  Operand
+rdMem <- Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines
+    [ OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Li [Operand
+rd, Int64 -> Operand
+Immediate Int64
+value],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+rd, Operand
+rdMem]
+    ]
+
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Operand
+rdMem
+
+-- boolean
+and, or :: (MonadAsmBuilder m) => Operand -> Operand -> m Operand
+and :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+and = OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 OpCode
+And
+or :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+or = OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 OpCode
+Or
+
+-- arithmetic
+add, sub, mul :: (MonadAsmBuilder m) => Operand -> Operand -> m Operand
+add :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+add = OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 OpCode
+Add
+sub :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+sub = OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 OpCode
+Sub
+mul :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+mul = OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 OpCode
+Mul
+
+neg :: (MonadAsmBuilder m) => Operand -> m Operand
+neg :: forall (m :: * -> *). MonadAsmBuilder m => Operand -> m Operand
+neg Operand
+a = do
+  let rd :: Operand
+rd = Register -> Operand
+Register Register
+T0
+  let rs :: Operand
+rs = Register -> Operand
+Register Register
+T0
+
+  Operand
+rdMem <- Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines
+    [ OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+rs, Operand
+a],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Neg [Operand
+rd, Operand
+rs],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+rd, Operand
+rdMem]
+    ]
+
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Operand
+rdMem
+
+-- comparison
+eq, ne, lt, le, gt, ge :: (MonadAsmBuilder m) => Operand -> Operand -> m Operand
+eq :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+eq = OpCode -> OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction2 OpCode
+Sub OpCode
+Seqz
+ne :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+ne = OpCode -> OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction2 OpCode
+Sub OpCode
+Snez
+lt :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+lt = OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 OpCode
+Slt
+le :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+le = (Operand -> Operand -> m Operand)
+-> Operand -> Operand -> m Operand
+forall a b c. (a -> b -> c) -> b -> a -> c
+flip Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+ge
+gt :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+gt = (Operand -> Operand -> m Operand)
+-> Operand -> Operand -> m Operand
+forall a b c. (a -> b -> c) -> b -> a -> c
+flip Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+lt
+ge :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> Operand -> m Operand
+ge = OpCode -> OpCode -> Operand -> Operand -> m Operand
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction2 OpCode
+Slt OpCode
+Seqz
+
+call :: (MonadAsmBuilder m) => Operand -> [Operand] -> m Operand
+call :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> [Operand] -> m Operand
+call Operand
+fun [Operand]
+args = do
+  let argRegs :: [Operand]
+argRegs = Register -> Operand
+Register (Register -> Operand) -> [Register] -> [Operand]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> [Register
+A0, Register
+A1, Register
+A2, Register
+A3, Register
+A4, Register
+A5, Register
+A6]
+  let loadArguments :: [CodeLine]
+loadArguments = (Operand -> Operand -> CodeLine) -> (Operand, Operand) -> CodeLine
+forall a b c. (a -> b -> c) -> (a, b) -> c
+uncurry Operand -> Operand -> CodeLine
+loadArgCL ((Operand, Operand) -> CodeLine)
+-> [(Operand, Operand)] -> [CodeLine]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> [Operand]
+argRegs [Operand] -> [Operand] -> [(Operand, Operand)]
+forall a b. [a] -> [b] -> [(a, b)]
+`zip` [Operand]
+args
+
+  let retVal :: Operand
+retVal = Register -> Operand
+Register Register
+A0
+  Operand
+retValMem <- Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1
+  Operand
+raMem <- Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines ([CodeLine] -> m ()) -> [CodeLine] -> m ()
+forall a b. (a -> b) -> a -> b
+$
+    [CodeLine]
+loadArguments
+      [CodeLine] -> [CodeLine] -> [CodeLine]
+forall a. [a] -> [a] -> [a]
+++ [ OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Register -> Operand
+Register Register
+Ra, Operand
+raMem],
+           OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Call [Operand
+fun],
+           OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Register -> Operand
+Register Register
+Ra, Operand
+raMem],
+           OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+retVal, Operand
+retValMem]
+         ]
+
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Operand
+retValMem
+  where
+    loadArgCL :: Operand -> Operand -> CodeLine
+loadArgCL Operand
+reg Operand
+arg = case Operand
+arg of
+      Symbol Text
+_ -> OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+La [Operand
+reg, Operand
+arg]
+      Operand
+_ -> OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+reg, Operand
+arg]
+
+ite :: (MonadAsmBuilder m) => Operand -> (() -> m Operand) -> (() -> m Operand) -> m Operand
+ite :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+Operand -> (() -> m Operand) -> (() -> m Operand) -> m Operand
+ite Operand
+c () -> m Operand
+t () -> m Operand
+e = do
+  let retVal :: Operand
+retVal = Register -> Operand
+Register Register
+T0
+  Operand
+retValMem <- Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1
+
+  Text
+elseLabelName <- String -> Text
+Txt.pack (String -> Text) -> (Integer -> String) -> Integer -> Text
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. (String
+"else_" String -> String -> String
+forall a. [a] -> [a] -> [a]
+++) (String -> String) -> (Integer -> String) -> Integer -> String
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. Integer -> String
+forall a. Show a => a -> String
+show (Integer -> Text) -> m Integer -> m Text
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> m Integer
+forall (m :: * -> *). MonadAsmBuilder m => m Integer
+genId
+  Text
+endLabelName <- String -> Text
+Txt.pack (String -> Text) -> (Integer -> String) -> Integer -> Text
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. (String
+"end_" String -> String -> String
+forall a. [a] -> [a] -> [a]
+++) (String -> String) -> (Integer -> String) -> Integer -> String
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. Integer -> String
+forall a. Show a => a -> String
+show (Integer -> Text) -> m Integer -> m Text
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> m Integer
+forall (m :: * -> *). MonadAsmBuilder m => m Integer
+genId
+
+  -- condition
+  let condReg :: Operand
+condReg = Register -> Operand
+Register Register
+T1
+  let loadCond :: CodeLine
+loadCond = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+condReg, Operand
+c]
+  let br :: CodeLine
+br = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Beqz [Operand
+condReg, Text -> Operand
+Symbol Text
+elseLabelName]
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines [CodeLine
+loadCond, CodeLine
+br]
+
+  -- then
+  [CodeLine]
+storeThenRes <- (\Operand
+op -> [OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+retVal, Operand
+op], OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+retVal, Operand
+retValMem]]) (Operand -> [CodeLine]) -> m Operand -> m [CodeLine]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> () -> m Operand
+t ()
+  let jumpFromThenToEnd :: CodeLine
+jumpFromThenToEnd = OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+J [Text -> Operand
+Symbol Text
+endLabelName]
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines ([CodeLine] -> m ()) -> [CodeLine] -> m ()
+forall a b. (a -> b) -> a -> b
+$ [CodeLine]
+storeThenRes [CodeLine] -> [CodeLine] -> [CodeLine]
+forall a. [a] -> [a] -> [a]
+++ [CodeLine
+jumpFromThenToEnd]
+
+  -- else
+  let elseLabel :: CodeLine
+elseLabel = Label -> CodeLine
+LabelCodeLine (Label -> CodeLine) -> Label -> CodeLine
+forall a b. (a -> b) -> a -> b
+$ Text -> Label
+Label Text
+elseLabelName
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines [CodeLine
+elseLabel]
+
+  [CodeLine]
+storeElseRes <- (\Operand
+op -> [OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+retVal, Operand
+op], OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+retVal, Operand
+retValMem]]) (Operand -> [CodeLine]) -> m Operand -> m [CodeLine]
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> () -> m Operand
+e ()
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines [CodeLine]
+storeElseRes
+
+  -- end
+  let endLabel :: CodeLine
+endLabel = Label -> CodeLine
+LabelCodeLine (Label -> CodeLine) -> Label -> CodeLine
+forall a b. (a -> b) -> a -> b
+$ Text -> Label
+Label Text
+endLabelName
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines [CodeLine
+endLabel]
+
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Operand
+retValMem
+
+-- Utils
+
+genOpCodeInstruction1 :: (MonadAsmBuilder m) => OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction1 OpCode
+opCode Operand
+a Operand
+b = do
+  let rd :: Operand
+rd = Register -> Operand
+Register Register
+T0
+  let rs1 :: Operand
+rs1 = Register -> Operand
+Register Register
+T0
+  let rs2 :: Operand
+rs2 = Register -> Operand
+Register Register
+T1
+
+  Operand
+rdMem <- Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines
+    [ OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+rs1, Operand
+a],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+rs2, Operand
+b],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+opCode [Operand
+rd, Operand
+rs1, Operand
+rs2],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+rd, Operand
+rdMem]
+    ]
+
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Operand
+rdMem
+
+genOpCodeInstruction2 :: (MonadAsmBuilder m) => OpCode -> OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction2 :: forall (m :: * -> *).
+MonadAsmBuilder m =>
+OpCode -> OpCode -> Operand -> Operand -> m Operand
+genOpCodeInstruction2 OpCode
+opCode1 OpCode
+opCode2 Operand
+a Operand
+b = do
+  let rd :: Operand
+rd = Register -> Operand
+Register Register
+T0
+  let rs1 :: Operand
+rs1 = Register -> Operand
+Register Register
+T0
+  let rs2 :: Operand
+rs2 = Register -> Operand
+Register Register
+T1
+
+  Operand
+rdMem <- Int64 -> Operand
+Memory (Int64 -> Operand) -> m Int64 -> m Operand
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> Int64 -> m Int64
+forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+1
+
+  [CodeLine] -> m ()
+forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines
+    [ OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+rs1, Operand
+a],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Ld [Operand
+rs2, Operand
+b],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+opCode1 [Operand
+rd, Operand
+rs1, Operand
+rs2],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+opCode2 [Operand
+rd, Operand
+rd],
+      OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+Sd [Operand
+rd, Operand
+rdMem]
+    ]
+
+  Operand -> m Operand
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Operand
+rdMem
+
+pushProgramCodeLines :: (MonadAsmBuilder m) => [CodeLine] -> m ()
+pushProgramCodeLines :: forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushProgramCodeLines [CodeLine]
+newCodeLines = (BuilderState -> BuilderState) -> m ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState ((BuilderState -> BuilderState) -> m ())
+-> (BuilderState -> BuilderState) -> m ()
+forall a b. (a -> b) -> a -> b
+$
+  \bs :: BuilderState
+bs@(BS pbs :: ProgramBuilderState
+pbs@(PBS [[CodeLine]]
+currCodeLines [CodeLine]
+_) FunctionBuilderState
+_ Integer
+_) ->
+    BuilderState
+bs {programBS :: ProgramBuilderState
+programBS = ProgramBuilderState
+pbs {sectionText :: [[CodeLine]]
+sectionText = [CodeLine]
+newCodeLines [CodeLine] -> [[CodeLine]] -> [[CodeLine]]
+forall a. a -> [a] -> [a]
+: [[CodeLine]]
+currCodeLines}}
+
+pushFunctionCodeLines :: (MonadAsmBuilder m) => [CodeLine] -> m ()
+pushFunctionCodeLines :: forall (m :: * -> *). MonadAsmBuilder m => [CodeLine] -> m ()
+pushFunctionCodeLines [CodeLine]
+newCodeLines = (BuilderState -> BuilderState) -> m ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState ((BuilderState -> BuilderState) -> m ())
+-> (BuilderState -> BuilderState) -> m ()
+forall a b. (a -> b) -> a -> b
+$
+  \bs :: BuilderState
+bs@(BS ProgramBuilderState
+_ fbs :: FunctionBuilderState
+fbs@(FBS [[CodeLine]]
+currCodeLines Int64
+_) Integer
+_) ->
+    BuilderState
+bs {functionBS :: FunctionBuilderState
+functionBS = FunctionBuilderState
+fbs {functionCodeLines :: [[CodeLine]]
+functionCodeLines = [CodeLine]
+newCodeLines [CodeLine] -> [[CodeLine]] -> [[CodeLine]]
+forall a. a -> [a] -> [a]
+: [[CodeLine]]
+currCodeLines}}
+
+incAndGetSpo :: (MonadAsmBuilder m) => Int64 -> m Int64
+incAndGetSpo :: forall (m :: * -> *). MonadAsmBuilder m => Int64 -> m Int64
+incAndGetSpo Int64
+amount = do
+  Int64
+spo <- FunctionBuilderState -> Int64
+stackPointerOffset (FunctionBuilderState -> Int64)
+-> (BuilderState -> FunctionBuilderState) -> BuilderState -> Int64
+forall b c a. (b -> c) -> (a -> b) -> a -> c
+. BuilderState -> FunctionBuilderState
+functionBS (BuilderState -> Int64) -> m BuilderState -> m Int64
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> m BuilderState
+forall (m :: * -> *). MonadAsmBuilder m => m BuilderState
+getAsmBuilderState
+  let newSpo :: Int64
+newSpo = Int64
+spo Int64 -> Int64 -> Int64
+forall a. Num a => a -> a -> a
++ Int64
+amount
+
+  (BuilderState -> BuilderState) -> m ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState ((BuilderState -> BuilderState) -> m ())
+-> (BuilderState -> BuilderState) -> m ()
+forall a b. (a -> b) -> a -> b
+$
+    \bs :: BuilderState
+bs@(BS ProgramBuilderState
+_ FunctionBuilderState
+fbs Integer
+_) ->
+      BuilderState
+bs {functionBS :: FunctionBuilderState
+functionBS = FunctionBuilderState
+fbs {stackPointerOffset :: Int64
+stackPointerOffset = Int64
+newSpo}}
+
+  Int64 -> m Int64
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Int64
+newSpo
+
+instructionCodeLine :: OpCode -> [Operand] -> CodeLine
+instructionCodeLine :: OpCode -> [Operand] -> CodeLine
+instructionCodeLine OpCode
+opCode [Operand]
+ops = Instruction -> CodeLine
+InstructionCodeLine (Instruction -> CodeLine) -> Instruction -> CodeLine
+forall a b. (a -> b) -> a -> b
+$ OpCode -> [Operand] -> Instruction
+Instruction OpCode
+opCode [Operand]
+ops
+
+genId :: (MonadAsmBuilder m) => m Integer
+genId :: forall (m :: * -> *). MonadAsmBuilder m => m Integer
+genId = do
+  Integer
+cnt <- BuilderState -> Integer
+idCnt (BuilderState -> Integer) -> m BuilderState -> m Integer
+forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
+<$> m BuilderState
+forall (m :: * -> *). MonadAsmBuilder m => m BuilderState
+getAsmBuilderState
+  (BuilderState -> BuilderState) -> m ()
+forall (m :: * -> *).
+MonadAsmBuilder m =>
+(BuilderState -> BuilderState) -> m ()
+modifyAsmBuilderState ((BuilderState -> BuilderState) -> m ())
+-> (BuilderState -> BuilderState) -> m ()
+forall a b. (a -> b) -> a -> b
+$ \BuilderState
+bs -> BuilderState
+bs {idCnt :: Integer
+idCnt = Integer
+cnt Integer -> Integer -> Integer
+forall a. Num a => a -> a -> a
++ Integer
+1}
+  Integer -> m Integer
+forall a. a -> m a
+forall (m :: * -> *) a. Monad m => a -> m a
+return Integer
+cnt
+
\ No newline at end of file diff --git a/src/CodeGen.RiscV.Runner.html b/src/CodeGen.RiscV.Runner.html new file mode 100644 index 0000000..daa8d19 --- /dev/null +++ b/src/CodeGen.RiscV.Runner.html @@ -0,0 +1,64 @@ +
module CodeGen.RiscV.Runner (compileToRiscVAsm) where
+
+import CodeGen.Module (compileToModule)
+import CodeGen.RiscV.AsmGen (ppRiscVAsm)
+import CodeGen.TimedValue (TimedValue, measureTimedValue)
+import Control.Monad.Except (runExcept)
+import Data.Text (Text)
+import qualified Data.Text.IO as Txt
+import System.IO (IOMode (WriteMode), withFile)
+
+compileToRiscVAsm :: Text -> FilePath -> IO (TimedValue (Either Text ()))
+compileToRiscVAsm :: Text -> FilePath -> IO (TimedValue (Either Text ()))
+compileToRiscVAsm Text
+text FilePath
+outputFilePath = IO (Either Text ()) -> IO (TimedValue (Either Text ()))
+forall a. IO a -> IO (TimedValue a)
+measureTimedValue (IO (Either Text ()) -> IO (TimedValue (Either Text ())))
+-> IO (Either Text ()) -> IO (TimedValue (Either Text ()))
+forall a b. (a -> b) -> a -> b
+$
+  Either Text (IO ()) -> IO (Either Text ())
+forall (t :: * -> *) (f :: * -> *) a.
+(Traversable t, Applicative f) =>
+t (f a) -> f (t a)
+forall (f :: * -> *) a.
+Applicative f =>
+Either Text (f a) -> f (Either Text a)
+sequenceA (Either Text (IO ()) -> IO (Either Text ()))
+-> Either Text (IO ()) -> IO (Either Text ())
+forall a b. (a -> b) -> a -> b
+$
+    Except Text (IO ()) -> Either Text (IO ())
+forall e a. Except e a -> Either e a
+runExcept (Except Text (IO ()) -> Either Text (IO ()))
+-> Except Text (IO ()) -> Either Text (IO ())
+forall a b. (a -> b) -> a -> b
+$ do
+      Module
+m <- Text -> Except Text Module
+compileToModule Text
+text
+      let riscVText :: Text
+riscVText = Module -> Text
+ppRiscVAsm Module
+m
+      IO () -> Except Text (IO ())
+forall a. a -> ExceptT Text Identity a
+forall (m :: * -> *) a. Monad m => a -> m a
+return (IO () -> Except Text (IO ())) -> IO () -> Except Text (IO ())
+forall a b. (a -> b) -> a -> b
+$
+        FilePath -> IOMode -> (Handle -> IO ()) -> IO ()
+forall r. FilePath -> IOMode -> (Handle -> IO r) -> IO r
+withFile FilePath
+outputFilePath IOMode
+WriteMode ((Handle -> IO ()) -> IO ()) -> (Handle -> IO ()) -> IO ()
+forall a b. (a -> b) -> a -> b
+$ \Handle
+handle -> do
+          Handle -> Text -> IO ()
+Txt.hPutStrLn Handle
+handle Text
+riscVText
+
\ No newline at end of file diff --git a/src/CodeGen.RunResult.html b/src/CodeGen.RunResult.html index d16a04a..b4815a1 100644 --- a/src/CodeGen.RunResult.html +++ b/src/CodeGen.RunResult.html @@ -28,7 +28,7 @@
compTime :: Nanoseconds, runTime :: Nanoseconds } - deriving (Int -> RunResult -> ShowS + deriving (Int -> RunResult -> ShowS [RunResult] -> ShowS RunResult -> String (Int -> RunResult -> ShowS) diff --git a/src/CodeGen.Runtime.PrintRuntime.html b/src/CodeGen.Runtime.PrintRuntime.html new file mode 100644 index 0000000..c0c7ead --- /dev/null +++ b/src/CodeGen.Runtime.PrintRuntime.html @@ -0,0 +1,29 @@ +
{-# LANGUAGE TemplateHaskell #-}
+
+module CodeGen.Runtime.PrintRuntime (printCRuntime) where
+
+import Data.FileEmbed (embedFile, makeRelativeToProject)
+import qualified Data.Text.Encoding as Txt
+import qualified Data.Text.IO as Txt
+import System.IO (IOMode (WriteMode), withFile)
+
+printCRuntime :: FilePath -> IO ()
+printCRuntime :: FilePath -> IO ()
+printCRuntime FilePath
+outputFilePath = do
+  let runtimeFileText :: Text
+runtimeFileText = ByteString -> Text
+Txt.decodeUtf8 $(makeRelativeToProject "lib/CodeGen/Runtime/runtime.c" >>= embedFile)
+  FilePath -> IOMode -> (Handle -> IO ()) -> IO ()
+forall r. FilePath -> IOMode -> (Handle -> IO r) -> IO r
+withFile FilePath
+outputFilePath IOMode
+WriteMode ((Handle -> IO ()) -> IO ()) -> (Handle -> IO ()) -> IO ()
+forall a b. (a -> b) -> a -> b
+$ \Handle
+handle -> do
+    Handle -> Text -> IO ()
+Txt.hPutStr Handle
+handle Text
+runtimeFileText
+
\ No newline at end of file diff --git a/src/CodeGen.TimedValue.html b/src/CodeGen.TimedValue.html index b1b3f97..4012689 100644 --- a/src/CodeGen.TimedValue.html +++ b/src/CodeGen.TimedValue.html @@ -4,16 +4,16 @@
import System.CPUTime (getCPUTime) -data TimedValue a = TimedValue +data TimedValue a = TimedValue { forall a. TimedValue a -> a -value :: a, +value
:: a, forall a. TimedValue a -> Nanoseconds time :: Nanoseconds } -- | Nanoseconds, son! newtype Nanoseconds = Nanoseconds Integer - deriving (Int -> Nanoseconds -> ShowS + deriving (Int -> Nanoseconds -> ShowS [Nanoseconds] -> ShowS Nanoseconds -> String (Int -> Nanoseconds -> ShowS) @@ -30,28 +30,28 @@ showList :: [Nanoseconds] -> ShowS Show) -measureTimedValue :: IO a -> IO (TimedValue a) +measureTimedValue :: IO a -> IO (TimedValue a) measureTimedValue :: forall a. IO a -> IO (TimedValue a) -measureTimedValue IO a -computation = do - Integer -start <- IO Integer +measureTimedValue IO a +computation = do + Integer +start <- IO Integer getCPUTime - a -val <- IO a -computation - Integer -end <- IO Integer + a +val <- IO a +computation + Integer +end <- IO Integer getCPUTime - let t :: Nanoseconds -t = Integer -> Nanoseconds + let t :: Nanoseconds +t = Integer -> Nanoseconds Nanoseconds (Integer -> Nanoseconds) -> Integer -> Nanoseconds forall a b. (a -> b) -> a -> b $ (Integer -end Integer -> Integer -> Integer +end Integer -> Integer -> Integer forall a. Num a => a -> a -> a - Integer -start) Integer -> Integer -> Integer +start) Integer -> Integer -> Integer forall a. Integral a => a -> a -> a `div` Integer 1_000 @@ -64,13 +64,13 @@ $ a -> Nanoseconds -> TimedValue a forall a. a -> Nanoseconds -> TimedValue a TimedValue a -val Nanoseconds -t +val Nanoseconds +t measureTime :: IO () -> IO Nanoseconds measureTime :: IO () -> IO Nanoseconds -measureTime IO () -computation = TimedValue () -> Nanoseconds +measureTime IO () +computation = TimedValue () -> Nanoseconds forall a. TimedValue a -> Nanoseconds time (TimedValue () -> Nanoseconds) -> IO (TimedValue ()) -> IO Nanoseconds @@ -78,5 +78,5 @@ <$> IO () -> IO (TimedValue ()) forall a. IO a -> IO (TimedValue a) measureTimedValue IO () -computation +computation \ No newline at end of file diff --git a/src/MonadUtils.html b/src/MonadUtils.html index 3582b36..a8d7444 100644 --- a/src/MonadUtils.html +++ b/src/MonadUtils.html @@ -3,79 +3,79 @@ import Control.Monad (liftM2, liftM3) import Control.Monad.State (MonadState (get, put)) -liftM1' :: (Monad m) => (a' -> m a) -> (a -> b) -> a' -> m b +liftM1' :: (Monad m) => (a' -> m a) -> (a -> b) -> a' -> m b liftM1' :: forall (m :: * -> *) a' a b. Monad m => (a' -> m a) -> (a -> b) -> a' -> m b -liftM1' a' -> m a -lifter a -> b -f a' -a = a -> b -f (a -> b) -> m a -> m b +liftM1'
a' -> m a +lifter a -> b +f a' +a = a -> b +f (a -> b) -> m a -> m b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> a' -> m a -lifter a' -a +lifter
a' +a -liftM2' :: (Monad m) => (a' -> m a) -> (a -> a -> b) -> a' -> a' -> m b +liftM2' :: (Monad m) => (a' -> m a) -> (a -> a -> b) -> a' -> a' -> m b liftM2' :: forall (m :: * -> *) a' a b. Monad m => (a' -> m a) -> (a -> a -> b) -> a' -> a' -> m b -liftM2' a' -> m a -lifter a -> a -> b -f a' -a a' -b = (a -> a -> b) -> m a -> m a -> m b +liftM2'
a' -> m a +lifter a -> a -> b +f a' +a a' +b = (a -> a -> b) -> m a -> m a -> m b forall (m :: * -> *) a1 a2 r. Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r liftM2 a -> a -> b -f (a' -> m a -lifter a' -a) (a' -> m a -lifter a' -b) +f
(a' -> m a +lifter a' +a) (a' -> m a +lifter a' +b) -liftM3' :: (Monad m) => (a' -> m a) -> (a -> a -> a -> b) -> a' -> a' -> a' -> m b +liftM3' :: (Monad m) => (a' -> m a) -> (a -> a -> a -> b) -> a' -> a' -> a' -> m b liftM3' :: forall (m :: * -> *) a' a b. Monad m => (a' -> m a) -> (a -> a -> a -> b) -> a' -> a' -> a' -> m b -liftM3' a' -> m a -lifter a -> a -> a -> b -f a' -a a' -b a' -c = (a -> a -> a -> b) -> m a -> m a -> m a -> m b +liftM3'
a' -> m a +lifter a -> a -> a -> b +f a' +a a' +b a' +c = (a -> a -> a -> b) -> m a -> m a -> m a -> m b forall (m :: * -> *) a1 a2 a3 r. Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r liftM3 a -> a -> a -> b -f (a' -> m a -lifter a' -a) (a' -> m a -lifter a' -b) (a' -> m a -lifter a' -c) +f
(a' -> m a +lifter a' +a) (a' -> m a +lifter a' +b) (a' -> m a +lifter a' +c) -locally :: (MonadState s m) => m a -> m a +locally :: (MonadState s m) => m a -> m a locally :: forall s (m :: * -> *) a. MonadState s m => m a -> m a -locally m a -computation = do - s -oldState <- m s +locally
m a +computation = do + s +oldState <- m s forall s (m :: * -> *). MonadState s m => m s get - a -result <- m a -computation + a +result <- m a +computation s -> m () forall s (m :: * -> *). MonadState s m => s -> m () put s -oldState +oldState
a -> m a forall a. a -> m a forall (m :: * -> *) a. Monad m => a -> m a return a -result +result \ No newline at end of file diff --git a/src/Parser.Ast.html b/src/Parser.Ast.html index e3f594c..4689f10 100644 --- a/src/Parser.Ast.html +++ b/src/Parser.Ast.html @@ -14,7 +14,7 @@ -- | The head of the AST. newtype Program = Program [Statement] - deriving (Int -> Program -> ShowS + deriving (Int -> Program -> ShowS [Program] -> ShowS Program -> String (Int -> Program -> ShowS) @@ -27,7 +27,7 @@ show :: Program -> String $cshowList :: [Program] -> ShowS showList :: [Program] -> ShowS -Show, Program -> Program -> Bool +Show, Program -> Program -> Bool (Program -> Program -> Bool) -> (Program -> Program -> Bool) -> Eq Program forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -45,7 +45,7 @@ StmtDecl Declaration | -- | Expression statement, see 'Expression'. StmtExpr Expression - deriving (Int -> Statement -> ShowS + deriving (Int -> Statement -> ShowS [Statement] -> ShowS Statement -> String (Int -> Statement -> ShowS) @@ -60,7 +60,7 @@ show :: Statement -> String $cshowList :: [Statement] -> ShowS showList :: [Statement] -> ShowS -Show, Statement -> Statement -> Bool +Show, Statement -> Statement -> Bool (Statement -> Statement -> Bool) -> (Statement -> Statement -> Bool) -> Eq Statement forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -86,7 +86,7 @@ -- -- > let rec f x y = f x 1 + f 1 y DeclFun Identifier IsRec Fun - deriving (Int -> Declaration -> ShowS + deriving (Int -> Declaration -> ShowS [Declaration] -> ShowS Declaration -> String (Int -> Declaration -> ShowS) @@ -101,7 +101,7 @@ show :: Declaration -> String $cshowList :: [Declaration] -> ShowS showList :: [Declaration] -> ShowS -Show, Declaration -> Declaration -> Bool +Show, Declaration -> Declaration -> Bool (Declaration -> Declaration -> Bool) -> (Declaration -> Declaration -> Bool) -> Eq Declaration forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -145,7 +145,7 @@ ExprLetIn Declaration Expression | -- | Anonymous function, see 'Fun'. ExprFun Fun - deriving (Int -> Expression -> ShowS + deriving (Int -> Expression -> ShowS [Expression] -> ShowS Expression -> String (Int -> Expression -> ShowS) @@ -160,7 +160,7 @@ show :: Expression -> String $cshowList :: [Expression] -> ShowS showList :: [Expression] -> ShowS -Show, Expression -> Expression -> Bool +Show, Expression -> Expression -> Bool (Expression -> Expression -> Bool) -> (Expression -> Expression -> Bool) -> Eq Expression forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -178,7 +178,7 @@ -- -- > fun x y -> x + y data Fun = Fun (NonEmpty (Identifier, Maybe Type)) (Maybe Type) Expression - deriving (Int -> Fun -> ShowS + deriving (Int -> Fun -> ShowS [Fun] -> ShowS Fun -> String (Int -> Fun -> ShowS) @@ -191,7 +191,7 @@ show :: Fun -> String $cshowList :: [Fun] -> ShowS showList :: [Fun] -> ShowS -Show, Fun -> Fun -> Bool +Show, Fun -> Fun -> Bool (Fun -> Fun -> Bool) -> (Fun -> Fun -> Bool) -> Eq Fun forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Fun -> Fun -> Bool diff --git a/src/Parser.Lexer.html b/src/Parser.Lexer.html index e72174d..2bdffe6 100644 --- a/src/Parser.Lexer.html +++ b/src/Parser.Lexer.html @@ -67,7 +67,7 @@ "*)") -- | Lexeme, automatically parses trailing whitespace and comments. -lexeme :: Parser a -> Parser a +lexeme :: Parser a -> Parser a lexeme :: forall a. Parser a -> Parser a lexeme = Parser () -> ParsecT Void Text Identity a -> ParsecT Void Text Identity a @@ -170,8 +170,8 @@ intLitP :: Parser Int64 intLitP :: Parser Int64 intLitP = do - Integer -int <- Parser Integer -> Parser Integer + Integer +int <- Parser Integer -> Parser Integer forall a. Parser a -> Parser a lexeme Parser Integer forall e s (m :: * -> *) a. @@ -181,10 +181,10 @@ Bool -> Parser () -> Parser () forall (f :: * -> *). Applicative f => Bool -> f () -> f () when (Integer -int Integer -> Integer -> Bool +int Integer -> Integer -> Bool forall a. Ord a => a -> a -> Bool > Integer -absMax) (Parser () -> Parser ()) -> Parser () -> Parser () +absMax) (Parser () -> Parser ()) -> Parser () -> Parser () forall a b. (a -> b) -> a -> b $ String -> Parser () @@ -200,10 +200,10 @@ $ Integer -> Int64 forall a. Num a => Integer -> a fromInteger Integer -int +int where - absMax :: Integer -absMax = Integer + absMax :: Integer +absMax = Integer 9223372036854775808 -- * Identifiers and keywords @@ -213,22 +213,22 @@ identifierP :: Parser Identifier identifierP :: Parser Text identifierP = Parser () -notReserved Parser () -> Parser Text -> Parser Text +notReserved Parser () -> Parser Text -> Parser Text forall a b. ParsecT Void Text Identity a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity b forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b *> Parser Text -identifier +identifier where - identifier :: Parser Text -identifier = Parser Text -> Parser Text + identifier :: Parser Text +identifier = Parser Text -> Parser Text forall a. Parser a -> Parser a lexeme (Parser Text -> Parser Text) -> Parser Text -> Parser Text forall a b. (a -> b) -> a -> b $ do - Char -first <- ParsecT Void Text Identity Char + Char +first <- ParsecT Void Text Identity Char ParsecT Void Text Identity (Token Text) forall e s (m :: * -> *). (MonadParsec e s m, Token s ~ Char) => @@ -247,8 +247,8 @@ char Char Token Text '_' - String -other <- ParsecT Void Text Identity Char + String +other <- ParsecT Void Text Identity Char -> ParsecT Void Text Identity String forall (m :: * -> *) a. MonadPlus m => m a -> m [a] many ParsecT Void Text Identity Char @@ -262,12 +262,12 @@ pack (String -> Text) -> String -> Text forall a b. (a -> b) -> a -> b $ Char -first Char -> String -> String +first Char -> String -> String forall a. a -> [a] -> [a] : String -other - notReserved :: Parser () -notReserved = +other + notReserved :: Parser () +notReserved = Parser Text -> Parser () forall a. ParsecT Void Text Identity a -> Parser () forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m () @@ -294,8 +294,8 @@ keyword :: Text -> Parser Text keyword :: Text -> Parser Text -keyword Text -ident = Parser Text -> Parser Text +keyword Text +ident = Parser Text -> Parser Text forall a. Parser a -> Parser a lexeme (Parser Text -> Parser Text) -> Parser Text -> Parser Text forall a b. (a -> b) -> a -> b @@ -305,7 +305,7 @@ Tokens s -> m (Tokens s) string Text Tokens Text -ident Parser Text -> Parser () -> Parser Text +ident Parser Text -> Parser () -> Parser Text forall a b. ParsecT Void Text Identity a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a diff --git a/src/Parser.Parser.html b/src/Parser.Parser.html index 81ff1a0..3a66d49 100644 --- a/src/Parser.Parser.html +++ b/src/Parser.Parser.html @@ -106,12 +106,12 @@ (Foldable f, Functor f) => f (Parser a) -> Parser a choice' [ParsecT Void Text Identity Declaration -recFunDeclP, ParsecT Void Text Identity Declaration -funDeclP, ParsecT Void Text Identity Declaration -varDeclP] +recFunDeclP, ParsecT Void Text Identity Declaration +funDeclP, ParsecT Void Text Identity Declaration +varDeclP] where - varDeclP :: ParsecT Void Text Identity Declaration -varDeclP = (Text, Maybe Type) -> Expression -> Declaration + varDeclP :: ParsecT Void Text Identity Declaration +varDeclP = (Text, Maybe Type) -> Expression -> Declaration DeclVar ((Text, Maybe Type) -> Expression -> Declaration) -> ParsecT Void Text Identity Text -> ParsecT @@ -135,7 +135,7 @@ -> ParsecT Void Text Identity a -> ParsecT Void Text Identity b forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ParsecT Void Text Identity (Text, Maybe Type) -varSigP ParsecT Void Text Identity (Expression -> Declaration) +varSigP ParsecT Void Text Identity (Expression -> Declaration) -> ParsecT Void Text Identity Text -> ParsecT Void Text Identity (Expression -> Declaration) forall a b. @@ -152,8 +152,8 @@ forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ParsecT Void Text Identity Expression exprP - funDeclP :: ParsecT Void Text Identity Declaration -funDeclP = (Text -> IsRec -> Fun -> Declaration) + funDeclP :: ParsecT Void Text Identity Declaration +funDeclP = (Text -> IsRec -> Fun -> Declaration) -> IsRec -> Text -> Fun -> Declaration forall a b c. (a -> b -> c) -> b -> a -> c flip Text -> IsRec -> Fun -> Declaration @@ -183,8 +183,8 @@ <*> ParsecT Void Text Identity Text -> ParsecT Void Text Identity Fun funP ParsecT Void Text Identity Text eq - recFunDeclP :: ParsecT Void Text Identity Declaration -recFunDeclP = (Text -> IsRec -> Fun -> Declaration) + recFunDeclP :: ParsecT Void Text Identity Declaration +recFunDeclP = (Text -> IsRec -> Fun -> Declaration) -> IsRec -> Text -> Fun -> Declaration forall a b c. (a -> b -> c) -> b -> a -> c flip Text -> IsRec -> Fun -> Declaration @@ -223,8 +223,8 @@ funP ParsecT Void Text Identity Text eq - varSigP :: ParsecT Void Text Identity (Text, Maybe Type) -varSigP = ParsecT Void Text Identity (Text, Maybe Type) + varSigP :: ParsecT Void Text Identity (Text, Maybe Type) +varSigP = ParsecT Void Text Identity (Text, Maybe Type) -> ParsecT Void Text Identity (Text, Maybe Type) forall a. Parser a -> Parser a manyParens (ParsecT Void Text Identity (Text, Maybe Type) @@ -503,9 +503,9 @@ binLeftOp :: Text -> BinaryOperator -> Operator (ParsecT Void Text Identity) Expression -binLeftOp Text -name BinaryOperator -op = ParsecT Void Text Identity (Expression -> Expression -> Expression) +binLeftOp Text +name BinaryOperator +op = ParsecT Void Text Identity (Expression -> Expression -> Expression) -> Operator (ParsecT Void Text Identity) Expression forall (m :: * -> *) a. m (a -> a -> a) -> Operator m a InfixL (ParsecT @@ -517,7 +517,7 @@ forall a b. (a -> b) -> a -> b $ BinaryOperator -> Expression -> Expression -> Expression ExprBinOp BinaryOperator -op (Expression -> Expression -> Expression) +op (Expression -> Expression -> Expression) -> ParsecT Void Text Identity Text -> ParsecT Void Text Identity (Expression -> Expression -> Expression) @@ -526,72 +526,72 @@ forall (f :: * -> *) a b. Functor f => a -> f b -> f a <$ Text -> ParsecT Void Text Identity Text symbol Text -name +name boolOp :: Text -> BooleanOperator -> Operator Parser Expression boolOp :: Text -> BooleanOperator -> Operator (ParsecT Void Text Identity) Expression -boolOp Text -name BooleanOperator -op = Text +boolOp Text +name BooleanOperator +op = Text -> BinaryOperator -> Operator (ParsecT Void Text Identity) Expression binLeftOp Text -name (BinaryOperator +name (BinaryOperator -> Operator (ParsecT Void Text Identity) Expression) -> BinaryOperator -> Operator (ParsecT Void Text Identity) Expression forall a b. (a -> b) -> a -> b $ BooleanOperator -> BinaryOperator BoolOp BooleanOperator -op +op arithOp :: Text -> ArithmeticOperator -> Operator Parser Expression arithOp :: Text -> ArithmeticOperator -> Operator (ParsecT Void Text Identity) Expression -arithOp Text -name ArithmeticOperator -op = Text +arithOp Text +name ArithmeticOperator +op = Text -> BinaryOperator -> Operator (ParsecT Void Text Identity) Expression binLeftOp Text -name (BinaryOperator +name (BinaryOperator -> Operator (ParsecT Void Text Identity) Expression) -> BinaryOperator -> Operator (ParsecT Void Text Identity) Expression forall a b. (a -> b) -> a -> b $ ArithmeticOperator -> BinaryOperator ArithOp ArithmeticOperator -op +op compOp :: Text -> ComparisonOperator -> Operator Parser Expression compOp :: Text -> ComparisonOperator -> Operator (ParsecT Void Text Identity) Expression -compOp Text -name ComparisonOperator -op = Text +compOp Text +name ComparisonOperator +op = Text -> BinaryOperator -> Operator (ParsecT Void Text Identity) Expression binLeftOp Text -name (BinaryOperator +name (BinaryOperator -> Operator (ParsecT Void Text Identity) Expression) -> BinaryOperator -> Operator (ParsecT Void Text Identity) Expression forall a b. (a -> b) -> a -> b $ ComparisonOperator -> BinaryOperator CompOp ComparisonOperator -op +op unOp :: Text -> UnaryOperator -> Operator Parser Expression unOp :: Text -> UnaryOperator -> Operator (ParsecT Void Text Identity) Expression -unOp Text -name UnaryOperator -op = ParsecT Void Text Identity (Expression -> Expression) +unOp Text +name UnaryOperator +op = ParsecT Void Text Identity (Expression -> Expression) -> Operator (ParsecT Void Text Identity) Expression forall (m :: * -> *) a. m (a -> a) -> Operator m a Prefix (ParsecT Void Text Identity (Expression -> Expression) @@ -601,7 +601,7 @@ forall a b. (a -> b) -> a -> b $ UnaryOperator -> Expression -> Expression ExprUnOp UnaryOperator -op (Expression -> Expression) +op (Expression -> Expression) -> ParsecT Void Text Identity Text -> ParsecT Void Text Identity (Expression -> Expression) forall a b. @@ -609,7 +609,7 @@ forall (f :: * -> *) a b. Functor f => a -> f b -> f a <$ Text -> ParsecT Void Text Identity Text symbol Text -name +name -- ** Type Parsers @@ -626,7 +626,7 @@ -> Parser Type -> ParsecT Void Text Identity (Type -> Type) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser Type -primitiveOrInParensTypeP ParsecT Void Text Identity (Type -> Type) +primitiveOrInParensTypeP ParsecT Void Text Identity (Type -> Type) -> ParsecT Void Text Identity Text -> ParsecT Void Text Identity (Type -> Type) forall a b. @@ -643,11 +643,11 @@ <*> Parser Type typeP, Parser Type -primitiveOrInParensTypeP +primitiveOrInParensTypeP ] where - primitiveOrInParensTypeP :: Parser Type -primitiveOrInParensTypeP = [Parser Type] -> Parser Type + primitiveOrInParensTypeP :: Parser Type +primitiveOrInParensTypeP = [Parser Type] -> Parser Type forall (f :: * -> *) a. (Foldable f, Functor f) => f (Parser a) -> Parser a @@ -655,9 +655,9 @@ forall a. Parser a -> Parser a parens Parser Type typeP, Parser Type -primitiveTypeP] - primitiveTypeP :: Parser Type -primitiveTypeP = +primitiveTypeP] + primitiveTypeP :: Parser Type +primitiveTypeP = [Parser Type] -> Parser Type forall (f :: * -> *) a. (Foldable f, Functor f) => @@ -726,8 +726,8 @@ funP :: Parser Text -> Parser Fun funP :: ParsecT Void Text Identity Text -> ParsecT Void Text Identity Fun -funP ParsecT Void Text Identity Text -sepSymbolP = NonEmpty (Text, Maybe Type) -> Maybe Type -> Expression -> Fun +funP ParsecT Void Text Identity Text +sepSymbolP = NonEmpty (Text, Maybe Type) -> Maybe Type -> Expression -> Fun Fun (NonEmpty (Text, Maybe Type) -> Maybe Type -> Expression -> Fun) -> ParsecT Void Text Identity (NonEmpty (Text, Maybe Type)) -> ParsecT Void Text Identity (Maybe Type -> Expression -> Fun) @@ -752,7 +752,7 @@ -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a <* ParsecT Void Text Identity Text -sepSymbolP ParsecT Void Text Identity (Expression -> Fun) +sepSymbolP ParsecT Void Text Identity (Expression -> Fun) -> ParsecT Void Text Identity Expression -> ParsecT Void Text Identity Fun forall a b. diff --git a/src/Parser.Utils.html b/src/Parser.Utils.html index f417163..9bf5a97 100644 --- a/src/Parser.Utils.html +++ b/src/Parser.Utils.html @@ -7,12 +7,12 @@ -- ** Backtracking support -choice' :: (Foldable f, Functor f) => f (Parser a) -> Parser a +choice' :: (Foldable f, Functor f) => f (Parser a) -> Parser a choice' :: forall (f :: * -> *) a. (Foldable f, Functor f) => f (Parser a) -> Parser a -choice' f (Parser a) -ps = f (Parser a) -> Parser a +choice' f (Parser a) +ps = f (Parser a) -> Parser a forall (f :: * -> *) (m :: * -> *) a. (Foldable f, Alternative m) => f (m a) -> m a @@ -25,9 +25,9 @@ try (Parser a -> Parser a) -> f (Parser a) -> f (Parser a) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> f (Parser a) -ps +ps -optional' :: Parser a -> Parser (Maybe a) +optional' :: Parser a -> Parser (Maybe a) optional' :: forall a. Parser a -> Parser (Maybe a) optional' = ParsecT Void Text Identity a -> ParsecT Void Text Identity (Maybe a) @@ -47,7 +47,7 @@ -- ** Parenthesis -- | Wraps the given parser with parenthesis. -parens :: Parser a -> Parser a +parens :: Parser a -> Parser a parens :: forall a. ParsecT Void Text Identity a -> ParsecT Void Text Identity a parens = ParsecT Void Text Identity Text @@ -61,26 +61,26 @@ leftPar ParsecT Void Text Identity Text rightPar -manyParens :: Parser a -> Parser a +manyParens :: Parser a -> Parser a manyParens :: forall a. ParsecT Void Text Identity a -> ParsecT Void Text Identity a -manyParens Parser a -p = [Parser a] -> Parser a +manyParens Parser a +p = [Parser a] -> Parser a forall (f :: * -> *) a. (Foldable f, Functor f) => f (Parser a) -> Parser a choice' [Parser a -p, Parser a -> Parser a +p, Parser a -> Parser a forall a. ParsecT Void Text Identity a -> ParsecT Void Text Identity a someParens Parser a -p] +p] -someParens :: Parser a -> Parser a +someParens :: Parser a -> Parser a someParens :: forall a. ParsecT Void Text Identity a -> ParsecT Void Text Identity a -someParens Parser a -p = Parser a -> Parser a +someParens Parser a +p = Parser a -> Parser a forall a. ParsecT Void Text Identity a -> ParsecT Void Text Identity a parens (Parser a -> Parser a) -> Parser a -> Parser a @@ -90,9 +90,9 @@ (Foldable f, Functor f) => f (Parser a) -> Parser a choice' [Parser a -p, Parser a -> Parser a +p, Parser a -> Parser a forall a. ParsecT Void Text Identity a -> ParsecT Void Text Identity a someParens Parser a -p] +p] \ No newline at end of file diff --git a/src/StdLib.html b/src/StdLib.html index 3e67f50..c2f3e82 100644 --- a/src/StdLib.html +++ b/src/StdLib.html @@ -43,7 +43,7 @@ allDeclsWithArity :: [DeclarationWithArity] allDeclsWithArity = (TypedDeclaration -> DeclarationWithArity forall {a}. (a, Type) -> (a, Arity) -convert (TypedDeclaration -> DeclarationWithArity) +convert (TypedDeclaration -> DeclarationWithArity) -> [TypedDeclaration] -> [DeclarationWithArity] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [TypedDeclaration] @@ -55,17 +55,17 @@ funToPafDecl, DeclarationWithArity applyDecl] where - convert :: (a, Type) -> (a, Arity) -convert (a -ident, Type -t) = (a -ident, Type -> Arity -calcArity Type -t) + convert :: (a, Type) -> (a, Arity) +convert (a +ident, Type +t) = (a +ident, Type -> Arity +calcArity Type +t) - calcArity :: Type -> Arity - calcArity :: Type -> Arity -calcArity = (ListF Type Arity -> Arity) + calcArity :: Type -> Arity + calcArity :: Type -> Arity +calcArity = (ListF Type Arity -> Arity) -> (Type -> ListF Type Type) -> Type -> Arity forall (f :: * -> *) b a. Functor f => @@ -74,18 +74,18 @@ forall a. ListF Type a -> Arity forall (t :: * -> *) a. Foldable t => t a -> Arity length Type -> ListF Type Type -getParams +getParams - getParams :: Type -> ListF Type Type - getParams :: Type -> ListF Type Type -getParams (TFun Type -pT Type -retT) = Type -> Type -> ListF Type Type + getParams :: Type -> ListF Type Type + getParams :: Type -> ListF Type Type +getParams (TFun Type +pT Type +retT) = Type -> Type -> ListF Type Type forall a b. a -> b -> ListF a b Cons Type -pT Type -retT - getParams Type +pT Type +retT + getParams Type _ = ListF Type Type forall a b. ListF a b Nil diff --git a/src/Transformations.Anf.Anf.html b/src/Transformations.Anf.Anf.html index cee972a..cc313ea 100644 --- a/src/Transformations.Anf.Anf.html +++ b/src/Transformations.Anf.Anf.html @@ -4,7 +4,7 @@ import Trees.Common newtype Program = Program [GlobalDeclaration] - deriving (Int -> Program -> ShowS + deriving (Int -> Program -> ShowS [Program] -> ShowS Program -> String (Int -> Program -> ShowS) @@ -17,7 +17,7 @@ show :: Program -> String $cshowList :: [Program] -> ShowS showList :: [Program] -> ShowS -Show, Program -> Program -> Bool +Show, Program -> Program -> Bool (Program -> Program -> Bool) -> (Program -> Program -> Bool) -> Eq Program forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -30,7 +30,7 @@ data GlobalDeclaration = GlobVarDecl Identifier' Expression | GlobFunDecl Identifier' [Identifier'] Expression - deriving (Int -> GlobalDeclaration -> ShowS + deriving (Int -> GlobalDeclaration -> ShowS [GlobalDeclaration] -> ShowS GlobalDeclaration -> String (Int -> GlobalDeclaration -> ShowS) @@ -45,7 +45,7 @@ show :: GlobalDeclaration -> String $cshowList :: [GlobalDeclaration] -> ShowS showList :: [GlobalDeclaration] -> ShowS -Show, GlobalDeclaration -> GlobalDeclaration -> Bool +Show, GlobalDeclaration -> GlobalDeclaration -> Bool (GlobalDeclaration -> GlobalDeclaration -> Bool) -> (GlobalDeclaration -> GlobalDeclaration -> Bool) -> Eq GlobalDeclaration @@ -60,7 +60,7 @@ = ExprAtom AtomicExpression | ExprComp ComplexExpression | ExprLetIn (Identifier', Expression) Expression - deriving (Int -> Expression -> ShowS + deriving (Int -> Expression -> ShowS [Expression] -> ShowS Expression -> String (Int -> Expression -> ShowS) @@ -75,7 +75,7 @@ show :: Expression -> String $cshowList :: [Expression] -> ShowS showList :: [Expression] -> ShowS -Show, Expression -> Expression -> Bool +Show, Expression -> Expression -> Bool (Expression -> Expression -> Bool) -> (Expression -> Expression -> Bool) -> Eq Expression forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -90,7 +90,7 @@ | AtomUnit | AtomBool Bool | AtomInt Int64 - deriving (Int -> AtomicExpression -> ShowS + deriving (Int -> AtomicExpression -> ShowS [AtomicExpression] -> ShowS AtomicExpression -> String (Int -> AtomicExpression -> ShowS) @@ -105,7 +105,7 @@ show :: AtomicExpression -> String $cshowList :: [AtomicExpression] -> ShowS showList :: [AtomicExpression] -> ShowS -Show, AtomicExpression -> AtomicExpression -> Bool +Show, AtomicExpression -> AtomicExpression -> Bool (AtomicExpression -> AtomicExpression -> Bool) -> (AtomicExpression -> AtomicExpression -> Bool) -> Eq AtomicExpression @@ -121,7 +121,7 @@ | CompIte AtomicExpression Expression Expression | CompBinOp BinaryOperator AtomicExpression AtomicExpression | CompUnOp UnaryOperator AtomicExpression - deriving (Int -> ComplexExpression -> ShowS + deriving (Int -> ComplexExpression -> ShowS [ComplexExpression] -> ShowS ComplexExpression -> String (Int -> ComplexExpression -> ShowS) @@ -136,7 +136,7 @@ show :: ComplexExpression -> String $cshowList :: [ComplexExpression] -> ShowS showList :: [ComplexExpression] -> ShowS -Show, ComplexExpression -> ComplexExpression -> Bool +Show, ComplexExpression -> ComplexExpression -> Bool (ComplexExpression -> ComplexExpression -> Bool) -> (ComplexExpression -> ComplexExpression -> Bool) -> Eq ComplexExpression diff --git a/src/Transformations.Anf.AnfGen.html b/src/Transformations.Anf.AnfGen.html index 8308068..90c5adb 100644 --- a/src/Transformations.Anf.AnfGen.html +++ b/src/Transformations.Anf.AnfGen.html @@ -14,11 +14,11 @@ genAnf :: Lfr.Program -> Anf.Program genAnf :: Program -> Program -genAnf (Lfr.Program [GlobalDeclaration] -gDecls Env -cnt) = - let gDecls' :: [GlobalDeclaration] -gDecls' = State Env [GlobalDeclaration] -> Env -> [GlobalDeclaration] +genAnf (Lfr.Program [GlobalDeclaration] +gDecls Env +cnt) = + let gDecls' :: [GlobalDeclaration] +gDecls' = State Env [GlobalDeclaration] -> Env -> [GlobalDeclaration] forall s a. State s a -> s -> a evalState ((GlobalDeclaration -> StateT Env Identity GlobalDeclaration) -> [GlobalDeclaration] -> State Env [GlobalDeclaration] @@ -28,17 +28,17 @@ forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapM GlobalDeclaration -> StateT Env Identity GlobalDeclaration genDecl [GlobalDeclaration] -gDecls) Env -cnt +gDecls) Env +cnt in [GlobalDeclaration] -> Program Anf.Program [GlobalDeclaration] -gDecls' +gDecls' -- * Internal -- ** ANF Normalizer Continuation & Generator State -type NormCont r a = ContT r AnfGenState a +type NormCont r a = ContT r AnfGenState a type AnfGenState = State Env @@ -48,35 +48,35 @@ genDecl :: Lfr.GlobalDeclaration -> AnfGenState Anf.GlobalDeclaration genDecl :: GlobalDeclaration -> StateT Env Identity GlobalDeclaration -genDecl (Lfr.GlobVarDecl (Lfr.VarDecl Identifier' -ident Expression -value)) = Identifier' -> Expression -> GlobalDeclaration +genDecl (Lfr.GlobVarDecl (Lfr.VarDecl Identifier' +ident Expression +value)) = Identifier' -> Expression -> GlobalDeclaration Anf.GlobVarDecl Identifier' -ident (Expression -> GlobalDeclaration) +ident (Expression -> GlobalDeclaration) -> StateT Env Identity Expression -> StateT Env Identity GlobalDeclaration forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Expression -> StateT Env Identity Expression genExpr Expression -value -genDecl (Lfr.GlobFunDecl Identifier' -ident [Identifier'] -params Expression -body) = Identifier' -> [Identifier'] -> Expression -> GlobalDeclaration +value +genDecl (Lfr.GlobFunDecl Identifier' +ident [Identifier'] +params Expression +body) = Identifier' -> [Identifier'] -> Expression -> GlobalDeclaration Anf.GlobFunDecl Identifier' -ident [Identifier'] -params (Expression -> GlobalDeclaration) +ident [Identifier'] +params (Expression -> GlobalDeclaration) -> StateT Env Identity Expression -> StateT Env Identity GlobalDeclaration forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Expression -> StateT Env Identity Expression genExpr Expression -body +body genExpr :: Lfr.Expression -> AnfGenState Anf.Expression genExpr :: Expression -> StateT Env Identity Expression -genExpr (Lfr.ExprId Identifier' -ident) = AtomicExpression -> StateT Env Identity Expression +genExpr (Lfr.ExprId Identifier' +ident) = AtomicExpression -> StateT Env Identity Expression forall (m :: * -> *). MonadState Env m => AtomicExpression -> m Expression @@ -85,9 +85,9 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> AtomicExpression Anf.AtomId Identifier' -ident -genExpr (Lfr.ExprPrimVal PrimitiveValue -val) = AtomicExpression -> StateT Env Identity Expression +ident +genExpr (Lfr.ExprPrimVal PrimitiveValue +val) = AtomicExpression -> StateT Env Identity Expression forall (m :: * -> *). MonadState Env m => AtomicExpression -> m Expression @@ -95,22 +95,22 @@ -> AtomicExpression -> StateT Env Identity Expression forall a b. (a -> b) -> a -> b $ case PrimitiveValue -val of +val of PrimitiveValue Common.PrimValUnit -> AtomicExpression Anf.AtomUnit - Common.PrimValBool Bool -bool -> Bool -> AtomicExpression + Common.PrimValBool Bool +bool -> Bool -> AtomicExpression Anf.AtomBool Bool -bool - Common.PrimValInt Int64 -int -> Int64 -> AtomicExpression +bool + Common.PrimValInt Int64 +int -> Int64 -> AtomicExpression Anf.AtomInt Int64 -int -genExpr (Lfr.ExprBinOp BinaryOperator -op Expression -lhs Expression -rhs) = ContT Expression (StateT Env Identity) Expression +int +genExpr (Lfr.ExprBinOp BinaryOperator +op Expression +lhs Expression +rhs) = ContT Expression (StateT Env Identity) Expression -> StateT Env Identity Expression forall (m :: * -> *) r. Monad m => ContT r m r -> m r evalContT (ContT Expression (StateT Env Identity) Expression @@ -119,14 +119,14 @@ -> StateT Env Identity Expression forall a b. (a -> b) -> a -> b $ do - AtomicExpression -lhs' <- Expression -> NormCont Expression AtomicExpression + AtomicExpression +lhs' <- Expression -> NormCont Expression AtomicExpression normalizeToAtom Expression -lhs - AtomicExpression -rhs' <- Expression -> NormCont Expression AtomicExpression +lhs + AtomicExpression +rhs' <- Expression -> NormCont Expression AtomicExpression normalizeToAtom Expression -rhs +rhs ComplexExpression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *). @@ -140,12 +140,12 @@ $ BinaryOperator -> AtomicExpression -> AtomicExpression -> ComplexExpression Anf.CompBinOp BinaryOperator -op AtomicExpression -lhs' AtomicExpression -rhs' -genExpr (Lfr.ExprUnOp UnaryOperator -op Expression -x) = ContT Expression (StateT Env Identity) Expression +op AtomicExpression +lhs' AtomicExpression +rhs' +genExpr (Lfr.ExprUnOp UnaryOperator +op Expression +x) = ContT Expression (StateT Env Identity) Expression -> StateT Env Identity Expression forall (m :: * -> *) r. Monad m => ContT r m r -> m r evalContT (ContT Expression (StateT Env Identity) Expression @@ -154,10 +154,10 @@ -> StateT Env Identity Expression forall a b. (a -> b) -> a -> b $ do - AtomicExpression -x' <- Expression -> NormCont Expression AtomicExpression + AtomicExpression +x' <- Expression -> NormCont Expression AtomicExpression normalizeToAtom Expression -x +x ComplexExpression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *). @@ -170,11 +170,11 @@ forall a b. (a -> b) -> a -> b $ UnaryOperator -> AtomicExpression -> ComplexExpression Anf.CompUnOp UnaryOperator -op AtomicExpression -x' -genExpr (Lfr.ExprApp Expression -f Expression -arg) = ContT Expression (StateT Env Identity) Expression +op AtomicExpression +x' +genExpr (Lfr.ExprApp Expression +f Expression +arg) = ContT Expression (StateT Env Identity) Expression -> StateT Env Identity Expression forall (m :: * -> *) r. Monad m => ContT r m r -> m r evalContT (ContT Expression (StateT Env Identity) Expression @@ -183,14 +183,14 @@ -> StateT Env Identity Expression forall a b. (a -> b) -> a -> b $ do - Identifier' -f' <- Expression -> NormCont Expression Identifier' + Identifier' +f' <- Expression -> NormCont Expression Identifier' normalizeToId Expression -f - AtomicExpression -arg' <- Expression -> NormCont Expression AtomicExpression +f + AtomicExpression +arg' <- Expression -> NormCont Expression AtomicExpression normalizeToAtom Expression -arg +arg ComplexExpression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *). @@ -203,12 +203,12 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> AtomicExpression -> ComplexExpression Anf.CompApp Identifier' -f' AtomicExpression -arg' -genExpr (Lfr.ExprIte Expression -c Expression -t Expression -e) = ContT Expression (StateT Env Identity) Expression +f' AtomicExpression +arg' +genExpr (Lfr.ExprIte Expression +c Expression +t Expression +e) = ContT Expression (StateT Env Identity) Expression -> StateT Env Identity Expression forall (m :: * -> *) r. Monad m => ContT r m r -> m r evalContT (ContT Expression (StateT Env Identity) Expression @@ -217,12 +217,12 @@ -> StateT Env Identity Expression forall a b. (a -> b) -> a -> b $ do - AtomicExpression -c' <- Expression -> NormCont Expression AtomicExpression + AtomicExpression +c' <- Expression -> NormCont Expression AtomicExpression normalizeToAtom Expression -c - Expression -t' <- StateT Env Identity Expression +c + Expression +t' <- StateT Env Identity Expression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *) a. Monad m => m a -> ContT Expression m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. @@ -235,9 +235,9 @@ forall a b. (a -> b) -> a -> b $ Expression -> StateT Env Identity Expression genExpr Expression -t - Expression -e' <- StateT Env Identity Expression +t + Expression +e' <- StateT Env Identity Expression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *) a. Monad m => m a -> ContT Expression m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. @@ -250,7 +250,7 @@ forall a b. (a -> b) -> a -> b $ Expression -> StateT Env Identity Expression genExpr Expression -e +e ComplexExpression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *). @@ -263,21 +263,21 @@ forall a b. (a -> b) -> a -> b $ AtomicExpression -> Expression -> Expression -> ComplexExpression Anf.CompIte AtomicExpression -c' Expression -t' Expression -e' -genExpr (Lfr.ExprLetIn (Lfr.VarDecl Identifier' -ident Expression -val) Expression -expr) = do - Expression -val' <- Expression -> StateT Env Identity Expression +c' Expression +t' Expression +e' +genExpr (Lfr.ExprLetIn (Lfr.VarDecl Identifier' +ident Expression +val) Expression +expr) = do + Expression +val' <- Expression -> StateT Env Identity Expression genExpr Expression -val - Expression -expr' <- Expression -> StateT Env Identity Expression +val + Expression +expr' <- Expression -> StateT Env Identity Expression genExpr Expression -expr +expr Expression -> StateT Env Identity Expression forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -286,11 +286,11 @@ forall a b. (a -> b) -> a -> b $ (Identifier', Expression) -> Expression -> Expression Anf.ExprLetIn (Identifier' -ident, Expression -val') Expression -expr' +ident, Expression +val') Expression +expr' -returnAtom :: (MonadState Env m) => Anf.AtomicExpression -> m Anf.Expression +returnAtom :: (MonadState Env m) => Anf.AtomicExpression -> m Anf.Expression returnAtom :: forall (m :: * -> *). MonadState Env m => AtomicExpression -> m Expression @@ -305,7 +305,7 @@ . AtomicExpression -> Expression Anf.ExprAtom -returnComplex :: (MonadState Env m) => Anf.ComplexExpression -> m Anf.Expression +returnComplex :: (MonadState Env m) => Anf.ComplexExpression -> m Anf.Expression returnComplex :: forall (m :: * -> *). MonadState Env m => ComplexExpression -> m Expression @@ -324,10 +324,10 @@ normalizeToAtom :: Lfr.Expression -> NormCont Anf.Expression Anf.AtomicExpression normalizeToAtom :: Expression -> NormCont Expression AtomicExpression -normalizeToAtom Expression -expr = do - Expression -expr' <- StateT Env Identity Expression +normalizeToAtom Expression +expr = do + Expression +expr' <- StateT Env Identity Expression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *) a. Monad m => m a -> ContT Expression m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. @@ -340,19 +340,19 @@ forall a b. (a -> b) -> a -> b $ Expression -> StateT Env Identity Expression genExpr Expression -expr +expr case Expression -expr' of - Anf.ExprAtom AtomicExpression -atom -> AtomicExpression -> NormCont Expression AtomicExpression +expr' of + Anf.ExprAtom AtomicExpression +atom -> AtomicExpression -> NormCont Expression AtomicExpression forall a. a -> ContT Expression (StateT Env Identity) a forall (m :: * -> *) a. Monad m => a -> m a return AtomicExpression -atom +atom Expression _ -> do - Identifier' -ident <- AnfGenState Identifier' -> NormCont Expression Identifier' + Identifier' +ident <- AnfGenState Identifier' -> NormCont Expression Identifier' forall (m :: * -> *) a. Monad m => m a -> ContT Expression m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. (MonadTrans t, Monad m) => @@ -365,15 +365,15 @@ forall {k} (m :: k -> *) (r :: k) a. (m r -> m r) -> ContT r m a -> ContT r m a mapContT - (\StateT Env Identity Expression -e -> (Identifier', Expression) -> Expression -> Expression + (\StateT Env Identity Expression +e -> (Identifier', Expression) -> Expression -> Expression Anf.ExprLetIn (Identifier' -ident, Expression -expr') (Expression -> Expression) +ident, Expression +expr') (Expression -> Expression) -> StateT Env Identity Expression -> StateT Env Identity Expression forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> StateT Env Identity Expression -e) +e) (AtomicExpression -> NormCont Expression AtomicExpression forall a. a -> ContT Expression (StateT Env Identity) a forall (m :: * -> *) a. Monad m => a -> m a @@ -382,14 +382,14 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> AtomicExpression Anf.AtomId Identifier' -ident) +ident) normalizeToId :: Lfr.Expression -> NormCont Anf.Expression Common.Identifier' normalizeToId :: Expression -> NormCont Expression Identifier' -normalizeToId Expression -expr = do - Expression -expr' <- StateT Env Identity Expression +normalizeToId Expression +expr = do + Expression +expr' <- StateT Env Identity Expression -> ContT Expression (StateT Env Identity) Expression forall (m :: * -> *) a. Monad m => m a -> ContT Expression m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. @@ -402,19 +402,19 @@ forall a b. (a -> b) -> a -> b $ Expression -> StateT Env Identity Expression genExpr Expression -expr +expr case Expression -expr' of - Anf.ExprAtom (Anf.AtomId Identifier' -ident) -> Identifier' -> NormCont Expression Identifier' +expr' of + Anf.ExprAtom (Anf.AtomId Identifier' +ident) -> Identifier' -> NormCont Expression Identifier' forall a. a -> ContT Expression (StateT Env Identity) a forall (m :: * -> *) a. Monad m => a -> m a return Identifier' -ident +ident Expression _ -> do - Identifier' -ident <- AnfGenState Identifier' -> NormCont Expression Identifier' + Identifier' +ident <- AnfGenState Identifier' -> NormCont Expression Identifier' forall (m :: * -> *) a. Monad m => m a -> ContT Expression m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. (MonadTrans t, Monad m) => @@ -427,28 +427,28 @@ forall {k} (m :: k -> *) (r :: k) a. (m r -> m r) -> ContT r m a -> ContT r m a mapContT - (\StateT Env Identity Expression -e -> (Identifier', Expression) -> Expression -> Expression + (\StateT Env Identity Expression +e -> (Identifier', Expression) -> Expression -> Expression Anf.ExprLetIn (Identifier' -ident, Expression -expr') (Expression -> Expression) +ident, Expression +expr') (Expression -> Expression) -> StateT Env Identity Expression -> StateT Env Identity Expression forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> StateT Env Identity Expression -e) +e) (Identifier' -> NormCont Expression Identifier' forall a. a -> ContT Expression (StateT Env Identity) a forall (m :: * -> *) a. Monad m => a -> m a return Identifier' -ident) +ident) -- ** Identifier Generation genId :: AnfGenState Common.Identifier' genId :: AnfGenState Identifier' genId = do - Env -cnt <- StateT Env Identity Env + Env +cnt <- StateT Env Identity Env forall s (m :: * -> *). MonadState s m => m s get (Env -> Env) -> StateT Env Identity () @@ -465,7 +465,7 @@ forall a b. (a -> b) -> a -> b $ Env -> Identifier -> Identifier' Common.Gen Env -cnt (Identifier -> Identifier') -> Identifier -> Identifier' +cnt (Identifier -> Identifier') -> Identifier -> Identifier' forall a b. (a -> b) -> a -> b $ String -> Identifier pack String diff --git a/src/Transformations.Anf.PrettyPrinter.html b/src/Transformations.Anf.PrettyPrinter.html index 7847f4c..ade4471 100644 --- a/src/Transformations.Anf.PrettyPrinter.html +++ b/src/Transformations.Anf.PrettyPrinter.html @@ -9,15 +9,15 @@ prettyPrint :: Program -> String prettyPrint :: Program -> String -prettyPrint (Program [GlobalDeclaration] -decls) = [String] -> String +prettyPrint (Program [GlobalDeclaration] +decls) = [String] -> String unlines ([String] -> String) -> [String] -> String forall a b. (a -> b) -> a -> b $ GlobalDeclaration -> String prettyDecl (GlobalDeclaration -> String) -> [GlobalDeclaration] -> [String] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [GlobalDeclaration] -decls +decls type IndentState = State IndentLevel @@ -25,26 +25,26 @@ prettyDecl :: GlobalDeclaration -> String prettyDecl :: GlobalDeclaration -> String -prettyDecl GlobalDeclaration -decl = State IdCnt String -> IdCnt -> String +prettyDecl GlobalDeclaration +decl = State IdCnt String -> IdCnt -> String forall s a. State s a -> s -> a evalState (GlobalDeclaration -> State IdCnt String -prettyDecl' GlobalDeclaration -decl) IdCnt +prettyDecl' GlobalDeclaration +decl) IdCnt 0 String -> String -> String forall a. Semigroup a => a -> a -> a <> String ";;" where - prettyDecl' :: GlobalDeclaration -> IndentState String - prettyDecl' :: GlobalDeclaration -> State IdCnt String -prettyDecl' (GlobVarDecl Identifier' -name Expression -value) = do - String -val' <- Expression -> State IdCnt String + prettyDecl' :: GlobalDeclaration -> IndentState String + prettyDecl' :: GlobalDeclaration -> State IdCnt String +prettyDecl' (GlobVarDecl Identifier' +name Expression +value) = do + String +val' <- Expression -> State IdCnt String prettyExpr Expression -value +value String -> State IdCnt String forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -54,17 +54,17 @@ unwords [String "let", Identifier' -> String prettyId Identifier' -name, String +name, String "=", String -val'] - prettyDecl' (GlobFunDecl Identifier' -name [Identifier'] -params Expression -body) = do - String -val' <- Expression -> State IdCnt String +val'] + prettyDecl' (GlobFunDecl Identifier' +name [Identifier'] +params Expression +body) = do + String +val' <- Expression -> State IdCnt String prettyExpr Expression -body +body String -> State IdCnt String forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -74,87 +74,87 @@ unwords [String "let", Identifier' -> String prettyId Identifier' -name, [String] -> String +name, [String] -> String unwords (Identifier' -> String prettyId (Identifier' -> String) -> [Identifier'] -> [String] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Identifier'] -params), String +params), String "=", String -val'] +val'] prettyExpr :: Expression -> IndentState String prettyExpr :: Expression -> State IdCnt String -prettyExpr (ExprAtom AtomicExpression -aexpr) = String -> State IdCnt String +prettyExpr (ExprAtom AtomicExpression +aexpr) = String -> State IdCnt String forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a return (String -> State IdCnt String) -> String -> State IdCnt String forall a b. (a -> b) -> a -> b $ AtomicExpression -> String prettyAtomic AtomicExpression -aexpr -prettyExpr (ExprComp ComplexExpression -cexpr) = ComplexExpression -> State IdCnt String +aexpr +prettyExpr (ExprComp ComplexExpression +cexpr) = ComplexExpression -> State IdCnt String prettyComplex ComplexExpression -cexpr -prettyExpr (ExprLetIn (Identifier' -ident, Expression -val) Expression -expr) = do +cexpr +prettyExpr (ExprLetIn (Identifier' +ident, Expression +val) Expression +expr) = do (IdCnt -> IdCnt) -> StateT IdCnt Identity () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify (IdCnt -> IdCnt -> IdCnt forall a. Num a => a -> a -> a + IdCnt 2) - IdCnt -indent <- StateT IdCnt Identity IdCnt + IdCnt +indent <- StateT IdCnt Identity IdCnt forall s (m :: * -> *). MonadState s m => m s get - String -val' <- Expression -> State IdCnt String + String +val' <- Expression -> State IdCnt String prettyExpr Expression -val - String -expr' <- Expression -> State IdCnt String +val + String +expr' <- Expression -> State IdCnt String prettyExpr Expression -expr - let declText :: String -declText = IdCnt -> String +expr + let declText :: String +declText = IdCnt -> String createIndent IdCnt -indent String -> String -> String +indent String -> String -> String forall a. Semigroup a => a -> a -> a <> String "let " String -> String -> String forall a. Semigroup a => a -> a -> a <> Identifier' -> String prettyId Identifier' -ident String -> String -> String +ident String -> String -> String forall a. Semigroup a => a -> a -> a <> String " = " String -> String -> String forall a. Semigroup a => a -> a -> a <> String -val' - let exprText :: String -exprText = IdCnt -> String +val' + let exprText :: String +exprText = IdCnt -> String createIndent IdCnt -indent String -> String -> String +indent String -> String -> String forall a. Semigroup a => a -> a -> a <> String "in " String -> String -> String forall a. Semigroup a => a -> a -> a <> String -expr' +expr' (IdCnt -> IdCnt) -> StateT IdCnt Identity () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((IdCnt -> IdCnt) -> StateT IdCnt Identity ()) -> (IdCnt -> IdCnt) -> StateT IdCnt Identity () forall a b. (a -> b) -> a -> b -$ \IdCnt -x -> IdCnt -x IdCnt -> IdCnt -> IdCnt +$ \IdCnt +x -> IdCnt +x IdCnt -> IdCnt -> IdCnt forall a. Num a => a -> a -> a - IdCnt 2 @@ -164,17 +164,17 @@ return (String -> State IdCnt String) -> String -> State IdCnt String forall a b. (a -> b) -> a -> b $ String -declText String -> String -> String +declText String -> String -> String forall a. Semigroup a => a -> a -> a <> String -exprText +exprText prettyComplex :: ComplexExpression -> IndentState String prettyComplex :: ComplexExpression -> State IdCnt String prettyComplex = \case - CompApp Identifier' -f AtomicExpression -arg -> String -> State IdCnt String + CompApp Identifier' +f AtomicExpression +arg -> String -> State IdCnt String forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a return (String -> State IdCnt String) -> String -> State IdCnt String @@ -184,32 +184,32 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> String prettyId Identifier' -f String -> String -> String +f String -> String -> String forall a. Semigroup a => a -> a -> a <> String " " String -> String -> String forall a. Semigroup a => a -> a -> a <> AtomicExpression -> String prettyAtomic AtomicExpression -arg - CompIte AtomicExpression -c Expression -t Expression -e -> do +arg + CompIte AtomicExpression +c Expression +t Expression +e -> do (IdCnt -> IdCnt) -> StateT IdCnt Identity () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify (IdCnt -> IdCnt -> IdCnt forall a. Num a => a -> a -> a + IdCnt 4) - IdCnt -indent <- StateT IdCnt Identity IdCnt + IdCnt +indent <- StateT IdCnt Identity IdCnt forall s (m :: * -> *). MonadState s m => m s get - let cText :: String -cText = IdCnt -> String + let cText :: String +cText = IdCnt -> String createIndent (IdCnt -indent IdCnt -> IdCnt -> IdCnt +indent IdCnt -> IdCnt -> IdCnt forall a. Num a => a -> a -> a - IdCnt 2) String -> String -> String @@ -219,43 +219,43 @@ forall a. Semigroup a => a -> a -> a <> AtomicExpression -> String prettyAtomic AtomicExpression -c - String -t' <- Expression -> State IdCnt String +c + String +t' <- Expression -> State IdCnt String prettyExpr Expression -t - let tText :: String -tText = IdCnt -> String +t + let tText :: String +tText = IdCnt -> String createIndent IdCnt -indent String -> String -> String +indent String -> String -> String forall a. Semigroup a => a -> a -> a <> String "then " String -> String -> String forall a. Semigroup a => a -> a -> a <> String -t' - String -e' <- Expression -> State IdCnt String +t' + String +e' <- Expression -> State IdCnt String prettyExpr Expression -e - let eText :: String -eText = IdCnt -> String +e + let eText :: String +eText = IdCnt -> String createIndent IdCnt -indent String -> String -> String +indent String -> String -> String forall a. Semigroup a => a -> a -> a <> String "else " String -> String -> String forall a. Semigroup a => a -> a -> a <> String -e' +e' (IdCnt -> IdCnt) -> StateT IdCnt Identity () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((IdCnt -> IdCnt) -> StateT IdCnt Identity ()) -> (IdCnt -> IdCnt) -> StateT IdCnt Identity () forall a b. (a -> b) -> a -> b -$ \IdCnt -x -> IdCnt -x IdCnt -> IdCnt -> IdCnt +$ \IdCnt +x -> IdCnt +x IdCnt -> IdCnt -> IdCnt forall a. Num a => a -> a -> a - IdCnt 4 @@ -265,17 +265,17 @@ return (String -> State IdCnt String) -> String -> State IdCnt String forall a b. (a -> b) -> a -> b $ String -cText String -> String -> String +cText String -> String -> String forall a. Semigroup a => a -> a -> a <> String -tText String -> String -> String +tText String -> String -> String forall a. Semigroup a => a -> a -> a <> String -eText - CompBinOp BinaryOperator -op AtomicExpression -lhs AtomicExpression -rhs -> String -> State IdCnt String +eText + CompBinOp BinaryOperator +op AtomicExpression +lhs AtomicExpression +rhs -> String -> State IdCnt String forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a return (String -> State IdCnt String) -> String -> State IdCnt String @@ -284,14 +284,14 @@ parens ([String] -> String unwords [AtomicExpression -> String prettyAtomic AtomicExpression -lhs, BinaryOperator -> String +lhs, BinaryOperator -> String prettyBinOp BinaryOperator -op, AtomicExpression -> String +op, AtomicExpression -> String prettyAtomic AtomicExpression -rhs]) - CompUnOp UnaryOperator -op AtomicExpression -x -> String -> State IdCnt String +rhs]) + CompUnOp UnaryOperator +op AtomicExpression +x -> String -> State IdCnt String forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a return (String -> State IdCnt String) -> String -> State IdCnt String @@ -301,44 +301,44 @@ forall a b. (a -> b) -> a -> b $ UnaryOperator -> String prettyUnOp UnaryOperator -op String -> String -> String +op String -> String -> String forall a. Semigroup a => a -> a -> a <> AtomicExpression -> String prettyAtomic AtomicExpression -x +x prettyAtomic :: AtomicExpression -> String prettyAtomic :: AtomicExpression -> String prettyAtomic = \case - AtomId Identifier' -name -> Identifier' -> String + AtomId Identifier' +name -> Identifier' -> String prettyId Identifier' -name +name AtomicExpression AtomUnit -> String "()" - AtomBool Bool -value -> if Bool -value then String + AtomBool Bool +value -> if Bool +value then String "true" else String "false" - AtomInt Int64 -value -> Int64 -> String + AtomInt Int64 +value -> Int64 -> String forall a. Show a => a -> String show Int64 -value +value prettyId :: Identifier' -> String prettyId :: Identifier' -> String -prettyId (Txt Identifier -n) = Identifier -> String +prettyId (Txt Identifier +n) = Identifier -> String unpack Identifier -n -prettyId (Gen IdCnt -n Identifier -ident) = Identifier -> String +n +prettyId (Gen IdCnt +n Identifier +ident) = Identifier -> String unpack Identifier -ident String -> String -> String +ident String -> String -> String forall a. Semigroup a => a -> a -> a <> String "'" String -> String -> String @@ -346,7 +346,7 @@ <> IdCnt -> String forall a. Show a => a -> String show IdCnt -n +n prettyBinOp :: BinaryOperator -> String prettyBinOp :: BinaryOperator -> String @@ -396,24 +396,24 @@ createIndent :: Int -> String createIndent :: IdCnt -> String -createIndent IdCnt -indent = String +createIndent IdCnt +indent = String "\n" String -> String -> String forall a. Semigroup a => a -> a -> a <> IdCnt -> Char -> String forall a. IdCnt -> a -> [a] replicate IdCnt -indent Char +indent Char ' ' parens :: String -> String parens :: String -> String -parens String -val = String +parens String +val = String "(" String -> String -> String forall a. Semigroup a => a -> a -> a <> String -val String -> String -> String +val String -> String -> String forall a. Semigroup a => a -> a -> a <> String ")" diff --git a/src/Transformations.Cc.Cc.html b/src/Transformations.Cc.Cc.html index 3ea5dfc..cc1d424 100644 --- a/src/Transformations.Cc.Cc.html +++ b/src/Transformations.Cc.Cc.html @@ -23,11 +23,11 @@ -- | Convert AST to its closure-free representation. ccAst :: Ast.Program -> Ast.Program ccAst :: Program -> Program -ccAst (Ast.Program [Declaration] -decls IdCnt -cnt) = - let decls' :: [Declaration] -decls' = Reader Env [Declaration] -> Env -> [Declaration] +ccAst (Ast.Program [Declaration] +decls IdCnt +cnt) = + let decls' :: [Declaration] +decls' = Reader Env [Declaration] -> Env -> [Declaration] forall r a. Reader r a -> r -> a runReader ((Declaration -> ReaderT Env Identity Declaration) -> [Declaration] -> Reader Env [Declaration] @@ -37,13 +37,13 @@ forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapM Declaration -> ReaderT Env Identity Declaration ccGDecl [Declaration] -decls) (Set Identifier' -> Map Identifier' Expression -> Env +decls) (Set Identifier' -> Map Identifier' Expression -> Env Env Set Identifier' -gIds Map Identifier' Expression +gIds Map Identifier' Expression forall k a. Map k a Map.empty) - gIds :: Set Identifier' -gIds = [Identifier'] -> Set Identifier' + gIds :: Set Identifier' +gIds = [Identifier'] -> Set Identifier' forall a. Ord a => [a] -> Set a Set.fromList ([Identifier'] -> Set Identifier') -> [Identifier'] -> Set Identifier' @@ -58,11 +58,11 @@ Ast.declId (Declaration -> Identifier') -> [Declaration] -> [Identifier'] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Declaration] -decls) +decls) in [Declaration] -> IdCnt -> Program Ast.Program [Declaration] -decls' IdCnt -cnt +decls' IdCnt +cnt -- * Internal @@ -81,30 +81,30 @@ ccGDecl :: Ast.Declaration -> CcInfo Ast.Declaration ccGDecl :: Declaration -> ReaderT Env Identity Declaration -ccGDecl Declaration -gDecl = case Declaration -gDecl of - Ast.DeclVar Identifier' -ident Expression -val -> (Expression -> Declaration) +ccGDecl Declaration +gDecl = case Declaration +gDecl of + Ast.DeclVar Identifier' +ident Expression +val -> (Expression -> Declaration) -> Expression -> ReaderT Env Identity Declaration forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (Identifier' -> Expression -> Declaration Ast.DeclVar Identifier' -ident) Expression -val - Ast.DeclFun Identifier' -ident IsRec -isRec (Ast.Fun NonEmpty Identifier' -params Expression -body) -> do - Fun -fun <- (Expression -> Fun) -> Expression -> CcInfo Fun +ident) Expression +val + Ast.DeclFun Identifier' +ident IsRec +isRec (Ast.Fun NonEmpty Identifier' +params Expression +body) -> do + Fun +fun <- (Expression -> Fun) -> Expression -> CcInfo Fun forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (NonEmpty Identifier' -> Expression -> Fun Ast.Fun NonEmpty Identifier' -params) Expression -body +params) Expression +body Declaration -> ReaderT Env Identity Declaration forall a. a -> ReaderT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -113,17 +113,17 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> IsRec -> Fun -> Declaration Ast.DeclFun Identifier' -ident IsRec -isRec Fun -fun +ident IsRec +isRec Fun +fun ccExpr :: Ast.Expression -> CcInfo Ast.Expression ccExpr :: Expression -> CcInfo Expression ccExpr = \case - Ast.ExprId Identifier' -ident -> do - Map Identifier' Expression -ms <- (Env -> Map Identifier' Expression) + Ast.ExprId Identifier' +ident -> do + Map Identifier' Expression +ms <- (Env -> Map Identifier' Expression) -> ReaderT Env Identity (Map Identifier' Expression) forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a asks Env -> Map Identifier' Expression @@ -138,13 +138,13 @@ forall a. a -> Maybe a -> a fromMaybe (Identifier' -> Expression Ast.ExprId Identifier' -ident) (Map Identifier' Expression -ms Map Identifier' Expression -> Identifier' -> Maybe Expression +ident) (Map Identifier' Expression +ms Map Identifier' Expression -> Identifier' -> Maybe Expression forall k a. Ord k => Map k a -> k -> Maybe a Map.!? Identifier' -ident) - Ast.ExprPrimVal PrimitiveValue -val -> Expression -> CcInfo Expression +ident) + Ast.ExprPrimVal PrimitiveValue +val -> Expression -> CcInfo Expression forall a. a -> ReaderT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a return (Expression -> CcInfo Expression) @@ -152,110 +152,110 @@ forall a b. (a -> b) -> a -> b $ PrimitiveValue -> Expression Ast.ExprPrimVal PrimitiveValue -val - Ast.ExprBinOp BinaryOperator -op Expression -lhs Expression -rhs -> (Expression -> Expression -> Expression) +val + Ast.ExprBinOp BinaryOperator +op Expression +lhs Expression +rhs -> (Expression -> Expression -> Expression) -> Expression -> Expression -> CcInfo Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> CcInfo a cc2 (BinaryOperator -> Expression -> Expression -> Expression Ast.ExprBinOp BinaryOperator -op) Expression -lhs Expression -rhs - Ast.ExprUnOp UnaryOperator -op Expression -x -> (Expression -> Expression) -> Expression -> CcInfo Expression +op) Expression +lhs Expression +rhs + Ast.ExprUnOp UnaryOperator +op Expression +x -> (Expression -> Expression) -> Expression -> CcInfo Expression forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (UnaryOperator -> Expression -> Expression Ast.ExprUnOp UnaryOperator -op) Expression -x - Ast.ExprApp Expression -f Expression -arg -> (Expression -> Expression -> Expression) +op) Expression +x + Ast.ExprApp Expression +f Expression +arg -> (Expression -> Expression -> Expression) -> Expression -> Expression -> CcInfo Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> CcInfo a cc2 Expression -> Expression -> Expression Ast.ExprApp Expression -f Expression -arg - Ast.ExprIte Expression -c Expression -t Expression -e -> (Expression -> Expression -> Expression -> Expression) +f Expression +arg + Ast.ExprIte Expression +c Expression +t Expression +e -> (Expression -> Expression -> Expression -> Expression) -> Expression -> Expression -> Expression -> CcInfo Expression forall a. (Expression -> Expression -> Expression -> a) -> Expression -> Expression -> Expression -> CcInfo a cc3 Expression -> Expression -> Expression -> Expression Ast.ExprIte Expression -c Expression -t Expression -e - Ast.ExprLetIn Declaration -decl Expression -expr -> case Declaration -decl of - Ast.DeclVar Identifier' -ident Expression -value -> do - Declaration -decl' <- (Expression -> Declaration) +c Expression +t Expression +e + Ast.ExprLetIn Declaration +decl Expression +expr -> case Declaration +decl of + Ast.DeclVar Identifier' +ident Expression +value -> do + Declaration +decl' <- (Expression -> Declaration) -> Expression -> ReaderT Env Identity Declaration forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (Identifier' -> Expression -> Declaration Ast.DeclVar Identifier' -ident) Expression -value +ident) Expression +value (Expression -> Expression) -> Expression -> CcInfo Expression forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (Declaration -> Expression -> Expression Ast.ExprLetIn Declaration -decl') Expression -expr - Ast.DeclFun Identifier' -ident IsRec -isRec (Ast.Fun NonEmpty Identifier' -params Expression -body) -> do - Set Identifier' -gs <- (Env -> Set Identifier') -> ReaderT Env Identity (Set Identifier') +decl') Expression +expr + Ast.DeclFun Identifier' +ident IsRec +isRec (Ast.Fun NonEmpty Identifier' +params Expression +body) -> do + Set Identifier' +gs <- (Env -> Set Identifier') -> ReaderT Env Identity (Set Identifier') forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a asks Env -> Set Identifier' globalIds - let fv :: [Identifier'] -fv = Set Identifier' -> [Identifier'] + let fv :: [Identifier'] +fv = Set Identifier' -> [Identifier'] forall a. Set a -> [a] Set.toList (Set Identifier' -> [Identifier']) -> Set Identifier' -> [Identifier'] forall a b. (a -> b) -> a -> b $ Expression -> Set Identifier' findFv Expression -body Set Identifier' -> Set Identifier' -> Set Identifier' +body Set Identifier' -> Set Identifier' -> Set Identifier' forall a. Ord a => Set a -> Set a -> Set a \\ (NonEmpty Identifier' -> Set Identifier' forall a. Ord a => NonEmpty a -> Set a toSet (Identifier' -ident Identifier' -> NonEmpty Identifier' -> NonEmpty Identifier' +ident Identifier' -> NonEmpty Identifier' -> NonEmpty Identifier' forall a. a -> NonEmpty a -> NonEmpty a <| NonEmpty Identifier' -params) Set Identifier' -> Set Identifier' -> Set Identifier' +params) Set Identifier' -> Set Identifier' -> Set Identifier' forall a. Semigroup a => a -> a -> a <> Set Identifier' -gs) +gs) - let withNewMappings :: ReaderT Env Identity a -> ReaderT Env Identity a -withNewMappings = + let withNewMappings :: ReaderT Env Identity a -> ReaderT Env Identity a +withNewMappings = if [Identifier'] -> IsRec forall (f :: * -> *) a. Foldable f => f a -> IsRec notNull [Identifier'] -fv +fv then (Env -> Env) -> ReaderT Env Identity a -> ReaderT Env Identity a forall a. (Env -> Env) -> ReaderT Env Identity a -> ReaderT Env Identity a @@ -263,103 +263,103 @@ local ((Env -> Env) -> ReaderT Env Identity a -> ReaderT Env Identity a) -> (Env -> Env) -> ReaderT Env Identity a -> ReaderT Env Identity a forall a b. (a -> b) -> a -> b -$ \Env -env -> - let app :: Expression -app = Expression -> [Expression] -> Expression +$ \Env +env -> + let app :: Expression +app = Expression -> [Expression] -> Expression forall (t :: * -> *). Foldable t => Expression -> t Expression -> Expression -apply (Identifier' -> Expression +apply (Identifier' -> Expression Ast.ExprId Identifier' -ident) (Identifier' -> Expression +ident) (Identifier' -> Expression Ast.ExprId (Identifier' -> Expression) -> [Identifier'] -> [Expression] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Identifier'] -fv) - ms :: Map Identifier' Expression -ms = Identifier' +fv) + ms :: Map Identifier' Expression +ms = Identifier' -> Expression -> Map Identifier' Expression -> Map Identifier' Expression forall k a. Ord k => k -> a -> Map k a -> Map k a Map.insert Identifier' -ident Expression -app (Env -> Map Identifier' Expression +ident Expression +app (Env -> Map Identifier' Expression declIdMappings Env -env) +env) in Env -env {declIdMappings :: Map Identifier' Expression +env {declIdMappings :: Map Identifier' Expression declIdMappings = Map Identifier' Expression -ms} +ms} else ReaderT Env Identity a -> ReaderT Env Identity a forall a. a -> a id CcInfo Expression -> CcInfo Expression forall {a}. ReaderT Env Identity a -> ReaderT Env Identity a -withNewMappings (CcInfo Expression -> CcInfo Expression) +withNewMappings (CcInfo Expression -> CcInfo Expression) -> CcInfo Expression -> CcInfo Expression forall a b. (a -> b) -> a -> b $ do - Fun -closedFun <- (Expression -> Fun) -> Expression -> CcInfo Fun + Fun +closedFun <- (Expression -> Fun) -> Expression -> CcInfo Fun forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (NonEmpty Identifier' -> Expression -> Fun Ast.Fun ([Identifier'] -> NonEmpty Identifier' -> NonEmpty Identifier' forall a. [a] -> NonEmpty a -> NonEmpty a prependList [Identifier'] -fv NonEmpty Identifier' -params)) Expression -body - let decl' :: Declaration -decl' = Identifier' -> IsRec -> Fun -> Declaration +fv NonEmpty Identifier' +params)) Expression +body + let decl' :: Declaration +decl' = Identifier' -> IsRec -> Fun -> Declaration Ast.DeclFun Identifier' -ident IsRec -isRec Fun -closedFun +ident IsRec +isRec Fun +closedFun (Expression -> Expression) -> Expression -> CcInfo Expression forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (Declaration -> Expression -> Expression Ast.ExprLetIn Declaration -decl') Expression -expr - Ast.ExprFun (Ast.Fun NonEmpty Identifier' -params Expression -body) -> do - Set Identifier' -gs <- (Env -> Set Identifier') -> ReaderT Env Identity (Set Identifier') +decl') Expression +expr + Ast.ExprFun (Ast.Fun NonEmpty Identifier' +params Expression +body) -> do + Set Identifier' +gs <- (Env -> Set Identifier') -> ReaderT Env Identity (Set Identifier') forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a asks Env -> Set Identifier' globalIds - let fv :: [Identifier'] -fv = Set Identifier' -> [Identifier'] + let fv :: [Identifier'] +fv = Set Identifier' -> [Identifier'] forall a. Set a -> [a] Set.toList (Set Identifier' -> [Identifier']) -> Set Identifier' -> [Identifier'] forall a b. (a -> b) -> a -> b $ Expression -> Set Identifier' findFv Expression -body Set Identifier' -> Set Identifier' -> Set Identifier' +body Set Identifier' -> Set Identifier' -> Set Identifier' forall a. Ord a => Set a -> Set a -> Set a \\ (NonEmpty Identifier' -> Set Identifier' forall a. Ord a => NonEmpty a -> Set a toSet NonEmpty Identifier' -params Set Identifier' -> Set Identifier' -> Set Identifier' +params Set Identifier' -> Set Identifier' -> Set Identifier' forall a. Semigroup a => a -> a -> a <> Set Identifier' -gs) +gs) - Fun -closedFun <- (Expression -> Fun) -> Expression -> CcInfo Fun + Fun +closedFun <- (Expression -> Fun) -> Expression -> CcInfo Fun forall a. (Expression -> a) -> Expression -> CcInfo a cc1 (NonEmpty Identifier' -> Expression -> Fun Ast.Fun ([Identifier'] -> NonEmpty Identifier' -> NonEmpty Identifier' forall a. [a] -> NonEmpty a -> NonEmpty a prependList [Identifier'] -fv NonEmpty Identifier' -params)) Expression -body +fv NonEmpty Identifier' +params)) Expression +body Expression -> CcInfo Expression forall a. a -> ReaderT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -370,19 +370,19 @@ forall (t :: * -> *). Foldable t => Expression -> t Expression -> Expression -apply (Fun -> Expression +apply (Fun -> Expression Ast.ExprFun Fun -closedFun) (Identifier' -> Expression +closedFun) (Identifier' -> Expression Ast.ExprId (Identifier' -> Expression) -> [Identifier'] -> [Expression] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Identifier'] -fv) +fv) where - apply :: (Foldable t) => Ast.Expression -> t Ast.Expression -> Ast.Expression - apply :: forall (t :: * -> *). + apply :: (Foldable t) => Ast.Expression -> t Ast.Expression -> Ast.Expression + apply :: forall (t :: * -> *). Foldable t => Expression -> t Expression -> Expression -apply = (Expression -> Expression -> Expression) +apply = (Expression -> Expression -> Expression) -> Expression -> t Expression -> Expression forall b a. (b -> a -> b) -> b -> t a -> b forall (t :: * -> *) b a. @@ -394,116 +394,116 @@ findFv :: Ast.Expression -> Set Ast.Identifier' findFv :: Expression -> Set Identifier' findFv = \case - Ast.ExprId Identifier' -ident -> Identifier' -> Set Identifier' + Ast.ExprId Identifier' +ident -> Identifier' -> Set Identifier' forall a. a -> Set a Set.singleton Identifier' -ident +ident Ast.ExprPrimVal PrimitiveValue _ -> Set Identifier' forall a. Set a Set.empty Ast.ExprBinOp BinaryOperator -_ Expression -lhs Expression -rhs -> [Expression] -> Set Identifier' -findFv' [Expression -lhs, Expression -rhs] +_ Expression +lhs Expression +rhs -> [Expression] -> Set Identifier' +findFv' [Expression +lhs, Expression +rhs] Ast.ExprUnOp UnaryOperator -_ Expression -x -> Expression -> Set Identifier' +_ Expression +x -> Expression -> Set Identifier' findFv Expression -x - Ast.ExprApp Expression -f Expression -arg -> [Expression] -> Set Identifier' -findFv' [Expression -f, Expression -arg] - Ast.ExprIte Expression -c Expression -t Expression -e -> [Expression] -> Set Identifier' -findFv' [Expression -c, Expression -t, Expression -e] - Ast.ExprLetIn Declaration -decl Expression -expr -> case Declaration -decl of - Ast.DeclVar Identifier' -ident Expression -value -> - let fv :: Set Identifier' -fv = [Expression] -> Set Identifier' -findFv' [Expression -value, Expression -expr] +x + Ast.ExprApp Expression +f Expression +arg -> [Expression] -> Set Identifier' +findFv' [Expression +f, Expression +arg] + Ast.ExprIte Expression +c Expression +t Expression +e -> [Expression] -> Set Identifier' +findFv' [Expression +c, Expression +t, Expression +e] + Ast.ExprLetIn Declaration +decl Expression +expr -> case Declaration +decl of + Ast.DeclVar Identifier' +ident Expression +value -> + let fv :: Set Identifier' +fv = [Expression] -> Set Identifier' +findFv' [Expression +value, Expression +expr] in Identifier' -> Set Identifier' -> Set Identifier' forall a. Ord a => a -> Set a -> Set a Set.delete Identifier' -ident Set Identifier' -fv - Ast.DeclFun Identifier' -ident IsRec -_ (Ast.Fun NonEmpty Identifier' -params Expression -body) -> - let fv :: Set Identifier' -fv = [Expression] -> Set Identifier' -findFv' [Expression -body, Expression -expr] +ident Set Identifier' +fv + Ast.DeclFun Identifier' +ident IsRec +_ (Ast.Fun NonEmpty Identifier' +params Expression +body) -> + let fv :: Set Identifier' +fv = [Expression] -> Set Identifier' +findFv' [Expression +body, Expression +expr] in Set Identifier' -fv Set Identifier' -> Set Identifier' -> Set Identifier' +fv Set Identifier' -> Set Identifier' -> Set Identifier' forall a. Ord a => Set a -> Set a -> Set a \\ NonEmpty Identifier' -> Set Identifier' forall a. Ord a => NonEmpty a -> Set a toSet (Identifier' -ident Identifier' -> NonEmpty Identifier' -> NonEmpty Identifier' +ident Identifier' -> NonEmpty Identifier' -> NonEmpty Identifier' forall a. a -> NonEmpty a -> NonEmpty a <| NonEmpty Identifier' -params) - Ast.ExprFun (Ast.Fun NonEmpty Identifier' -params Expression -body) -> Expression -> Set Identifier' +params) + Ast.ExprFun (Ast.Fun NonEmpty Identifier' +params Expression +body) -> Expression -> Set Identifier' findFv Expression -body Set Identifier' -> Set Identifier' -> Set Identifier' +body Set Identifier' -> Set Identifier' -> Set Identifier' forall a. Ord a => Set a -> Set a -> Set a \\ NonEmpty Identifier' -> Set Identifier' forall a. Ord a => NonEmpty a -> Set a toSet NonEmpty Identifier' -params +params where - findFv' :: [Ast.Expression] -> Set Ast.Identifier' - findFv' :: [Expression] -> Set Identifier' -findFv' = (Base [Expression] (Set Identifier') -> Set Identifier') + findFv' :: [Ast.Expression] -> Set Ast.Identifier' + findFv' :: [Expression] -> Set Identifier' +findFv' = (Base [Expression] (Set Identifier') -> Set Identifier') -> [Expression] -> Set Identifier' forall t a. Recursive t => (Base t a -> a) -> t -> a forall a. (Base [Expression] a -> a) -> [Expression] -> a cata ListF Expression (Set Identifier') -> Set Identifier' Base [Expression] (Set Identifier') -> Set Identifier' -merger +merger where - merger :: ListF Expression (Set Identifier') -> Set Identifier' -merger (Cons Expression -x Set Identifier' -accum) = Set Identifier' -accum Set Identifier' -> Set Identifier' -> Set Identifier' + merger :: ListF Expression (Set Identifier') -> Set Identifier' +merger (Cons Expression +x Set Identifier' +accum) = Set Identifier' +accum Set Identifier' -> Set Identifier' -> Set Identifier' forall a. Semigroup a => a -> a -> a <> Expression -> Set Identifier' findFv Expression -x - merger ListF Expression (Set Identifier') +x + merger ListF Expression (Set Identifier') Nil = Set Identifier' forall a. Set a Set.empty -- ** Collection Utils -toSet :: (Ord a) => NonEmpty a -> Set a +toSet :: (Ord a) => NonEmpty a -> Set a toSet :: forall a. Ord a => NonEmpty a -> Set a toSet = [a] -> Set a forall a. Ord a => [a] -> Set a @@ -513,26 +513,26 @@ forall a. NonEmpty a -> [a] NE.toList -prependList :: [a] -> NonEmpty a -> NonEmpty a +prependList :: [a] -> NonEmpty a -> NonEmpty a prependList :: forall a. [a] -> NonEmpty a -> NonEmpty a -prependList [] NonEmpty a -ne = NonEmpty a -ne -prependList [a] -l NonEmpty a -ne = [a] -> NonEmpty a +prependList [] NonEmpty a +ne = NonEmpty a +ne +prependList [a] +l NonEmpty a +ne = [a] -> NonEmpty a forall a. HasCallStack => [a] -> NonEmpty a NE.fromList [a] -l NonEmpty a -> NonEmpty a -> NonEmpty a +l NonEmpty a -> NonEmpty a -> NonEmpty a forall a. Semigroup a => a -> a -> a <> NonEmpty a -ne +ne -- ** Utils -cc1 :: - (Ast.Expression -> a) -> - (Ast.Expression -> CcInfo a) +cc1 :: + (Ast.Expression -> a) -> + (Ast.Expression -> CcInfo a) cc1 :: forall a. (Expression -> a) -> Expression -> CcInfo a cc1 = (Expression -> CcInfo Expression) -> (Expression -> a) -> Expression -> ReaderT Env Identity a @@ -542,9 +542,9 @@ liftM1' Expression -> CcInfo Expression ccExpr -cc2 :: - (Ast.Expression -> Ast.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> CcInfo a) +cc2 :: + (Ast.Expression -> Ast.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> CcInfo a) cc2 :: forall a. (Expression -> Expression -> a) -> Expression -> Expression -> CcInfo a @@ -559,9 +559,9 @@ liftM2' Expression -> CcInfo Expression ccExpr -cc3 :: - (Ast.Expression -> Ast.Expression -> Ast.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> Ast.Expression -> CcInfo a) +cc3 :: + (Ast.Expression -> Ast.Expression -> Ast.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> Ast.Expression -> CcInfo a) cc3 :: forall a. (Expression -> Expression -> Expression -> a) -> Expression -> Expression -> Expression -> CcInfo a diff --git a/src/Transformations.Ll.Lfr.html b/src/Transformations.Ll.Lfr.html index a189ecf..b7f493f 100644 --- a/src/Transformations.Ll.Lfr.html +++ b/src/Transformations.Ll.Lfr.html @@ -6,7 +6,7 @@ import Trees.Common data Program = Program [GlobalDeclaration] IdCnt - deriving (Int -> Program -> ShowS + deriving (Int -> Program -> ShowS [Program] -> ShowS Program -> String (Int -> Program -> ShowS) @@ -19,7 +19,7 @@ show :: Program -> String $cshowList :: [Program] -> ShowS showList :: [Program] -> ShowS -Show, Program -> Program -> Bool +Show, Program -> Program -> Bool (Program -> Program -> Bool) -> (Program -> Program -> Bool) -> Eq Program forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -32,7 +32,7 @@ data GlobalDeclaration = GlobVarDecl VarDeclaration | GlobFunDecl Identifier' [Identifier'] Expression - deriving (Int -> GlobalDeclaration -> ShowS + deriving (Int -> GlobalDeclaration -> ShowS [GlobalDeclaration] -> ShowS GlobalDeclaration -> String (Int -> GlobalDeclaration -> ShowS) @@ -47,7 +47,7 @@ show :: GlobalDeclaration -> String $cshowList :: [GlobalDeclaration] -> ShowS showList :: [GlobalDeclaration] -> ShowS -Show, GlobalDeclaration -> GlobalDeclaration -> Bool +Show, GlobalDeclaration -> GlobalDeclaration -> Bool (GlobalDeclaration -> GlobalDeclaration -> Bool) -> (GlobalDeclaration -> GlobalDeclaration -> Bool) -> Eq GlobalDeclaration @@ -59,7 +59,7 @@ Eq) data VarDeclaration = VarDecl Identifier' Expression - deriving (Int -> VarDeclaration -> ShowS + deriving (Int -> VarDeclaration -> ShowS [VarDeclaration] -> ShowS VarDeclaration -> String (Int -> VarDeclaration -> ShowS) @@ -74,7 +74,7 @@ show :: VarDeclaration -> String $cshowList :: [VarDeclaration] -> ShowS showList :: [VarDeclaration] -> ShowS -Show, VarDeclaration -> VarDeclaration -> Bool +Show, VarDeclaration -> VarDeclaration -> Bool (VarDeclaration -> VarDeclaration -> Bool) -> (VarDeclaration -> VarDeclaration -> Bool) -> Eq VarDeclaration forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -92,7 +92,7 @@ | ExprApp Expression Expression | ExprIte Expression Expression Expression | ExprLetIn VarDeclaration Expression - deriving (Int -> Expression -> ShowS + deriving (Int -> Expression -> ShowS [Expression] -> ShowS Expression -> String (Int -> Expression -> ShowS) @@ -107,7 +107,7 @@ show :: Expression -> String $cshowList :: [Expression] -> ShowS showList :: [Expression] -> ShowS -Show, Expression -> Expression -> Bool +Show, Expression -> Expression -> Bool (Expression -> Expression -> Bool) -> (Expression -> Expression -> Bool) -> Eq Expression forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a diff --git a/src/Transformations.Ll.Ll.html b/src/Transformations.Ll.Ll.html index 5cbb1d3..e9be177 100644 --- a/src/Transformations.Ll.Ll.html +++ b/src/Transformations.Ll.Ll.html @@ -15,13 +15,13 @@ -- | Convert AST to its lambda-free representation. llAst :: Ast.Program -> Lfr.Program llAst :: Program -> Program -llAst (Ast.Program [Declaration] -gDecls IdCnt -cnt) = - let ([[GlobalDeclaration]] -gDecls', Env [FunDeclaration] -_ IdCnt -cnt') = State Env [[GlobalDeclaration]] +llAst (Ast.Program [Declaration] +gDecls IdCnt +cnt) = + let ([[GlobalDeclaration]] +gDecls', Env [FunDeclaration] +_ IdCnt +cnt') = State Env [[GlobalDeclaration]] -> Env -> ([[GlobalDeclaration]], Env) forall s a. State s a -> s -> (a, s) runState ((Declaration -> StateT Env Identity [GlobalDeclaration]) @@ -32,15 +32,15 @@ forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapM Declaration -> StateT Env Identity [GlobalDeclaration] llGDecl [Declaration] -gDecls) ([FunDeclaration] -> IdCnt -> Env +gDecls) ([FunDeclaration] -> IdCnt -> Env Env [] IdCnt -cnt) +cnt) in [GlobalDeclaration] -> IdCnt -> Program Lfr.Program ([[GlobalDeclaration]] -> [GlobalDeclaration] forall (t :: * -> *) a. Foldable t => t [a] -> [a] concat [[GlobalDeclaration]] -gDecls') IdCnt -cnt' +gDecls') IdCnt +cnt' -- * Internal @@ -62,19 +62,19 @@ llGDecl :: Ast.Declaration -> LlState [Lfr.GlobalDeclaration] llGDecl :: Declaration -> StateT Env Identity [GlobalDeclaration] llGDecl = \case - Ast.DeclVar Identifier' -ident Expression -value -> do - VarDeclaration -var <- (Expression -> VarDeclaration) + Ast.DeclVar Identifier' +ident Expression +value -> do + VarDeclaration +var <- (Expression -> VarDeclaration) -> Expression -> LlState VarDeclaration forall a. (Expression -> a) -> Expression -> LlState a ll1 (Identifier' -> Expression -> VarDeclaration Lfr.VarDecl Identifier' -ident) Expression -value - [FunDeclaration] -genFuns <- (Env -> [FunDeclaration]) -> StateT Env Identity [FunDeclaration] +ident) Expression +value + [FunDeclaration] +genFuns <- (Env -> [FunDeclaration]) -> StateT Env Identity [FunDeclaration] forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets Env -> [FunDeclaration] genFunDecls @@ -83,9 +83,9 @@ modify ((Env -> Env) -> StateT Env Identity ()) -> (Env -> Env) -> StateT Env Identity () forall a b. (a -> b) -> a -> b -$ \Env -env -> Env -env {genFunDecls :: [FunDeclaration] +$ \Env +env -> Env +env {genFunDecls :: [FunDeclaration] genFunDecls = []} [GlobalDeclaration] -> StateT Env Identity [GlobalDeclaration] forall a. a -> StateT Env Identity a @@ -97,32 +97,32 @@ forall a. [a] -> [a] reverse (VarDeclaration -> GlobalDeclaration Lfr.GlobVarDecl VarDeclaration -var GlobalDeclaration -> [GlobalDeclaration] -> [GlobalDeclaration] +var GlobalDeclaration -> [GlobalDeclaration] -> [GlobalDeclaration] forall a. a -> [a] -> [a] : (FunDeclaration -> GlobalDeclaration -convertFunDecl (FunDeclaration -> GlobalDeclaration) +convertFunDecl (FunDeclaration -> GlobalDeclaration) -> [FunDeclaration] -> [GlobalDeclaration] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [FunDeclaration] -genFuns)) - Ast.DeclFun Identifier' -ident IsRec -_ (Ast.Fun NonEmpty Identifier' -params Expression -body) -> do - FunDeclaration -fun <- (Expression -> FunDeclaration) +genFuns)) + Ast.DeclFun Identifier' +ident IsRec +_ (Ast.Fun NonEmpty Identifier' +params Expression +body) -> do + FunDeclaration +fun <- (Expression -> FunDeclaration) -> Expression -> LlState FunDeclaration forall a. (Expression -> a) -> Expression -> LlState a ll1 (Identifier' -> [Identifier'] -> Expression -> FunDeclaration FunDecl Identifier' -ident (NonEmpty Identifier' -> [Identifier'] +ident (NonEmpty Identifier' -> [Identifier'] forall a. NonEmpty a -> [a] NE.toList NonEmpty Identifier' -params)) Expression -body - [FunDeclaration] -genFuns <- (Env -> [FunDeclaration]) -> StateT Env Identity [FunDeclaration] +params)) Expression +body + [FunDeclaration] +genFuns <- (Env -> [FunDeclaration]) -> StateT Env Identity [FunDeclaration] forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets Env -> [FunDeclaration] genFunDecls @@ -131,9 +131,9 @@ modify ((Env -> Env) -> StateT Env Identity ()) -> (Env -> Env) -> StateT Env Identity () forall a b. (a -> b) -> a -> b -$ \Env -env -> Env -env {genFunDecls :: [FunDeclaration] +$ \Env +env -> Env +env {genFunDecls :: [FunDeclaration] genFunDecls = []} [GlobalDeclaration] -> StateT Env Identity [GlobalDeclaration] forall a. a -> StateT Env Identity a @@ -142,32 +142,32 @@ -> [GlobalDeclaration] -> StateT Env Identity [GlobalDeclaration] forall a b. (a -> b) -> a -> b $ FunDeclaration -> GlobalDeclaration -convertFunDecl (FunDeclaration -> GlobalDeclaration) +convertFunDecl (FunDeclaration -> GlobalDeclaration) -> [FunDeclaration] -> [GlobalDeclaration] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [FunDeclaration] -> [FunDeclaration] forall a. [a] -> [a] reverse (FunDeclaration -fun FunDeclaration -> [FunDeclaration] -> [FunDeclaration] +fun FunDeclaration -> [FunDeclaration] -> [FunDeclaration] forall a. a -> [a] -> [a] : [FunDeclaration] -genFuns) +genFuns) where - convertFunDecl :: FunDeclaration -> GlobalDeclaration -convertFunDecl (FunDecl Identifier' -i [Identifier'] -ps Expression -b) = Identifier' -> [Identifier'] -> Expression -> GlobalDeclaration + convertFunDecl :: FunDeclaration -> GlobalDeclaration +convertFunDecl (FunDecl Identifier' +i [Identifier'] +ps Expression +b) = Identifier' -> [Identifier'] -> Expression -> GlobalDeclaration Lfr.GlobFunDecl Identifier' -i [Identifier'] -ps Expression -b +i [Identifier'] +ps Expression +b llExpr :: Ast.Expression -> LlState Lfr.Expression llExpr :: Expression -> LlState Expression llExpr = \case - Ast.ExprId Identifier' -ident -> Expression -> LlState Expression + Ast.ExprId Identifier' +ident -> Expression -> LlState Expression forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a return (Expression -> LlState Expression) @@ -175,9 +175,9 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> Expression Lfr.ExprId Identifier' -ident - Ast.ExprPrimVal PrimitiveValue -val -> Expression -> LlState Expression +ident + Ast.ExprPrimVal PrimitiveValue +val -> Expression -> LlState Expression forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a return (Expression -> LlState Expression) @@ -185,71 +185,71 @@ forall a b. (a -> b) -> a -> b $ PrimitiveValue -> Expression Lfr.ExprPrimVal PrimitiveValue -val - Ast.ExprBinOp BinaryOperator -op Expression -lhs Expression -rhs -> (Expression -> Expression -> Expression) +val + Ast.ExprBinOp BinaryOperator +op Expression +lhs Expression +rhs -> (Expression -> Expression -> Expression) -> Expression -> Expression -> LlState Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> LlState a ll2 (BinaryOperator -> Expression -> Expression -> Expression Lfr.ExprBinOp BinaryOperator -op) Expression -lhs Expression -rhs - Ast.ExprUnOp UnaryOperator -op Expression -x -> (Expression -> Expression) -> Expression -> LlState Expression +op) Expression +lhs Expression +rhs + Ast.ExprUnOp UnaryOperator +op Expression +x -> (Expression -> Expression) -> Expression -> LlState Expression forall a. (Expression -> a) -> Expression -> LlState a ll1 (UnaryOperator -> Expression -> Expression Lfr.ExprUnOp UnaryOperator -op) Expression -x - Ast.ExprApp Expression -f Expression -arg -> (Expression -> Expression -> Expression) +op) Expression +x + Ast.ExprApp Expression +f Expression +arg -> (Expression -> Expression -> Expression) -> Expression -> Expression -> LlState Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> LlState a ll2 Expression -> Expression -> Expression Lfr.ExprApp Expression -f Expression -arg - Ast.ExprIte Expression -c Expression -t Expression -e -> (Expression -> Expression -> Expression -> Expression) +f Expression +arg + Ast.ExprIte Expression +c Expression +t Expression +e -> (Expression -> Expression -> Expression -> Expression) -> Expression -> Expression -> Expression -> LlState Expression forall a. (Expression -> Expression -> Expression -> a) -> Expression -> Expression -> Expression -> LlState a ll3 Expression -> Expression -> Expression -> Expression Lfr.ExprIte Expression -c Expression -t Expression -e - Ast.ExprLetIn Declaration -decl Expression -expr -> case Declaration -decl of - Ast.DeclVar Identifier' -ident Expression -value -> do - VarDeclaration -varDecl <- (Expression -> VarDeclaration) +c Expression +t Expression +e + Ast.ExprLetIn Declaration +decl Expression +expr -> case Declaration +decl of + Ast.DeclVar Identifier' +ident Expression +value -> do + VarDeclaration +varDecl <- (Expression -> VarDeclaration) -> Expression -> LlState VarDeclaration forall a. (Expression -> a) -> Expression -> LlState a ll1 (Identifier' -> Expression -> VarDeclaration Lfr.VarDecl Identifier' -ident) Expression -value - Expression -expr' <- Expression -> LlState Expression +ident) Expression +value + Expression +expr' <- Expression -> LlState Expression llExpr Expression -expr +expr Expression -> LlState Expression forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -258,31 +258,31 @@ forall a b. (a -> b) -> a -> b $ VarDeclaration -> Expression -> Expression Lfr.ExprLetIn VarDeclaration -varDecl Expression -expr' - Ast.DeclFun Identifier' -ident IsRec -_ Fun -fun -> Identifier' -> Fun -> StateT Env Identity () +varDecl Expression +expr' + Ast.DeclFun Identifier' +ident IsRec +_ Fun +fun -> Identifier' -> Fun -> StateT Env Identity () llFun Identifier' -ident Fun -fun StateT Env Identity () -> LlState Expression -> LlState Expression +ident Fun +fun StateT Env Identity () -> LlState Expression -> LlState Expression forall a b. StateT Env Identity a -> StateT Env Identity b -> StateT Env Identity b forall (m :: * -> *) a b. Monad m => m a -> m b -> m b >> Expression -> LlState Expression llExpr Expression -expr - Ast.ExprFun Fun -fun -> do - Identifier' -ident <- LlState Identifier' +expr + Ast.ExprFun Fun +fun -> do + Identifier' +ident <- LlState Identifier' genId Identifier' -> Fun -> StateT Env Identity () llFun Identifier' -ident Fun -fun +ident Fun +fun Expression -> LlState Expression forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -291,47 +291,47 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> Expression Lfr.ExprId Identifier' -ident +ident llFun :: Common.Identifier' -> Ast.Fun -> LlState () llFun :: Identifier' -> Fun -> StateT Env Identity () -llFun Identifier' -ident (Ast.Fun NonEmpty Identifier' -params Expression -body) = do - FunDeclaration -fun <- (Expression -> FunDeclaration) +llFun Identifier' +ident (Ast.Fun NonEmpty Identifier' +params Expression +body) = do + FunDeclaration +fun <- (Expression -> FunDeclaration) -> Expression -> LlState FunDeclaration forall a. (Expression -> a) -> Expression -> LlState a ll1 (Identifier' -> [Identifier'] -> Expression -> FunDeclaration FunDecl Identifier' -ident (NonEmpty Identifier' -> [Identifier'] +ident (NonEmpty Identifier' -> [Identifier'] forall a. NonEmpty a -> [a] NE.toList NonEmpty Identifier' -params)) Expression -body +params)) Expression +body (Env -> Env) -> StateT Env Identity () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((Env -> Env) -> StateT Env Identity ()) -> (Env -> Env) -> StateT Env Identity () forall a b. (a -> b) -> a -> b -$ \Env -env -> Env -env {genFunDecls :: [FunDeclaration] +$ \Env +env -> Env +env {genFunDecls :: [FunDeclaration] genFunDecls = FunDeclaration -fun FunDeclaration -> [FunDeclaration] -> [FunDeclaration] +fun FunDeclaration -> [FunDeclaration] -> [FunDeclaration] forall a. a -> [a] -> [a] : Env -> [FunDeclaration] genFunDecls Env -env} +env} -- ** Identifier Generation genId :: LlState Common.Identifier' genId :: LlState Identifier' genId = do - IdCnt -cnt <- (Env -> IdCnt) -> StateT Env Identity IdCnt + IdCnt +cnt <- (Env -> IdCnt) -> StateT Env Identity IdCnt forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets Env -> IdCnt idCnt @@ -340,11 +340,11 @@ modify ((Env -> Env) -> StateT Env Identity ()) -> (Env -> Env) -> StateT Env Identity () forall a b. (a -> b) -> a -> b -$ \Env -env -> Env -env {idCnt :: IdCnt +$ \Env +env -> Env +env {idCnt :: IdCnt idCnt = IdCnt -cnt IdCnt -> IdCnt -> IdCnt +cnt IdCnt -> IdCnt -> IdCnt forall a. Num a => a -> a -> a + IdCnt 1} @@ -356,7 +356,7 @@ forall a b. (a -> b) -> a -> b $ IdCnt -> Identifier -> Identifier' Common.Gen IdCnt -cnt (Identifier -> Identifier') -> Identifier -> Identifier' +cnt (Identifier -> Identifier') -> Identifier -> Identifier' forall a b. (a -> b) -> a -> b $ String -> Identifier pack String @@ -364,9 +364,9 @@ -- ** Utils -ll1 :: - (Lfr.Expression -> a) -> - (Ast.Expression -> LlState a) +ll1 :: + (Lfr.Expression -> a) -> + (Ast.Expression -> LlState a) ll1 :: forall a. (Expression -> a) -> Expression -> LlState a ll1 = (Expression -> LlState Expression) -> (Expression -> a) -> Expression -> StateT Env Identity a @@ -376,9 +376,9 @@ liftM1' Expression -> LlState Expression llExpr -ll2 :: - (Lfr.Expression -> Lfr.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> LlState a) +ll2 :: + (Lfr.Expression -> Lfr.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> LlState a) ll2 :: forall a. (Expression -> Expression -> a) -> Expression -> Expression -> LlState a @@ -393,9 +393,9 @@ liftM2' Expression -> LlState Expression llExpr -ll3 :: - (Lfr.Expression -> Lfr.Expression -> Lfr.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> Ast.Expression -> LlState a) +ll3 :: + (Lfr.Expression -> Lfr.Expression -> Lfr.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> Ast.Expression -> LlState a) ll3 :: forall a. (Expression -> Expression -> Expression -> a) -> Expression -> Expression -> Expression -> LlState a diff --git a/src/Transformations.Relabeler.Relabeler.html b/src/Transformations.Relabeler.Relabeler.html index c501cae..07400f6 100644 --- a/src/Transformations.Relabeler.Relabeler.html +++ b/src/Transformations.Relabeler.Relabeler.html @@ -17,13 +17,13 @@ -- It helps to avoid naming errors in the future. relabelAst :: Ast.Program -> Ast.Program relabelAst :: Program -> Program -relabelAst (Ast.Program [Declaration] -decls IdCnt -cnt) = - let ([Declaration] -decls', Env [IdMapping] -_ IdCnt -cnt') = State Env [Declaration] -> Env -> ([Declaration], Env) +relabelAst (Ast.Program [Declaration] +decls IdCnt +cnt) = + let ([Declaration] +decls', Env [IdMapping] +_ IdCnt +cnt') = State Env [Declaration] -> Env -> ([Declaration], Env) forall s a. State s a -> s -> (a, s) runState ((Declaration -> StateT Env Identity Declaration) -> [Declaration] -> State Env [Declaration] @@ -33,13 +33,13 @@ forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapM Declaration -> StateT Env Identity Declaration relabelDecl [Declaration] -decls) ([IdMapping] -> IdCnt -> Env +decls) ([IdMapping] -> IdCnt -> Env Env [] IdCnt -cnt) +cnt) in [Declaration] -> IdCnt -> Program Ast.Program [Declaration] -decls' IdCnt -cnt' +decls' IdCnt +cnt' -- * Internal @@ -61,17 +61,17 @@ relabelDecl :: Ast.Declaration -> RelabelerState Ast.Declaration relabelDecl :: Declaration -> StateT Env Identity Declaration relabelDecl = \case - Ast.DeclVar Identifier' -ident Expression -value -> do - Expression -value' <- Expression -> RelabelerState Expression + Ast.DeclVar Identifier' +ident Expression +value -> do + Expression +value' <- Expression -> RelabelerState Expression relabelExpr Expression -value - Identifier' -ident' <- Identifier' -> RelabelerState Identifier' +value + Identifier' +ident' <- Identifier' -> RelabelerState Identifier' pushAndMapId Identifier' -ident +ident Declaration -> StateT Env Identity Declaration forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -80,24 +80,24 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> Expression -> Declaration Ast.DeclVar Identifier' -ident' Expression -value' - Ast.DeclFun Identifier' -ident IsRec -isRec Fun -fun -> do - (Identifier' -ident', Fun -fun') <- +ident' Expression +value' + Ast.DeclFun Identifier' +ident IsRec +isRec Fun +fun -> do + (Identifier' +ident', Fun +fun') <- if IsRec -isRec +isRec then (,) (Identifier' -> Fun -> (Identifier', Fun)) -> RelabelerState Identifier' -> StateT Env Identity (Fun -> (Identifier', Fun)) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Identifier' -> RelabelerState Identifier' pushAndMapId Identifier' -ident StateT Env Identity (Fun -> (Identifier', Fun)) +ident StateT Env Identity (Fun -> (Identifier', Fun)) -> StateT Env Identity Fun -> StateT Env Identity (Identifier', Fun) forall a b. @@ -106,7 +106,7 @@ forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Fun -> StateT Env Identity Fun relabelFun Fun -fun +fun else (Identifier' -> Fun -> (Identifier', Fun)) -> Fun -> Identifier' -> (Identifier', Fun) forall a b c. (a -> b -> c) -> b -> a -> c @@ -116,7 +116,7 @@ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Fun -> StateT Env Identity Fun relabelFun Fun -fun StateT Env Identity (Identifier' -> (Identifier', Fun)) +fun StateT Env Identity (Identifier' -> (Identifier', Fun)) -> RelabelerState Identifier' -> StateT Env Identity (Identifier', Fun) forall a b. @@ -125,7 +125,7 @@ forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Identifier' -> RelabelerState Identifier' pushAndMapId Identifier' -ident +ident Declaration -> StateT Env Identity Declaration forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a @@ -134,23 +134,23 @@ forall a b. (a -> b) -> a -> b $ Identifier' -> IsRec -> Fun -> Declaration Ast.DeclFun Identifier' -ident' IsRec -isRec Fun -fun' +ident' IsRec +isRec Fun +fun' relabelExpr :: Ast.Expression -> RelabelerState Ast.Expression relabelExpr :: Expression -> RelabelerState Expression relabelExpr = \case - Ast.ExprId Identifier' -ident -> Identifier' -> Expression + Ast.ExprId Identifier' +ident -> Identifier' -> Expression Ast.ExprId (Identifier' -> Expression) -> RelabelerState Identifier' -> RelabelerState Expression forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Identifier' -> RelabelerState Identifier' mapId Identifier' -ident - Ast.ExprPrimVal PrimitiveValue -val -> Expression -> RelabelerState Expression +ident + Ast.ExprPrimVal PrimitiveValue +val -> Expression -> RelabelerState Expression forall a. a -> StateT Env Identity a forall (m :: * -> *) a. Monad m => a -> m a return (Expression -> RelabelerState Expression) @@ -158,44 +158,44 @@ forall a b. (a -> b) -> a -> b $ PrimitiveValue -> Expression Ast.ExprPrimVal PrimitiveValue -val - Ast.ExprBinOp BinaryOperator -op Expression -lhs Expression -rhs -> (Expression -> Expression -> Expression) +val + Ast.ExprBinOp BinaryOperator +op Expression +lhs Expression +rhs -> (Expression -> Expression -> Expression) -> Expression -> Expression -> RelabelerState Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> RelabelerState a relabel2 (BinaryOperator -> Expression -> Expression -> Expression Ast.ExprBinOp BinaryOperator -op) Expression -lhs Expression -rhs - Ast.ExprUnOp UnaryOperator -op Expression -x -> (Expression -> Expression) +op) Expression +lhs Expression +rhs + Ast.ExprUnOp UnaryOperator +op Expression +x -> (Expression -> Expression) -> Expression -> RelabelerState Expression forall a. (Expression -> a) -> Expression -> RelabelerState a relabel1 (UnaryOperator -> Expression -> Expression Ast.ExprUnOp UnaryOperator -op) Expression -x - Ast.ExprApp Expression -f Expression -args -> (Expression -> Expression -> Expression) +op) Expression +x + Ast.ExprApp Expression +f Expression +args -> (Expression -> Expression -> Expression) -> Expression -> Expression -> RelabelerState Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> RelabelerState a relabel2 Expression -> Expression -> Expression Ast.ExprApp Expression -f Expression -args - Ast.ExprIte Expression -c Expression -t Expression -e -> (Expression -> Expression -> Expression -> Expression) +f Expression +args + Ast.ExprIte Expression +c Expression +t Expression +e -> (Expression -> Expression -> Expression -> Expression) -> Expression -> Expression -> Expression @@ -205,20 +205,20 @@ -> Expression -> Expression -> Expression -> RelabelerState a relabel3 Expression -> Expression -> Expression -> Expression Ast.ExprIte Expression -c Expression -t Expression -e - Ast.ExprLetIn Declaration -decl Expression -expr -> do - Declaration -decl' <- Declaration -> StateT Env Identity Declaration +c Expression +t Expression +e + Ast.ExprLetIn Declaration +decl Expression +expr -> do + Declaration +decl' <- Declaration -> StateT Env Identity Declaration relabelDecl Declaration -decl - Expression -expr' <- Expression -> RelabelerState Expression +decl + Expression +expr' <- Expression -> RelabelerState Expression relabelExpr Expression -expr +expr RelabelerState () popId Expression -> RelabelerState Expression @@ -229,24 +229,24 @@ forall a b. (a -> b) -> a -> b $ Declaration -> Expression -> Expression Ast.ExprLetIn Declaration -decl' Expression -expr' - Ast.ExprFun Fun -fun -> Fun -> Expression +decl' Expression +expr' + Ast.ExprFun Fun +fun -> Fun -> Expression Ast.ExprFun (Fun -> Expression) -> StateT Env Identity Fun -> RelabelerState Expression forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Fun -> StateT Env Identity Fun relabelFun Fun -fun +fun relabelFun :: Ast.Fun -> RelabelerState Ast.Fun relabelFun :: Fun -> StateT Env Identity Fun -relabelFun (Ast.Fun NonEmpty Identifier' -params Expression -body) = do - NonEmpty Identifier' -params' <- (Identifier' -> RelabelerState Identifier') +relabelFun (Ast.Fun NonEmpty Identifier' +params Expression +body) = do + NonEmpty Identifier' +params' <- (Identifier' -> RelabelerState Identifier') -> NonEmpty Identifier' -> StateT Env Identity (NonEmpty Identifier') forall (t :: * -> *) (m :: * -> *) a b. @@ -257,17 +257,17 @@ (a -> m b) -> NonEmpty a -> m (NonEmpty b) mapM Identifier' -> RelabelerState Identifier' pushAndMapId NonEmpty Identifier' -params - Expression -body' <- Expression -> RelabelerState Expression +params + Expression +body' <- Expression -> RelabelerState Expression relabelExpr Expression -body +body IdCnt -> RelabelerState () -> RelabelerState () forall (m :: * -> *) a. Applicative m => IdCnt -> m a -> m () replicateM_ (NonEmpty Identifier' -> IdCnt forall a. NonEmpty a -> IdCnt NE.length NonEmpty Identifier' -params) RelabelerState () +params) RelabelerState () popId Fun -> StateT Env Identity Fun forall a. a -> StateT Env Identity a @@ -276,17 +276,17 @@ forall a b. (a -> b) -> a -> b $ NonEmpty Identifier' -> Expression -> Fun Ast.Fun NonEmpty Identifier' -params' Expression -body' +params' Expression +body' -- ** Identifier Mappings mapId :: Ast.Identifier' -> RelabelerState Ast.Identifier' mapId :: Identifier' -> RelabelerState Identifier' -mapId Identifier' -ident = do - [IdMapping] -ms <- (Env -> [IdMapping]) -> StateT Env Identity [IdMapping] +mapId Identifier' +ident = do + [IdMapping] +ms <- (Env -> [IdMapping]) -> StateT Env Identity [IdMapping] forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a gets Env -> [IdMapping] idMappings @@ -299,18 +299,18 @@ $ Identifier' -> Maybe Identifier' -> Identifier' forall a. a -> Maybe a -> a fromMaybe Identifier' -ident (Identifier' -> [IdMapping] -> Maybe Identifier' +ident (Identifier' -> [IdMapping] -> Maybe Identifier' forall a b. Eq a => a -> [(a, b)] -> Maybe b lookup Identifier' -ident [IdMapping] -ms) +ident [IdMapping] +ms) pushAndMapId :: Ast.Identifier' -> RelabelerState Ast.Identifier' pushAndMapId :: Identifier' -> RelabelerState Identifier' -pushAndMapId Identifier' -ident = Identifier' -> RelabelerState () +pushAndMapId Identifier' +ident = Identifier' -> RelabelerState () pushId Identifier' -ident RelabelerState () +ident RelabelerState () -> RelabelerState Identifier' -> RelabelerState Identifier' forall a b. StateT Env Identity a @@ -318,46 +318,46 @@ forall (m :: * -> *) a b. Monad m => m a -> m b -> m b >> Identifier' -> RelabelerState Identifier' mapId Identifier' -ident +ident pushId :: Ast.Identifier' -> RelabelerState () pushId :: Identifier' -> RelabelerState () -pushId Identifier' -ident = (Env -> Env) -> RelabelerState () +pushId Identifier' +ident = (Env -> Env) -> RelabelerState () forall s (m :: * -> *). MonadState s m => (s -> s) -> m () modify ((Env -> Env) -> RelabelerState ()) -> (Env -> Env) -> RelabelerState () forall a b. (a -> b) -> a -> b -$ \(Env [IdMapping] -ms IdCnt -cnt) -> +$ \(Env [IdMapping] +ms IdCnt +cnt) -> Env { idMappings :: [IdMapping] idMappings = (Identifier' -ident, IdCnt -> Identifier -> Identifier' +ident, IdCnt -> Identifier -> Identifier' Ast.Gen IdCnt -cnt (Identifier' -> Identifier -getName Identifier' -ident)) IdMapping -> [IdMapping] -> [IdMapping] +cnt (Identifier' -> Identifier +getName Identifier' +ident)) IdMapping -> [IdMapping] -> [IdMapping] forall a. a -> [a] -> [a] : [IdMapping] -ms, +ms, idCnt :: IdCnt idCnt = IdCnt -cnt IdCnt -> IdCnt -> IdCnt +cnt IdCnt -> IdCnt -> IdCnt forall a. Num a => a -> a -> a + IdCnt 1 } where - getName :: Identifier' -> Identifier -getName (Ast.Gen IdCnt -_ Identifier -name) = Identifier -name - getName (Ast.Txt Identifier -name) = Identifier -name + getName :: Identifier' -> Identifier +getName (Ast.Gen IdCnt +_ Identifier +name) = Identifier +name + getName (Ast.Txt Identifier +name) = Identifier +name popId :: RelabelerState () popId :: RelabelerState () @@ -366,21 +366,21 @@ modify ((Env -> Env) -> RelabelerState ()) -> (Env -> Env) -> RelabelerState () forall a b. (a -> b) -> a -> b -$ \env :: Env -env@(Env [IdMapping] -ms IdCnt +$ \env :: Env +env@(Env [IdMapping] +ms IdCnt _) -> Env -env {idMappings :: [IdMapping] +env {idMappings :: [IdMapping] idMappings = [IdMapping] -> [IdMapping] forall a. HasCallStack => [a] -> [a] tail [IdMapping] -ms} +ms} -- ** Utils -relabel1 :: - (Ast.Expression -> a) -> - (Ast.Expression -> RelabelerState a) +relabel1 :: + (Ast.Expression -> a) -> + (Ast.Expression -> RelabelerState a) relabel1 :: forall a. (Expression -> a) -> Expression -> RelabelerState a relabel1 = (Expression -> RelabelerState Expression) -> (Expression -> a) -> Expression -> StateT Env Identity a @@ -390,9 +390,9 @@ liftM1' Expression -> RelabelerState Expression relabelExpr -relabel2 :: - (Ast.Expression -> Ast.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> RelabelerState a) +relabel2 :: + (Ast.Expression -> Ast.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> RelabelerState a) relabel2 :: forall a. (Expression -> Expression -> a) -> Expression -> Expression -> RelabelerState a @@ -407,9 +407,9 @@ liftM2' Expression -> RelabelerState Expression relabelExpr -relabel3 :: - (Ast.Expression -> Ast.Expression -> Ast.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> Ast.Expression -> RelabelerState a) +relabel3 :: + (Ast.Expression -> Ast.Expression -> Ast.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> Ast.Expression -> RelabelerState a) relabel3 :: forall a. (Expression -> Expression -> Expression -> a) -> Expression -> Expression -> Expression -> RelabelerState a diff --git a/src/Transformations.Simplifier.SimplifiedAst.html b/src/Transformations.Simplifier.SimplifiedAst.html index 3e5b6f0..d64fbe2 100644 --- a/src/Transformations.Simplifier.SimplifiedAst.html +++ b/src/Transformations.Simplifier.SimplifiedAst.html @@ -4,7 +4,7 @@ import Trees.Common data Program = Program [Declaration] IdCnt - deriving (Int -> Program -> ShowS + deriving (Int -> Program -> ShowS [Program] -> ShowS Program -> String (Int -> Program -> ShowS) @@ -17,7 +17,7 @@ show :: Program -> String $cshowList :: [Program] -> ShowS showList :: [Program] -> ShowS -Show, Program -> Program -> Bool +Show, Program -> Program -> Bool (Program -> Program -> Bool) -> (Program -> Program -> Bool) -> Eq Program forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -30,7 +30,7 @@ data Declaration = DeclVar Identifier' Expression | DeclFun Identifier' IsRec Fun - deriving (Int -> Declaration -> ShowS + deriving (Int -> Declaration -> ShowS [Declaration] -> ShowS Declaration -> String (Int -> Declaration -> ShowS) @@ -45,7 +45,7 @@ show :: Declaration -> String $cshowList :: [Declaration] -> ShowS showList :: [Declaration] -> ShowS -Show, Declaration -> Declaration -> Bool +Show, Declaration -> Declaration -> Bool (Declaration -> Declaration -> Bool) -> (Declaration -> Declaration -> Bool) -> Eq Declaration forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -57,15 +57,15 @@ declId :: Declaration -> Identifier' declId :: Declaration -> Identifier' -declId (DeclVar Identifier' -ident Expression +declId (DeclVar Identifier' +ident Expression _) = Identifier' -ident -declId (DeclFun Identifier' -ident Bool +ident +declId (DeclFun Identifier' +ident Bool _ Fun _) = Identifier' -ident +ident data Expression = ExprId Identifier' @@ -76,7 +76,7 @@ | ExprIte Expression Expression Expression | ExprLetIn Declaration Expression | ExprFun Fun - deriving (Int -> Expression -> ShowS + deriving (Int -> Expression -> ShowS [Expression] -> ShowS Expression -> String (Int -> Expression -> ShowS) @@ -91,7 +91,7 @@ show :: Expression -> String $cshowList :: [Expression] -> ShowS showList :: [Expression] -> ShowS -Show, Expression -> Expression -> Bool +Show, Expression -> Expression -> Bool (Expression -> Expression -> Bool) -> (Expression -> Expression -> Bool) -> Eq Expression forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a @@ -102,7 +102,7 @@ Eq) data Fun = Fun (NonEmpty Identifier') Expression - deriving (Int -> Fun -> ShowS + deriving (Int -> Fun -> ShowS [Fun] -> ShowS Fun -> String (Int -> Fun -> ShowS) @@ -115,7 +115,7 @@ show :: Fun -> String $cshowList :: [Fun] -> ShowS showList :: [Fun] -> ShowS -Show, Fun -> Fun -> Bool +Show, Fun -> Fun -> Bool (Fun -> Fun -> Bool) -> (Fun -> Fun -> Bool) -> Eq Fun forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Fun -> Fun -> Bool diff --git a/src/Transformations.Simplifier.Simplifier.html b/src/Transformations.Simplifier.Simplifier.html index 547cdd1..c897e59 100644 --- a/src/Transformations.Simplifier.Simplifier.html +++ b/src/Transformations.Simplifier.Simplifier.html @@ -13,11 +13,11 @@ simplifyAst :: Ast.Program -> SAst.Program simplifyAst :: Program -> Program -simplifyAst (Ast.Program [Statement] -stmts) = - let ([Declaration] -decls, IdCnt -cnt) = State IdCnt [Declaration] -> IdCnt -> ([Declaration], IdCnt) +simplifyAst (Ast.Program [Statement] +stmts) = + let ([Declaration] +decls, IdCnt +cnt) = State IdCnt [Declaration] -> IdCnt -> ([Declaration], IdCnt) forall s a. State s a -> s -> (a, s) runState ((Statement -> StateT IdCnt Identity Declaration) -> [Statement] -> State IdCnt [Declaration] @@ -27,12 +27,12 @@ forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b] mapM Statement -> StateT IdCnt Identity Declaration simplifyStmt [Statement] -stmts) IdCnt +stmts) IdCnt 0 in [Declaration] -> IdCnt -> Program SAst.Program [Declaration] -decls IdCnt -cnt +decls IdCnt +cnt -- * Internal @@ -45,12 +45,12 @@ simplifyStmt :: Ast.Statement -> SimplifierState SAst.Declaration simplifyStmt :: Statement -> StateT IdCnt Identity Declaration simplifyStmt = \case - Ast.StmtDecl Declaration -decl -> Declaration -> StateT IdCnt Identity Declaration + Ast.StmtDecl Declaration +decl -> Declaration -> StateT IdCnt Identity Declaration simplifyDecl Declaration -decl - Ast.StmtExpr Expression -expr -> Identifier' -> Expression -> Declaration +decl + Ast.StmtExpr Expression +expr -> Identifier' -> Expression -> Declaration SAst.DeclVar (Identifier' -> Expression -> Declaration) -> StateT IdCnt Identity Identifier' -> StateT IdCnt Identity (Expression -> Declaration) @@ -65,40 +65,40 @@ forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Expression -> StateT IdCnt Identity Expression simplifyExpr Expression -expr +expr simplifyDecl :: Ast.Declaration -> SimplifierState SAst.Declaration simplifyDecl :: Declaration -> StateT IdCnt Identity Declaration simplifyDecl = \case - Ast.DeclVar (Identifier, Maybe Type) -ident Expression -value -> (Expression -> Declaration) + Ast.DeclVar (Identifier, Maybe Type) +ident Expression +value -> (Expression -> Declaration) -> Expression -> StateT IdCnt Identity Declaration forall a. (Expression -> a) -> Expression -> SimplifierState a simplify1 (Identifier' -> Expression -> Declaration SAst.DeclVar ((Identifier, Maybe Type) -> Identifier' convertTypedId (Identifier, Maybe Type) -ident)) Expression -value - Ast.DeclFun Identifier -ident IsRec -isRec Fun -fun -> Identifier' -> IsRec -> Fun -> Declaration +ident)) Expression +value + Ast.DeclFun Identifier +ident IsRec +isRec Fun +fun -> Identifier' -> IsRec -> Fun -> Declaration SAst.DeclFun (Identifier -> Identifier' convertId Identifier -ident) IsRec -isRec (Fun -> Declaration) +ident) IsRec +isRec (Fun -> Declaration) -> StateT IdCnt Identity Fun -> StateT IdCnt Identity Declaration forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Fun -> StateT IdCnt Identity Fun simplifyFun Fun -fun +fun simplifyExpr :: Ast.Expression -> SimplifierState SAst.Expression simplifyExpr :: Expression -> StateT IdCnt Identity Expression simplifyExpr = \case - Ast.ExprId Identifier -ident -> Expression -> StateT IdCnt Identity Expression + Ast.ExprId Identifier +ident -> Expression -> StateT IdCnt Identity Expression forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a return (Expression -> StateT IdCnt Identity Expression) @@ -107,9 +107,9 @@ $ Identifier' -> Expression SAst.ExprId (Identifier -> Identifier' convertId Identifier -ident) - Ast.ExprPrimVal PrimitiveValue -val -> Expression -> StateT IdCnt Identity Expression +ident) + Ast.ExprPrimVal PrimitiveValue +val -> Expression -> StateT IdCnt Identity Expression forall a. a -> StateT IdCnt Identity a forall (m :: * -> *) a. Monad m => a -> m a return (Expression -> StateT IdCnt Identity Expression) @@ -117,44 +117,44 @@ forall a b. (a -> b) -> a -> b $ PrimitiveValue -> Expression SAst.ExprPrimVal PrimitiveValue -val - Ast.ExprBinOp BinaryOperator -op Expression -lhs Expression -rhs -> (Expression -> Expression -> Expression) +val + Ast.ExprBinOp BinaryOperator +op Expression +lhs Expression +rhs -> (Expression -> Expression -> Expression) -> Expression -> Expression -> StateT IdCnt Identity Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> SimplifierState a simplify2 (BinaryOperator -> Expression -> Expression -> Expression SAst.ExprBinOp BinaryOperator -op) Expression -lhs Expression -rhs - Ast.ExprUnOp UnaryOperator -op Expression -x -> (Expression -> Expression) +op) Expression +lhs Expression +rhs + Ast.ExprUnOp UnaryOperator +op Expression +x -> (Expression -> Expression) -> Expression -> StateT IdCnt Identity Expression forall a. (Expression -> a) -> Expression -> SimplifierState a simplify1 (UnaryOperator -> Expression -> Expression SAst.ExprUnOp UnaryOperator -op) Expression -x - Ast.ExprApp Expression -f Expression -arg -> (Expression -> Expression -> Expression) +op) Expression +x + Ast.ExprApp Expression +f Expression +arg -> (Expression -> Expression -> Expression) -> Expression -> Expression -> StateT IdCnt Identity Expression forall a. (Expression -> Expression -> a) -> Expression -> Expression -> SimplifierState a simplify2 Expression -> Expression -> Expression SAst.ExprApp Expression -f Expression -arg - Ast.ExprIte Expression -c Expression -t Expression -e -> (Expression -> Expression -> Expression -> Expression) +f Expression +arg + Ast.ExprIte Expression +c Expression +t Expression +e -> (Expression -> Expression -> Expression -> Expression) -> Expression -> Expression -> Expression @@ -164,19 +164,19 @@ -> Expression -> Expression -> Expression -> SimplifierState a simplify3 Expression -> Expression -> Expression -> Expression SAst.ExprIte Expression -c Expression -t Expression -e - Ast.ExprLetIn Declaration -decl Expression -expr -> Declaration -> Expression -> Expression +c Expression +t Expression +e + Ast.ExprLetIn Declaration +decl Expression +expr -> Declaration -> Expression -> Expression SAst.ExprLetIn (Declaration -> Expression -> Expression) -> StateT IdCnt Identity Declaration -> StateT IdCnt Identity (Expression -> Expression) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Declaration -> StateT IdCnt Identity Declaration simplifyDecl Declaration -decl StateT IdCnt Identity (Expression -> Expression) +decl StateT IdCnt Identity (Expression -> Expression) -> StateT IdCnt Identity Expression -> StateT IdCnt Identity Expression forall a b. @@ -185,22 +185,22 @@ forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Expression -> StateT IdCnt Identity Expression simplifyExpr Expression -expr - Ast.ExprFun Fun -fun -> Fun -> Expression +expr + Ast.ExprFun Fun +fun -> Fun -> Expression SAst.ExprFun (Fun -> Expression) -> StateT IdCnt Identity Fun -> StateT IdCnt Identity Expression forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Fun -> StateT IdCnt Identity Fun simplifyFun Fun -fun +fun simplifyFun :: Ast.Fun -> SimplifierState SAst.Fun simplifyFun :: Fun -> StateT IdCnt Identity Fun -simplifyFun (Ast.Fun NonEmpty (Identifier, Maybe Type) -params Maybe Type -_ Expression -body) = (Expression -> Fun) -> Expression -> StateT IdCnt Identity Fun +simplifyFun (Ast.Fun NonEmpty (Identifier, Maybe Type) +params Maybe Type +_ Expression +body) = (Expression -> Fun) -> Expression -> StateT IdCnt Identity Fun forall a. (Expression -> a) -> Expression -> SimplifierState a simplify1 (NonEmpty Identifier' -> Expression -> Fun SAst.Fun ((Identifier, Maybe Type) -> Identifier' @@ -208,8 +208,8 @@ -> NonEmpty (Identifier, Maybe Type) -> NonEmpty Identifier' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> NonEmpty (Identifier, Maybe Type) -params)) Expression -body +params)) Expression +body -- ** Identifier Conversion and Generation @@ -233,8 +233,8 @@ genId :: SimplifierState Common.Identifier' genId :: StateT IdCnt Identity Identifier' genId = do - IdCnt -cnt <- StateT IdCnt Identity IdCnt + IdCnt +cnt <- StateT IdCnt Identity IdCnt forall s (m :: * -> *). MonadState s m => m s get (IdCnt -> IdCnt) -> StateT IdCnt Identity () @@ -251,7 +251,7 @@ forall a b. (a -> b) -> a -> b $ IdCnt -> Identifier -> Identifier' Common.Gen IdCnt -cnt (Identifier -> Identifier') -> Identifier -> Identifier' +cnt (Identifier -> Identifier') -> Identifier -> Identifier' forall a b. (a -> b) -> a -> b $ String -> Identifier pack String @@ -259,9 +259,9 @@ -- ** Utils -simplify1 :: - (SAst.Expression -> a) -> - (Ast.Expression -> SimplifierState a) +simplify1 :: + (SAst.Expression -> a) -> + (Ast.Expression -> SimplifierState a) simplify1 :: forall a. (Expression -> a) -> Expression -> SimplifierState a simplify1 = (Expression -> StateT IdCnt Identity Expression) -> (Expression -> a) -> Expression -> StateT IdCnt Identity a @@ -271,9 +271,9 @@ liftM1' Expression -> StateT IdCnt Identity Expression simplifyExpr -simplify2 :: - (SAst.Expression -> SAst.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> SimplifierState a) +simplify2 :: + (SAst.Expression -> SAst.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> SimplifierState a) simplify2 :: forall a. (Expression -> Expression -> a) -> Expression -> Expression -> SimplifierState a @@ -288,9 +288,9 @@ liftM2' Expression -> StateT IdCnt Identity Expression simplifyExpr -simplify3 :: - (SAst.Expression -> SAst.Expression -> SAst.Expression -> a) -> - (Ast.Expression -> Ast.Expression -> Ast.Expression -> SimplifierState a) +simplify3 :: + (SAst.Expression -> SAst.Expression -> SAst.Expression -> a) -> + (Ast.Expression -> Ast.Expression -> Ast.Expression -> SimplifierState a) simplify3 :: forall a. (Expression -> Expression -> Expression -> a) -> Expression -> Expression -> Expression -> SimplifierState a diff --git a/src/Trees.Common.html b/src/Trees.Common.html index b488caf..3bfaeff 100644 --- a/src/Trees.Common.html +++ b/src/Trees.Common.html @@ -1,4 +1,4 @@ -
module Trees.Common where
+
module Trees.Common where
 
 import Data.Int (Int64)
 import Data.Text (Text)
@@ -12,7 +12,7 @@
 data Identifier'
   = Txt Identifier
   | Gen IdCnt Identifier
-  deriving (Int -> Identifier' -> ShowS
+  deriving (Int -> Identifier' -> ShowS
 [Identifier'] -> ShowS
 Identifier' -> String
 (Int -> Identifier' -> ShowS)
@@ -27,7 +27,7 @@
 show :: Identifier' -> String
 $cshowList :: [Identifier'] -> ShowS
 showList :: [Identifier'] -> ShowS
-Show, Identifier' -> Identifier' -> Bool
+Show, Identifier' -> Identifier' -> Bool
 (Identifier' -> Identifier' -> Bool)
 -> (Identifier' -> Identifier' -> Bool) -> Eq Identifier'
 forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
@@ -35,7 +35,7 @@
 == :: Identifier' -> Identifier' -> Bool
 $c/= :: Identifier' -> Identifier' -> Bool
 /= :: Identifier' -> Identifier' -> Bool
-Eq, Eq Identifier'
+Eq, Eq Identifier'
 Eq Identifier'
 -> (Identifier' -> Identifier' -> Ordering)
 -> (Identifier' -> Identifier' -> Bool)
@@ -86,7 +86,7 @@
     ArithOp ArithmeticOperator
   | -- | Comparison operator, see 'ComparisonOperator'.
     CompOp ComparisonOperator
-  deriving (Int -> BinaryOperator -> ShowS
+  deriving (Int -> BinaryOperator -> ShowS
 [BinaryOperator] -> ShowS
 BinaryOperator -> String
 (Int -> BinaryOperator -> ShowS)
@@ -101,7 +101,7 @@
 show :: BinaryOperator -> String
 $cshowList :: [BinaryOperator] -> ShowS
 showList :: [BinaryOperator] -> ShowS
-Show, BinaryOperator -> BinaryOperator -> Bool
+Show, BinaryOperator -> BinaryOperator -> Bool
 (BinaryOperator -> BinaryOperator -> Bool)
 -> (BinaryOperator -> BinaryOperator -> Bool) -> Eq BinaryOperator
 forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
@@ -115,7 +115,7 @@
 data UnaryOperator
   = -- | Unary minus operator (@-a@), works only for @int@.
     UnMinusOp
-  deriving (Int -> UnaryOperator -> ShowS
+  deriving (Int -> UnaryOperator -> ShowS
 [UnaryOperator] -> ShowS
 UnaryOperator -> String
 (Int -> UnaryOperator -> ShowS)
@@ -130,7 +130,7 @@
 show :: UnaryOperator -> String
 $cshowList :: [UnaryOperator] -> ShowS
 showList :: [UnaryOperator] -> ShowS
-Show, UnaryOperator -> UnaryOperator -> Bool
+Show, UnaryOperator -> UnaryOperator -> Bool
 (UnaryOperator -> UnaryOperator -> Bool)
 -> (UnaryOperator -> UnaryOperator -> Bool) -> Eq UnaryOperator
 forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
@@ -138,7 +138,7 @@
 == :: UnaryOperator -> UnaryOperator -> Bool
 $c/= :: UnaryOperator -> UnaryOperator -> Bool
 /= :: UnaryOperator -> UnaryOperator -> Bool
-Eq, Int -> UnaryOperator
+Eq, Int -> UnaryOperator
 UnaryOperator -> Int
 UnaryOperator -> [UnaryOperator]
 UnaryOperator -> UnaryOperator
@@ -180,7 +180,7 @@
 enumFromTo :: UnaryOperator -> UnaryOperator -> [UnaryOperator]
 $cenumFromThenTo :: UnaryOperator -> UnaryOperator -> UnaryOperator -> [UnaryOperator]
 enumFromThenTo :: UnaryOperator -> UnaryOperator -> UnaryOperator -> [UnaryOperator]
-Enum, UnaryOperator
+Enum, UnaryOperator
 UnaryOperator -> UnaryOperator -> Bounded UnaryOperator
 forall a. a -> a -> Bounded a
 $cminBound :: UnaryOperator
@@ -195,7 +195,7 @@
     AndOp
   | -- | Or operator (@a || b@).
     OrOp
-  deriving (Int -> BooleanOperator -> ShowS
+  deriving (Int -> BooleanOperator -> ShowS
 [BooleanOperator] -> ShowS
 BooleanOperator -> String
 (Int -> BooleanOperator -> ShowS)
@@ -210,7 +210,7 @@
 show :: BooleanOperator -> String
 $cshowList :: [BooleanOperator] -> ShowS
 showList :: [BooleanOperator] -> ShowS
-Show, BooleanOperator -> BooleanOperator -> Bool
+Show, BooleanOperator -> BooleanOperator -> Bool
 (BooleanOperator -> BooleanOperator -> Bool)
 -> (BooleanOperator -> BooleanOperator -> Bool)
 -> Eq BooleanOperator
@@ -219,7 +219,7 @@
 == :: BooleanOperator -> BooleanOperator -> Bool
 $c/= :: BooleanOperator -> BooleanOperator -> Bool
 /= :: BooleanOperator -> BooleanOperator -> Bool
-Eq, Int -> BooleanOperator
+Eq, Int -> BooleanOperator
 BooleanOperator -> Int
 BooleanOperator -> [BooleanOperator]
 BooleanOperator -> BooleanOperator
@@ -264,7 +264,7 @@
 -> BooleanOperator -> BooleanOperator -> [BooleanOperator]
 enumFromThenTo :: BooleanOperator
 -> BooleanOperator -> BooleanOperator -> [BooleanOperator]
-Enum, BooleanOperator
+Enum, BooleanOperator
 BooleanOperator -> BooleanOperator -> Bounded BooleanOperator
 forall a. a -> a -> Bounded a
 $cminBound :: BooleanOperator
@@ -283,7 +283,7 @@
     MulOp
   | -- | Division operator (@a / b@).
     DivOp
-  deriving (Int -> ArithmeticOperator -> ShowS
+  deriving (Int -> ArithmeticOperator -> ShowS
 [ArithmeticOperator] -> ShowS
 ArithmeticOperator -> String
 (Int -> ArithmeticOperator -> ShowS)
@@ -298,7 +298,7 @@
 show :: ArithmeticOperator -> String
 $cshowList :: [ArithmeticOperator] -> ShowS
 showList :: [ArithmeticOperator] -> ShowS
-Show, ArithmeticOperator -> ArithmeticOperator -> Bool
+Show, ArithmeticOperator -> ArithmeticOperator -> Bool
 (ArithmeticOperator -> ArithmeticOperator -> Bool)
 -> (ArithmeticOperator -> ArithmeticOperator -> Bool)
 -> Eq ArithmeticOperator
@@ -307,7 +307,7 @@
 == :: ArithmeticOperator -> ArithmeticOperator -> Bool
 $c/= :: ArithmeticOperator -> ArithmeticOperator -> Bool
 /= :: ArithmeticOperator -> ArithmeticOperator -> Bool
-Eq, Int -> ArithmeticOperator
+Eq, Int -> ArithmeticOperator
 ArithmeticOperator -> Int
 ArithmeticOperator -> [ArithmeticOperator]
 ArithmeticOperator -> ArithmeticOperator
@@ -356,7 +356,7 @@
 -> ArithmeticOperator -> ArithmeticOperator -> [ArithmeticOperator]
 enumFromThenTo :: ArithmeticOperator
 -> ArithmeticOperator -> ArithmeticOperator -> [ArithmeticOperator]
-Enum, ArithmeticOperator
+Enum, ArithmeticOperator
 ArithmeticOperator
 -> ArithmeticOperator -> Bounded ArithmeticOperator
 forall a. a -> a -> Bounded a
@@ -380,7 +380,7 @@
     GtOp
   | -- | Greater than or equal operator (@a >= b@).
     GeOp
-  deriving (Int -> ComparisonOperator -> ShowS
+  deriving (Int -> ComparisonOperator -> ShowS
 [ComparisonOperator] -> ShowS
 ComparisonOperator -> String
 (Int -> ComparisonOperator -> ShowS)
@@ -395,7 +395,7 @@
 show :: ComparisonOperator -> String
 $cshowList :: [ComparisonOperator] -> ShowS
 showList :: [ComparisonOperator] -> ShowS
-Show, ComparisonOperator -> ComparisonOperator -> Bool
+Show, ComparisonOperator -> ComparisonOperator -> Bool
 (ComparisonOperator -> ComparisonOperator -> Bool)
 -> (ComparisonOperator -> ComparisonOperator -> Bool)
 -> Eq ComparisonOperator
@@ -404,7 +404,7 @@
 == :: ComparisonOperator -> ComparisonOperator -> Bool
 $c/= :: ComparisonOperator -> ComparisonOperator -> Bool
 /= :: ComparisonOperator -> ComparisonOperator -> Bool
-Eq, Int -> ComparisonOperator
+Eq, Int -> ComparisonOperator
 ComparisonOperator -> Int
 ComparisonOperator -> [ComparisonOperator]
 ComparisonOperator -> ComparisonOperator
@@ -453,7 +453,7 @@
 -> ComparisonOperator -> ComparisonOperator -> [ComparisonOperator]
 enumFromThenTo :: ComparisonOperator
 -> ComparisonOperator -> ComparisonOperator -> [ComparisonOperator]
-Enum, ComparisonOperator
+Enum, ComparisonOperator
 ComparisonOperator
 -> ComparisonOperator -> Bounded ComparisonOperator
 forall a. a -> a -> Bounded a
@@ -482,7 +482,7 @@
     -- It contains the type of the first parameter and the result of the function
     -- (e.g., @int -> (int -> bool -> bool)@).
     TFun Type Type
-  deriving (Int -> Type -> ShowS
+  deriving (Int -> Type -> ShowS
 [Type] -> ShowS
 Type -> String
 (Int -> Type -> ShowS)
@@ -495,14 +495,14 @@
 show :: Type -> String
 $cshowList :: [Type] -> ShowS
 showList :: [Type] -> ShowS
-Show, Type -> Type -> Bool
+Show, Type -> Type -> Bool
 (Type -> Type -> Bool) -> (Type -> Type -> Bool) -> Eq Type
 forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
 $c== :: Type -> Type -> Bool
 == :: Type -> Type -> Bool
 $c/= :: Type -> Type -> Bool
 /= :: Type -> Type -> Bool
-Eq, Eq Type
+Eq, Eq Type
 Eq Type
 -> (Type -> Type -> Ordering)
 -> (Type -> Type -> Bool)
@@ -554,7 +554,7 @@
     PrimValBool Bool
   | -- | Int value (e.g., @0@, @4@, @15@, @23@).
     PrimValInt Int64
-  deriving (Int -> PrimitiveValue -> ShowS
+  deriving (Int -> PrimitiveValue -> ShowS
 [PrimitiveValue] -> ShowS
 PrimitiveValue -> String
 (Int -> PrimitiveValue -> ShowS)
@@ -569,7 +569,7 @@
 show :: PrimitiveValue -> String
 $cshowList :: [PrimitiveValue] -> ShowS
 showList :: [PrimitiveValue] -> ShowS
-Show, PrimitiveValue -> PrimitiveValue -> Bool
+Show, PrimitiveValue -> PrimitiveValue -> Bool
 (PrimitiveValue -> PrimitiveValue -> Bool)
 -> (PrimitiveValue -> PrimitiveValue -> Bool) -> Eq PrimitiveValue
 forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
diff --git a/src/TypeChecker.HindleyMilner.html b/src/TypeChecker.HindleyMilner.html
index b3ac650..a03d1cf 100644
--- a/src/TypeChecker.HindleyMilner.html
+++ b/src/TypeChecker.HindleyMilner.html
@@ -52,13 +52,13 @@
 
 type Type = Fix TypeF
 
-data TypeF a
+data TypeF a
   = TVarF L.Identifier
   | TUnitF
   | TBoolF
   | TIntF
-  | TFunF a a
-  deriving (Int -> TypeF a -> ShowS
+  | TFunF a a
+  deriving (Int -> TypeF a -> ShowS
 [TypeF a] -> ShowS
 TypeF a -> String
 (Int -> TypeF a -> ShowS)
@@ -74,7 +74,7 @@
 show :: TypeF a -> String
 $cshowList :: forall a. Show a => [TypeF a] -> ShowS
 showList :: [TypeF a] -> ShowS
-Show, TypeF a -> TypeF a -> Bool
+Show, TypeF a -> TypeF a -> Bool
 (TypeF a -> TypeF a -> Bool)
 -> (TypeF a -> TypeF a -> Bool) -> Eq (TypeF a)
 forall a. Eq a => TypeF a -> TypeF a -> Bool
@@ -83,7 +83,7 @@
 == :: TypeF a -> TypeF a -> Bool
 $c/= :: forall a. Eq a => TypeF a -> TypeF a -> Bool
 /= :: TypeF a -> TypeF a -> Bool
-Eq, (forall a b. (a -> b) -> TypeF a -> TypeF b)
+Eq, (forall a b. (a -> b) -> TypeF a -> TypeF b)
 -> (forall a b. a -> TypeF b -> TypeF a) -> Functor TypeF
 forall a b. a -> TypeF b -> TypeF a
 forall a b. (a -> b) -> TypeF a -> TypeF b
@@ -94,7 +94,7 @@
 fmap :: forall a b. (a -> b) -> TypeF a -> TypeF b
 $c<$ :: forall a b. a -> TypeF b -> TypeF a
 <$ :: forall a b. a -> TypeF b -> TypeF a
-Functor, (forall m. Monoid m => TypeF m -> m)
+Functor, (forall m. Monoid m => TypeF m -> m)
 -> (forall m a. Monoid m => (a -> m) -> TypeF a -> m)
 -> (forall m a. Monoid m => (a -> m) -> TypeF a -> m)
 -> (forall a b. (a -> b -> b) -> b -> TypeF a -> b)
@@ -176,7 +176,7 @@
 sum :: forall a. Num a => TypeF a -> a
 $cproduct :: forall a. Num a => TypeF a -> a
 product :: forall a. Num a => TypeF a -> a
-Foldable, Functor TypeF
+Foldable, Functor TypeF
 Foldable TypeF
 Functor TypeF
 -> Foldable TypeF
@@ -227,7 +227,7 @@
 (a -> m b) -> TypeF a -> m (TypeF b)
 $csequence :: forall (m :: * -> *) a. Monad m => TypeF (m a) -> m (TypeF a)
 sequence :: forall (m :: * -> *) a. Monad m => TypeF (m a) -> m (TypeF a)
-Traversable, (forall a. TypeF a -> Rep1 TypeF a)
+Traversable, (forall a. TypeF a -> Rep1 TypeF a)
 -> (forall a. Rep1 TypeF a -> TypeF a) -> Generic1 TypeF
 forall a. Rep1 TypeF a -> TypeF a
 forall a. TypeF a -> Rep1 TypeF a
@@ -238,7 +238,7 @@
 from1 :: forall a. TypeF a -> Rep1 TypeF a
 $cto1 :: forall a. Rep1 TypeF a -> TypeF a
 to1 :: forall a. Rep1 TypeF a -> TypeF a
-Generic1, Traversable TypeF
+Generic1, Traversable TypeF
 Traversable TypeF
 -> (forall a.
     TypeF a -> TypeF a -> Maybe (TypeF (Either a (a, a))))
@@ -259,7 +259,7 @@
 pattern UTVar :: L.Identifier -> UType
 pattern $mUTVar :: forall {r}. UType -> (Identifier -> r) -> ((# #) -> r) -> r
 $bUTVar :: Identifier -> UType
-UTVar var = UTerm (TVarF var)
+UTVar var = UTerm (TVarF var)
 
 pattern UTUnit :: UType
 pattern $mUTUnit :: forall {r}. UType -> ((# #) -> r) -> ((# #) -> r) -> r
@@ -279,12 +279,12 @@
 pattern UTFun :: UType -> UType -> UType
 pattern $mUTFun :: forall {r}. UType -> (UType -> UType -> r) -> ((# #) -> r) -> r
 $bUTFun :: UType -> UType -> UType
-UTFun funT argT = UTerm (TFunF funT argT)
+UTFun funT argT = UTerm (TFunF funT argT)
 
 -- * Polytype
 
-data Poly t = Forall [L.Identifier] t
-  deriving (Poly t -> Poly t -> Bool
+data Poly t = Forall [L.Identifier] t
+  deriving (Poly t -> Poly t -> Bool
 (Poly t -> Poly t -> Bool)
 -> (Poly t -> Poly t -> Bool) -> Eq (Poly t)
 forall t. Eq t => Poly t -> Poly t -> Bool
@@ -293,7 +293,7 @@
 == :: Poly t -> Poly t -> Bool
 $c/= :: forall t. Eq t => Poly t -> Poly t -> Bool
 /= :: Poly t -> Poly t -> Bool
-Eq, Int -> Poly t -> ShowS
+Eq, Int -> Poly t -> ShowS
 [Poly t] -> ShowS
 Poly t -> String
 (Int -> Poly t -> ShowS)
@@ -309,7 +309,7 @@
 show :: Poly t -> String
 $cshowList :: forall t. Show t => [Poly t] -> ShowS
 showList :: [Poly t] -> ShowS
-Show, (forall a b. (a -> b) -> Poly a -> Poly b)
+Show, (forall a b. (a -> b) -> Poly a -> Poly b)
 -> (forall a b. a -> Poly b -> Poly a) -> Functor Poly
 forall a b. a -> Poly b -> Poly a
 forall a b. (a -> b) -> Poly a -> Poly b
@@ -340,14 +340,14 @@
   Type
 L.TInt -> UType
 UTInt
-  L.TFun Type
-funT Type
-argT -> UType -> UType -> UType
+  L.TFun Type
+funT Type
+argT -> UType -> UType -> UType
 UTFun (Type -> UType
 toUType Type
-funT) (Type -> UType
+funT) (Type -> UType
 toUType Type
-argT)
+argT)
 
 toPolytype :: UPolytype -> Polytype
 toPolytype :: UPolytype -> Polytype
@@ -370,10 +370,10 @@
 
 lookup :: L.Identifier -> Infer UType
 lookup :: Identifier -> Infer UType
-lookup Identifier
-var = do
-  Maybe UPolytype
-varUPT <- (Ctx -> Maybe UPolytype)
+lookup Identifier
+var = do
+  Maybe UPolytype
+varUPT <- (Ctx -> Maybe UPolytype)
 -> ReaderT
      Ctx
      (ExceptT TypeError (IntBindingT TypeF Identity))
@@ -393,7 +393,7 @@
 $ Identifier -> Ctx -> Maybe UPolytype
 forall k a. Ord k => k -> Map k a -> Maybe a
 M.lookup Identifier
-var
+var
   Infer UType
 -> (UPolytype -> Infer UType) -> Maybe UPolytype -> Infer UType
 forall b a. b -> (a -> b) -> Maybe a -> b
@@ -406,17 +406,17 @@
 forall a b. (a -> b) -> a -> b
 $ Identifier -> TypeError
 UnboundVar Identifier
-var) UPolytype -> Infer UType
-instantiate Maybe UPolytype
-varUPT
+var) UPolytype -> Infer UType
+instantiate Maybe UPolytype
+varUPT
   where
-    instantiate :: UPolytype -> Infer UType
-    instantiate :: UPolytype -> Infer UType
-instantiate (Forall [Identifier]
-xs UType
-uty) = do
-      [UType]
-xs' <- (Identifier -> Infer UType)
+    instantiate :: UPolytype -> Infer UType
+    instantiate :: UPolytype -> Infer UType
+instantiate (Forall [Identifier]
+xs UType
+uty) = do
+      [UType]
+xs' <- (Identifier -> Infer UType)
 -> [Identifier]
 -> ReaderT
      Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) [UType]
@@ -428,7 +428,7 @@
 forall a b. a -> b -> a
 const Infer UType
 fresh) [Identifier]
-xs
+xs
       UType -> Infer UType
 forall a.
 a -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a
@@ -448,40 +448,40 @@
 map Identifier -> Either Identifier IntVar
 forall a b. a -> Either a b
 Left [Identifier]
-xs) [UType]
-xs')) UType
-uty
+xs) [UType]
+xs')) UType
+uty
 
-withBinding :: (MonadReader Ctx m) => L.Identifier -> UPolytype -> m a -> m a
+withBinding :: (MonadReader Ctx m) => L.Identifier -> UPolytype -> m a -> m a
 withBinding :: forall (m :: * -> *) a.
 MonadReader Ctx m =>
 Identifier -> UPolytype -> m a -> m a
-withBinding Identifier
-x UPolytype
-ty = (Ctx -> Ctx) -> m a -> m a
+withBinding Identifier
+x UPolytype
+ty = (Ctx -> Ctx) -> m a -> m a
 forall a. (Ctx -> Ctx) -> m a -> m a
 forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
 local (Identifier -> UPolytype -> Ctx -> Ctx
 forall k a. Ord k => k -> a -> Map k a -> Map k a
 M.insert Identifier
-x UPolytype
-ty)
+x UPolytype
+ty)
 
-ucata :: (Functor t) => (v -> a) -> (t a -> a) -> UTerm t v -> a
+ucata :: (Functor t) => (v -> a) -> (t a -> a) -> UTerm t v -> a
 ucata :: forall (t :: * -> *) v a.
 Functor t =>
 (v -> a) -> (t a -> a) -> UTerm t v -> a
-ucata v -> a
-f t a -> a
-_ (UVar v
-v) = v -> a
-f v
-v
-ucata v -> a
-f t a -> a
-g (UTerm t (UTerm t v)
-t) = t a -> a
-g ((UTerm t v -> a) -> t (UTerm t v) -> t a
+ucata v -> a
+f t a -> a
+_ (UVar v
+v) = v -> a
+f v
+v
+ucata v -> a
+f t a -> a
+g (UTerm t (UTerm t v)
+t) = t a -> a
+g ((UTerm t v -> a) -> t (UTerm t v) -> t a
 forall a b. (a -> b) -> t a -> t b
 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
 fmap ((v -> a) -> (t a -> a) -> UTerm t v -> a
@@ -489,23 +489,23 @@
 Functor t =>
 (v -> a) -> (t a -> a) -> UTerm t v -> a
 ucata v -> a
-f t a -> a
-g) t (UTerm t v)
-t)
+f t a -> a
+g) t (UTerm t v)
+t)
 
-deriving instance Ord IntVar
+deriving instance Ord IntVar
 
 -- * FreeVars
 
-class FreeVars a where
-  freeVars :: a -> Infer (Set (Either L.Identifier IntVar))
+class FreeVars a where
+  freeVars :: a -> Infer (Set (Either L.Identifier IntVar))
 
 instance FreeVars UType where
-  freeVars :: UType -> Infer (Set (Either Identifier IntVar))
-freeVars UType
-ut = do
-    Set (Either Identifier IntVar)
-fuvs <- ([IntVar] -> Set (Either Identifier IntVar))
+  freeVars :: UType -> Infer (Set (Either Identifier IntVar))
+freeVars UType
+ut = do
+    Set (Either Identifier IntVar)
+fuvs <- ([IntVar] -> Set (Either Identifier IntVar))
 -> ReaderT
      Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) [IntVar]
 -> Infer (Set (Either Identifier IntVar))
@@ -567,9 +567,9 @@
 BindingMonad t v m =>
 UTerm t v -> m [v]
 getFreeVars UType
-ut
-    let ftvs :: Set (Either Identifier IntVar)
-ftvs =
+ut
+    let ftvs :: Set (Either Identifier IntVar)
+ftvs =
           (IntVar -> Set (Either Identifier IntVar))
 -> (TypeF (Set (Either Identifier IntVar))
     -> Set (Either Identifier IntVar))
@@ -585,21 +585,21 @@
 const Set (Either Identifier IntVar)
 forall a. Set a
 S.empty)
-            (\case TVarF Identifier
-x -> Either Identifier IntVar -> Set (Either Identifier IntVar)
+            (\case TVarF Identifier
+x -> Either Identifier IntVar -> Set (Either Identifier IntVar)
 forall a. a -> Set a
 S.singleton (Identifier -> Either Identifier IntVar
 forall a b. a -> Either a b
 Left Identifier
-x); TypeF (Set (Either Identifier IntVar))
-f -> TypeF (Set (Either Identifier IntVar))
+x); TypeF (Set (Either Identifier IntVar))
+f -> TypeF (Set (Either Identifier IntVar))
 -> Set (Either Identifier IntVar)
 forall m. Monoid m => TypeF m -> m
 forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
 fold TypeF (Set (Either Identifier IntVar))
-f)
+f)
             UType
-ut
+ut
     Set (Either Identifier IntVar)
 -> Infer (Set (Either Identifier IntVar))
 forall a.
@@ -611,17 +611,17 @@
 -> Infer (Set (Either Identifier IntVar))
 forall a b. (a -> b) -> a -> b
 $ Set (Either Identifier IntVar)
-fuvs Set (Either Identifier IntVar)
+fuvs Set (Either Identifier IntVar)
 -> Set (Either Identifier IntVar) -> Set (Either Identifier IntVar)
 forall a. Ord a => Set a -> Set a -> Set a
 `S.union` Set (Either Identifier IntVar)
-ftvs
+ftvs
 
 instance FreeVars UPolytype where
-  freeVars :: UPolytype -> Infer (Set (Either Identifier IntVar))
-freeVars (Forall [Identifier]
-xs UType
-ut) = (Set (Either Identifier IntVar)
+  freeVars :: UPolytype -> Infer (Set (Either Identifier IntVar))
+freeVars (Forall [Identifier]
+xs UType
+ut) = (Set (Either Identifier IntVar)
 -> Set (Either Identifier IntVar) -> Set (Either Identifier IntVar)
 forall a. Ord a => Set a -> Set a -> Set a
 \\ [Either Identifier IntVar] -> Set (Either Identifier IntVar)
@@ -632,17 +632,17 @@
 map Identifier -> Either Identifier IntVar
 forall a b. a -> Either a b
 Left [Identifier]
-xs)) (Set (Either Identifier IntVar) -> Set (Either Identifier IntVar))
+xs)) (Set (Either Identifier IntVar) -> Set (Either Identifier IntVar))
 -> Infer (Set (Either Identifier IntVar))
 -> Infer (Set (Either Identifier IntVar))
 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
 <$> UType -> Infer (Set (Either Identifier IntVar))
 forall a. FreeVars a => a -> Infer (Set (Either Identifier IntVar))
 freeVars UType
-ut
+ut
 
 instance FreeVars Ctx where
-  freeVars :: Ctx -> Infer (Set (Either Identifier IntVar))
+  freeVars :: Ctx -> Infer (Set (Either Identifier IntVar))
 freeVars = ([Set (Either Identifier IntVar)]
  -> Set (Either Identifier IntVar))
 -> ReaderT
@@ -733,7 +733,7 @@
   ImpossibleBinOpApplication :: UType -> UType -> TypeError
   ImpossibleUnOpApplication :: UType -> TypeError
   Mismatch :: TypeF UType -> TypeF UType -> TypeError
-  deriving (Int -> TypeError -> ShowS
+  deriving (Int -> TypeError -> ShowS
 [TypeError] -> ShowS
 TypeError -> String
 (Int -> TypeError -> ShowS)
@@ -751,18 +751,18 @@
 Show)
 
 instance Fallible TypeF IntVar TypeError where
-  occursFailure :: IntVar -> UType -> TypeError
-occursFailure = IntVar -> UType -> TypeError
+  occursFailure :: IntVar -> UType -> TypeError
+occursFailure = IntVar -> UType -> TypeError
 Infinite
-  mismatchFailure :: TypeF UType -> TypeF UType -> TypeError
-mismatchFailure = TypeF UType -> TypeF UType -> TypeError
+  mismatchFailure :: TypeF UType -> TypeF UType -> TypeError
+mismatchFailure = TypeF UType -> TypeF UType -> TypeError
 Mismatch
 
 (=:=) :: UType -> UType -> Infer UType
-UType
-s =:= :: UType -> UType -> Infer UType
-=:= UType
-t = ExceptT TypeError (IntBindingT TypeF Identity) UType -> Infer UType
+UType
+s =:= :: UType -> UType -> Infer UType
+=:= UType
+t = ExceptT TypeError (IntBindingT TypeF Identity) UType -> Infer UType
 forall (m :: * -> *) a. Monad m => m a -> ReaderT Ctx m a
 forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
 (MonadTrans t, Monad m) =>
@@ -773,14 +773,14 @@
 -> Infer UType
 forall a b. (a -> b) -> a -> b
 $ UType
-s UType
+s UType
 -> UType -> ExceptT TypeError (IntBindingT TypeF Identity) UType
 forall (t :: * -> *) v (m :: * -> *) e (em :: (* -> *) -> * -> *).
 (BindingMonad t v m, Fallible t v e, MonadTrans em, Functor (em m),
  MonadError e (em m)) =>
 UTerm t v -> UTerm t v -> em m (UTerm t v)
 U.=:= UType
-t
+t
 
 applyBindings :: UType -> Infer UType
 applyBindings :: UType -> Infer UType
@@ -804,60 +804,60 @@
 
 substU :: Map (Either L.Identifier IntVar) UType -> UType -> UType
 substU :: Map (Either Identifier IntVar) UType -> UType -> UType
-substU Map (Either Identifier IntVar) UType
-m =
+substU Map (Either Identifier IntVar) UType
+m =
   (IntVar -> UType) -> (TypeF UType -> UType) -> UType -> UType
 forall (t :: * -> *) v a.
 Functor t =>
 (v -> a) -> (t a -> a) -> UTerm t v -> a
 ucata
-    (\IntVar
-v -> UType -> Maybe UType -> UType
+    (\IntVar
+v -> UType -> Maybe UType -> UType
 forall a. a -> Maybe a -> a
 fromMaybe (IntVar -> UType
 forall (t :: * -> *) v. v -> UTerm t v
 UVar IntVar
-v) (Either Identifier IntVar
+v) (Either Identifier IntVar
 -> Map (Either Identifier IntVar) UType -> Maybe UType
 forall k a. Ord k => k -> Map k a -> Maybe a
 M.lookup (IntVar -> Either Identifier IntVar
 forall a b. b -> Either a b
 Right IntVar
-v) Map (Either Identifier IntVar) UType
-m))
+v) Map (Either Identifier IntVar) UType
+m))
     ( \case
-        TVarF Identifier
-v -> UType -> Maybe UType -> UType
+        TVarF Identifier
+v -> UType -> Maybe UType -> UType
 forall a. a -> Maybe a -> a
 fromMaybe (Identifier -> UType
 UTVar Identifier
-v) (Either Identifier IntVar
+v) (Either Identifier IntVar
 -> Map (Either Identifier IntVar) UType -> Maybe UType
 forall k a. Ord k => k -> Map k a -> Maybe a
 M.lookup (Identifier -> Either Identifier IntVar
 forall a b. a -> Either a b
 Left Identifier
-v) Map (Either Identifier IntVar) UType
-m)
-        TypeF UType
-f -> TypeF UType -> UType
+v) Map (Either Identifier IntVar) UType
+m)
+        TypeF UType
+f -> TypeF UType -> UType
 forall (t :: * -> *) v. t (UTerm t v) -> UTerm t v
 UTerm TypeF UType
-f
+f
     )
 
 mkVarName :: String -> IntVar -> L.Identifier
 mkVarName :: String -> IntVar -> Identifier
-mkVarName String
-nm (IntVar Int
-v) = String -> Identifier
+mkVarName String
+nm (IntVar Int
+v) = String -> Identifier
 pack (String
-nm String -> ShowS
+nm String -> ShowS
 forall a. Semigroup a => a -> a -> a
 <> Int -> String
 forall a. Show a => a -> String
 show (Int
-v Int -> Int -> Int
+v Int -> Int -> Int
 forall a. Num a => a -> a -> a
 + (Int
 forall a. Bounded a => a
@@ -868,40 +868,40 @@
 
 generalize :: UType -> Infer UPolytype
 generalize :: UType -> Infer UPolytype
-generalize UType
-uty = do
-  UType
-uty' <- UType -> Infer UType
+generalize UType
+uty = do
+  UType
+uty' <- UType -> Infer UType
 applyBindings UType
-uty
-  Ctx
-ctx <- ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) Ctx
+uty
+  Ctx
+ctx <- ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) Ctx
 forall r (m :: * -> *). MonadReader r m => m r
 ask
-  Set (Either Identifier IntVar)
-tmFreeVars <- UType -> Infer (Set (Either Identifier IntVar))
+  Set (Either Identifier IntVar)
+tmFreeVars <- UType -> Infer (Set (Either Identifier IntVar))
 forall a. FreeVars a => a -> Infer (Set (Either Identifier IntVar))
 freeVars UType
-uty'
-  Set (Either Identifier IntVar)
-ctxFreeVars <- Ctx -> Infer (Set (Either Identifier IntVar))
+uty'
+  Set (Either Identifier IntVar)
+ctxFreeVars <- Ctx -> Infer (Set (Either Identifier IntVar))
 forall a. FreeVars a => a -> Infer (Set (Either Identifier IntVar))
 freeVars Ctx
-ctx
-  let fvs :: [Either Identifier IntVar]
-fvs = Set (Either Identifier IntVar) -> [Either Identifier IntVar]
+ctx
+  let fvs :: [Either Identifier IntVar]
+fvs = Set (Either Identifier IntVar) -> [Either Identifier IntVar]
 forall a. Set a -> [a]
 S.toList (Set (Either Identifier IntVar) -> [Either Identifier IntVar])
 -> Set (Either Identifier IntVar) -> [Either Identifier IntVar]
 forall a b. (a -> b) -> a -> b
 $ Set (Either Identifier IntVar)
-tmFreeVars Set (Either Identifier IntVar)
+tmFreeVars Set (Either Identifier IntVar)
 -> Set (Either Identifier IntVar) -> Set (Either Identifier IntVar)
 forall a. Ord a => Set a -> Set a -> Set a
 \\ Set (Either Identifier IntVar)
-ctxFreeVars
-      xs :: [Identifier]
-xs = (Either Identifier IntVar -> Identifier)
+ctxFreeVars
+      xs :: [Identifier]
+xs = (Either Identifier IntVar -> Identifier)
 -> [Either Identifier IntVar] -> [Identifier]
 forall a b. (a -> b) -> [a] -> [b]
 map ((Identifier -> Identifier)
@@ -912,7 +912,7 @@
 id (String -> IntVar -> Identifier
 mkVarName String
 "a")) [Either Identifier IntVar]
-fvs
+fvs
   UPolytype -> Infer UPolytype
 forall a.
 a -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a
@@ -922,7 +922,7 @@
 $ [Identifier] -> UType -> UPolytype
 forall t. [Identifier] -> t -> Poly t
 Forall [Identifier]
-xs (Map (Either Identifier IntVar) UType -> UType -> UType
+xs (Map (Either Identifier IntVar) UType -> UType -> UType
 substU ([(Either Identifier IntVar, UType)]
 -> Map (Either Identifier IntVar) UType
 forall k a. Ord k => [(k, a)] -> Map k a
@@ -930,10 +930,10 @@
 -> [UType] -> [(Either Identifier IntVar, UType)]
 forall a b. [a] -> [b] -> [(a, b)]
 zip [Either Identifier IntVar]
-fvs ((Identifier -> UType) -> [Identifier] -> [UType]
+fvs ((Identifier -> UType) -> [Identifier] -> [UType]
 forall a b. (a -> b) -> [a] -> [b]
 map Identifier -> UType
 UTVar [Identifier]
-xs))) UType
-uty')
+xs))) UType
+uty')
 
\ No newline at end of file diff --git a/src/TypeChecker.PrettyPrinter.html b/src/TypeChecker.PrettyPrinter.html index f25a71b..753bad7 100644 --- a/src/TypeChecker.PrettyPrinter.html +++ b/src/TypeChecker.PrettyPrinter.html @@ -11,40 +11,40 @@
import TypeChecker.HindleyMilner import Prelude hiding (lookup) -class Pretty p where - pretty :: p -> String - pretty = Prec -> p -> String +class Pretty p where + pretty :: p -> String + pretty = Prec -> p -> String forall p. Pretty p => Prec -> p -> String prettyPrec Prec 0 - prettyPrec :: Prec -> p -> String - prettyPrec Prec + prettyPrec :: Prec -> p -> String + prettyPrec Prec _ = p -> String forall p. Pretty p => p -> String pretty type Prec = Int -instance (Pretty (t (Fix t))) => Pretty (Fix t) where - prettyPrec :: Prec -> Fix t -> String -prettyPrec Prec -p = Prec -> t (Fix t) -> String +instance (Pretty (t (Fix t))) => Pretty (Fix t) where + prettyPrec :: Prec -> Fix t -> String +prettyPrec Prec +p = Prec -> t (Fix t) -> String forall p. Pretty p => Prec -> p -> String prettyPrec Prec -p (t (Fix t) -> String) -> (Fix t -> t (Fix t)) -> Fix t -> String +p (t (Fix t) -> String) -> (Fix t -> t (Fix t)) -> Fix t -> String forall b c a. (b -> c) -> (a -> b) -> a -> c . Fix t -> t (Fix t) forall (f :: * -> *). Fix f -> f (Fix f) unFix -instance (Pretty t) => Pretty (TypeF t) where - prettyPrec :: Prec -> TypeF t -> String +instance (Pretty t) => Pretty (TypeF t) where + prettyPrec :: Prec -> TypeF t -> String prettyPrec Prec -_ (TVarF Identifier -x) = Identifier -> String +_ (TVarF Identifier +x) = Identifier -> String unpack Identifier -x +x prettyPrec Prec _ TypeF t TUnitF = String @@ -57,13 +57,13 @@ _ TypeF t TIntF = String "int" - prettyPrec Prec -p (TFunF t -ty1 t -ty2) = + prettyPrec Prec +p (TFunF t +ty1 t +ty2) = Bool -> String -> String mparens (Prec -p Prec -> Prec -> Bool +p Prec -> Prec -> Bool forall a. Ord a => a -> a -> Bool > Prec 0) (String -> String) -> String -> String @@ -72,7 +72,7 @@ forall p. Pretty p => Prec -> p -> String prettyPrec Prec 1 t -ty1 String -> String -> String +ty1 String -> String -> String forall a. [a] -> [a] -> [a] ++ String " -> " String -> String -> String @@ -81,31 +81,31 @@ forall p. Pretty p => Prec -> p -> String prettyPrec Prec 0 t -ty2 +ty2 -instance (Pretty (t (UTerm t v)), Pretty v) => Pretty (UTerm t v) where - pretty :: UTerm t v -> String -pretty (UTerm t (UTerm t v) -t) = t (UTerm t v) -> String +instance (Pretty (t (UTerm t v)), Pretty v) => Pretty (UTerm t v) where + pretty :: UTerm t v -> String +pretty (UTerm t (UTerm t v) +t) = t (UTerm t v) -> String forall p. Pretty p => p -> String pretty t (UTerm t v) -t - pretty (UVar v -v) = v -> String +t + pretty (UVar v +v) = v -> String forall p. Pretty p => p -> String pretty v -v +v -instance Pretty Polytype where - pretty :: Polytype -> String -pretty (Forall [] Type -t) = Type -> String +instance Pretty Polytype where + pretty :: Polytype -> String +pretty (Forall [] Type +t) = Type -> String forall p. Pretty p => p -> String pretty Type -t - pretty (Forall [Identifier] -xs Type -t) = [String] -> String +t + pretty (Forall [Identifier] +xs Type +t) = [String] -> String unwords (String "forall" String -> [String] -> [String] forall a. a -> [a] -> [a] @@ -113,7 +113,7 @@ unpack (Identifier -> String) -> [Identifier] -> [String] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Identifier] -xs)) String -> String -> String +xs)) String -> String -> String forall a. [a] -> [a] -> [a] ++ String ". " String -> String -> String @@ -121,7 +121,7 @@ ++ Type -> String forall p. Pretty p => p -> String pretty Type -t +t mparens :: Bool -> String -> String mparens :: Bool -> String -> String @@ -140,8 +140,8 @@ forall a. a -> a id -instance Pretty IntVar where - pretty :: IntVar -> String +instance Pretty IntVar where + pretty :: IntVar -> String pretty = Identifier -> String unpack (Identifier -> String) -> (IntVar -> Identifier) -> IntVar -> String @@ -150,65 +150,65 @@ mkVarName String "u" -instance Pretty TypeError where - pretty :: TypeError -> String +instance Pretty TypeError where + pretty :: TypeError -> String pretty TypeError Unreachable = String -> String forall r. PrintfType r => String -> r printf String "Unreachable state" - pretty (ImpossibleBinOpApplication UType -c1 UType -c2) = String -> String -> String -> String + pretty (ImpossibleBinOpApplication UType +c1 UType +c2) = String -> String -> String -> String forall r. PrintfType r => String -> r printf String "It is not possible to apply this operation between '%s' and '%s'" (Prec -> UType -> String forall p. Pretty p => Prec -> p -> String prettyPrec Prec 0 UType -c1) (Prec -> UType -> String +c1) (Prec -> UType -> String forall p. Pretty p => Prec -> p -> String prettyPrec Prec 0 UType -c2) - pretty (ImpossibleUnOpApplication UType -c) = String -> String -> String +c2) + pretty (ImpossibleUnOpApplication UType +c) = String -> String -> String forall r. PrintfType r => String -> r printf String "It is not possible to apply this operation to '%s'" (Prec -> UType -> String forall p. Pretty p => Prec -> p -> String prettyPrec Prec 0 UType -c) - pretty (UnboundVar Identifier -x) = String -> String -> String +c) + pretty (UnboundVar Identifier +x) = String -> String -> String forall r. PrintfType r => String -> r printf String "Unbound variable '%s'" (Identifier -> String unpack Identifier -x) - pretty (Infinite IntVar -x UType -ty) = String -> String -> String -> String +x) + pretty (Infinite IntVar +x UType +ty) = String -> String -> String -> String forall r. PrintfType r => String -> r printf String "Infinite type %s = %s" (IntVar -> String forall p. Pretty p => p -> String pretty IntVar -x) (UType -> String +x) (UType -> String forall p. Pretty p => p -> String pretty UType -ty) - pretty (Mismatch TypeF UType -ty1 TypeF UType -ty2) = String -> String -> String -> String +ty) + pretty (Mismatch TypeF UType +ty1 TypeF UType +ty2) = String -> String -> String -> String forall r. PrintfType r => String -> r printf String "The type '%s' does not match the type '%s'" (TypeF UType -> String forall p. Pretty p => p -> String pretty TypeF UType -ty1) (TypeF UType -> String +ty1) (TypeF UType -> String forall p. Pretty p => p -> String pretty TypeF UType -ty2) +ty2)
\ No newline at end of file diff --git a/src/TypeChecker.TypeChecker.html b/src/TypeChecker.TypeChecker.html index 3153e4a..0a4471f 100644 --- a/src/TypeChecker.TypeChecker.html +++ b/src/TypeChecker.TypeChecker.html @@ -37,22 +37,22 @@
inferProgram :: Program -> Either TypeError Polytype inferProgram :: Program -> Either TypeError Polytype -inferProgram (Program [Statement] -stmts) = Infer UType -> Either TypeError Polytype -runInfer (Infer UType -> Either TypeError Polytype) +inferProgram
(Program [Statement] +stmts) = Infer UType -> Either TypeError Polytype +runInfer (Infer UType -> Either TypeError Polytype) -> Infer UType -> Either TypeError Polytype forall a b. (a -> b) -> a -> b $ Infer UType -> Infer UType forall {b}. ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b -withStdLib ([Statement] -> Infer UType +withStdLib ([Statement] -> Infer UType inferStatements [Statement] -stmts) +stmts
) where - runInfer :: Infer UType -> Either TypeError Polytype - runInfer :: Infer UType -> Either TypeError Polytype -runInfer = + runInfer :: Infer UType -> Either TypeError Polytype + runInfer :: Infer UType -> Either TypeError Polytype +runInfer = (Infer UType -> (UType -> Infer UType) -> Infer UType forall a b. ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a @@ -172,17 +172,17 @@ forall a. Identity a -> a runIdentity - withStdLib :: ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b + withStdLib :: ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b -withStdLib ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b -infer = do - let generalizeDecl :: (t, Type) +withStdLib ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b +infer = do + let generalizeDecl :: (t, Type) -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) (t, UPolytype) -generalizeDecl (t -ident, Type -t) = (t -ident,) (UPolytype -> (t, UPolytype)) +generalizeDecl (t +ident, Type +t) = (t +ident,) (UPolytype -> (t, UPolytype)) -> Infer UPolytype -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) (t, UPolytype) @@ -190,9 +190,9 @@ <$> UType -> Infer UPolytype generalize (Type -> UType toUType Type -t) - [(Identifier, UPolytype)] -generalizedDecls <- ((Identifier, Type) +t) + [(Identifier, UPolytype)] +generalizedDecls <- ((Identifier, Type) -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) @@ -215,7 +215,7 @@ (t, Type) -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) (t, UPolytype) -generalizeDecl [(Identifier, Type)] +generalizeDecl [(Identifier, Type)] StdLib.typedDecls (Ctx -> Ctx) -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b @@ -230,17 +230,17 @@ M.union ([(Identifier, UPolytype)] -> Ctx forall k a. Ord k => [(k, a)] -> Map k a M.fromList [(Identifier, UPolytype)] -generalizedDecls)) ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b -infer +generalizedDecls)) ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) b +infer -- * Internal inferStatements :: [Statement] -> Infer UType inferStatements :: [Statement] -> Infer UType -inferStatements [Statement] -x = [Statement] -> Infer UType -> Infer UType +inferStatements
[Statement] +x = [Statement] -> Infer UType -> Infer UType inferStatements' [Statement] -x (TypeError -> Infer UType +x (TypeError -> Infer UType forall a. TypeError -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a @@ -250,134 +250,134 @@ inferStatements' :: [Statement] -> Infer UType -> Infer UType inferStatements' :: [Statement] -> Infer UType -> Infer UType -inferStatements' [] Infer UType -t = Infer UType -t -inferStatements' ((StmtExpr Expression -e) : [Statement] -stmts) Infer UType +inferStatements' [] Infer UType +t = Infer UType +t +inferStatements' ((StmtExpr Expression +e) : [Statement] +stmts) Infer UType _ = do - UType -res <- Expression -> Infer UType + UType +res <- Expression -> Infer UType inferExpr Expression -e +e [Statement] -> Infer UType -> Infer UType inferStatements' [Statement] -stmts (UType -> Infer UType +stmts (UType -> Infer UType forall a. a -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a forall (m :: * -> *) a. Monad m => a -> m a return UType -res) -inferStatements' ((StmtDecl (DeclVar (Identifier -ident, Maybe Type -t) Expression -val)) : [Statement] -stmts) Infer UType +res) +inferStatements' ((StmtDecl (DeclVar (Identifier +ident, Maybe Type +t) Expression +val)) : [Statement] +stmts) Infer UType _ = do - UType -t' <- Expression -> Infer UType + UType +t' <- Expression -> Infer UType inferExpr Expression -val - UType -t'' <- UType -> Maybe Type -> Infer UType +val + UType +t'' <- UType -> Maybe Type -> Infer UType checkByAnnotation UType -t' Maybe Type -t - UPolytype -upt <- UType -> Infer UPolytype +t' Maybe Type +t + UPolytype +upt <- UType -> Infer UPolytype generalize UType -t'' +t'' Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident UPolytype -upt (Infer UType -> Infer UType) -> Infer UType -> Infer UType +ident UPolytype +upt (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ [Statement] -> Infer UType -> Infer UType inferStatements' [Statement] -stmts (UType -> Infer UType +stmts (UType -> Infer UType forall a. a -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a forall (m :: * -> *) a. Monad m => a -> m a return UType -t'') -inferStatements' ((StmtDecl (DeclFun Identifier -ident IsRec -isRec Fun -fun)) : [Statement] -stmts) Infer UType +t'') +inferStatements' ((StmtDecl (DeclFun Identifier +ident IsRec +isRec Fun +fun)) : [Statement] +stmts) Infer UType _ = do - UType -funT <- + UType +funT <- if IsRec -isRec +isRec
then do - UType -funT <- Infer UType + UType +funT <- Infer UType fresh - UType -funT' <- Identifier -> UPolytype -> Infer UType -> Infer UType + UType +funT' <- Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident ([Identifier] -> UType -> UPolytype +ident ([Identifier] -> UType -> UPolytype forall t. [Identifier] -> t -> Poly t Forall [] UType -funT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType +funT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ Fun -> Infer UType inferFun Fun -fun +fun Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident ([Identifier] -> UType -> UPolytype +ident ([Identifier] -> UType -> UPolytype forall t. [Identifier] -> t -> Poly t Forall [] UType -funT') (Infer UType -> Infer UType) -> Infer UType -> Infer UType +funT') (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ Fun -> Infer UType inferFun Fun -fun +fun else Fun -> Infer UType inferFun Fun -fun - UPolytype -funUT <- UType -> Infer UPolytype +fun + UPolytype +funUT <- UType -> Infer UPolytype generalize UType -funT +funT
Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident UPolytype -funUT (Infer UType -> Infer UType) -> Infer UType -> Infer UType +ident UPolytype +funUT (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ [Statement] -> Infer UType -> Infer UType inferStatements' [Statement] -stmts (UType -> Infer UType +stmts (UType -> Infer UType forall a. a -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a forall (m :: * -> *) a. Monad m => a -> m a return UType -funT) +funT
) inferExpr :: Expression -> Infer UType inferExpr :: Expression -> Infer UType -inferExpr (ExprId Identifier -ident) = Identifier -> Infer UType +inferExpr
(ExprId Identifier +ident) = Identifier -> Infer UType lookup Identifier -ident -inferExpr (ExprPrimVal PrimitiveValue -value) = case PrimitiveValue -value of +ident
+inferExpr (ExprPrimVal PrimitiveValue +value) = case PrimitiveValue +value of PrimitiveValue PrimValUnit -> UType -> Infer UType forall a. @@ -399,18 +399,18 @@ forall (m :: * -> *) a. Monad m => a -> m a return UType UTInt -inferExpr (ExprBinOp BinaryOperator -op Expression -lhs Expression -rhs) = do - UType -lhsT <- Expression -> Infer UType +inferExpr (ExprBinOp BinaryOperator +op Expression +lhs Expression +rhs) = do + UType +lhsT <- Expression -> Infer UType inferExpr Expression -lhs - UType -rhsT <- Expression -> Infer UType +lhs + UType +rhsT <- Expression -> Infer UType inferExpr Expression -rhs +rhs (TypeError -> TypeError) -> Infer UType -> Infer UType forall e (m :: * -> *) a. MonadError e m => (e -> e) -> m a -> m a withError (TypeError -> TypeError -> TypeError @@ -420,25 +420,25 @@ forall a b. (a -> b) -> a -> b $ UType -> UType -> TypeError ImpossibleBinOpApplication UType -lhsT UType -rhsT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType +lhsT UType +rhsT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ do - UType -valT <- UType -lhsT UType -> UType -> Infer UType + UType +valT <- UType +lhsT UType -> UType -> Infer UType =:= UType -rhsT +rhsT case BinaryOperator -op of +op
of BoolOp BooleanOperator _ -> UType -valT UType -> UType -> Infer UType +valT UType -> UType -> Infer UType =:= UType UTBool ArithOp ArithmeticOperator _ -> UType -valT UType -> UType -> Infer UType +valT UType -> UType -> Infer UType =:= UType UTInt CompOp ComparisonOperator @@ -448,13 +448,13 @@ forall (m :: * -> *) a. Monad m => a -> m a return UType UTBool -inferExpr (ExprUnOp UnaryOperator -op Expression -val) = do - UType -valT <- Expression -> Infer UType +inferExpr (ExprUnOp UnaryOperator +op Expression +val) = do + UType +valT <- Expression -> Infer UType inferExpr Expression -val +val (TypeError -> TypeError) -> Infer UType -> Infer UType forall e (m :: * -> *) a. MonadError e m => (e -> e) -> m a -> m a withError (TypeError -> TypeError -> TypeError @@ -464,197 +464,197 @@ forall a b. (a -> b) -> a -> b $ UType -> TypeError ImpossibleUnOpApplication UType -valT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType +valT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ case UnaryOperator -op of +op
of UnaryOperator UnMinusOp -> UType -valT UType -> UType -> Infer UType +valT UType -> UType -> Infer UType =:= UType UTInt -inferExpr (ExprApp Expression -funExpr Expression -argExpr) = do - UType -funT <- Expression -> Infer UType +inferExpr (ExprApp Expression +funExpr Expression +argExpr) = do + UType +funT <- Expression -> Infer UType inferExpr Expression -funExpr - UType -argT <- Expression -> Infer UType +funExpr + UType +argT <- Expression -> Infer UType inferExpr Expression -argExpr - UType -resT <- Infer UType +argExpr + UType +resT <- Infer UType fresh UType _ <- UType -funT UType -> UType -> Infer UType +funT UType -> UType -> Infer UType =:= UType -> UType -> UType UTFun UType -argT UType -resT +argT UType +resT UType -> Infer UType forall a. a -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a forall (m :: * -> *) a. Monad m => a -> m a return UType -resT -inferExpr (ExprIte Expression -c Expression -t Expression -e) = do +resT
+inferExpr (ExprIte Expression +c Expression +t Expression +e) = do UType _ <- Expression -> UType -> Infer UType check Expression -c UType +c UType UTBool - UType -tT <- Expression -> Infer UType + UType +tT <- Expression -> Infer UType inferExpr Expression -t - UType -eT <- Expression -> Infer UType +t + UType +eT <- Expression -> Infer UType inferExpr Expression -e +e UType -tT UType -> UType -> Infer UType +tT UType -> UType -> Infer UType =:= UType -eT -inferExpr (ExprLetIn Declaration -decl Expression -expr) = Declaration -> Expression -> Infer UType +eT +inferExpr (ExprLetIn Declaration +decl Expression +expr) = Declaration -> Expression -> Infer UType inferLetIn Declaration -decl Expression -expr -inferExpr (ExprFun Fun -fun) = Fun -> Infer UType +decl Expression +expr +inferExpr (ExprFun Fun +fun) = Fun -> Infer UType inferFun Fun -fun +fun
inferLetIn :: Declaration -> Expression -> Infer UType inferLetIn :: Declaration -> Expression -> Infer UType -inferLetIn (DeclVar (Identifier -ident, Maybe Type -t) Expression -val) Expression -expr = do - UType -t' <- Expression -> Infer UType +inferLetIn
(DeclVar (Identifier +ident, Maybe Type +t) Expression +val) Expression +expr = do + UType +t' <- Expression -> Infer UType inferExpr Expression -val - UType -t'' <- UType -> Maybe Type -> Infer UType +val + UType +t'' <- UType -> Maybe Type -> Infer UType checkByAnnotation UType -t' Maybe Type -t - UPolytype -upt <- UType -> Infer UPolytype +t' Maybe Type +t + UPolytype +upt <- UType -> Infer UPolytype generalize UType -t'' +t''
Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident UPolytype -upt (Infer UType -> Infer UType) -> Infer UType -> Infer UType +ident UPolytype +upt (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ Expression -> Infer UType inferExpr Expression -expr -inferLetIn (DeclFun Identifier -ident IsRec -isRec Fun -fun) Expression -expr = do - UType -funT <- +expr
+inferLetIn (DeclFun Identifier +ident IsRec +isRec Fun +fun) Expression +expr = do + UType +funT <- if IsRec -isRec +isRec
then do - UType -funT <- Infer UType + UType +funT <- Infer UType fresh - UType -funT' <- Identifier -> UPolytype -> Infer UType -> Infer UType + UType +funT' <- Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident ([Identifier] -> UType -> UPolytype +ident ([Identifier] -> UType -> UPolytype forall t. [Identifier] -> t -> Poly t Forall [] UType -funT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType +funT) (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ Fun -> Infer UType inferFun Fun -fun +fun Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident ([Identifier] -> UType -> UPolytype +ident ([Identifier] -> UType -> UPolytype forall t. [Identifier] -> t -> Poly t Forall [] UType -funT') (Infer UType -> Infer UType) -> Infer UType -> Infer UType +funT') (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ Fun -> Infer UType inferFun Fun -fun +fun else Fun -> Infer UType inferFun Fun -fun - UPolytype -funUT <- UType -> Infer UPolytype +fun + UPolytype +funUT <- UType -> Infer UPolytype generalize UType -funT +funT
Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident UPolytype -funUT (Infer UType -> Infer UType) -> Infer UType -> Infer UType +ident UPolytype +funUT (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ Expression -> Infer UType inferExpr Expression -expr +expr
inferFun :: Fun -> Infer UType inferFun :: Fun -> Infer UType -inferFun (Fun NonEmpty (Identifier, Maybe Type) -params Maybe Type -resT Expression -body) = [(Identifier, Maybe Type)] -> Infer UType -inferFun' ([(Identifier, Maybe Type)] -> Infer UType) +inferFun
(Fun NonEmpty (Identifier, Maybe Type) +params Maybe Type +resT Expression +body) = [(Identifier, Maybe Type)] -> Infer UType +inferFun' ([(Identifier, Maybe Type)] -> Infer UType) -> [(Identifier, Maybe Type)] -> Infer UType forall a b. (a -> b) -> a -> b $ NonEmpty (Identifier, Maybe Type) -> [(Identifier, Maybe Type)] forall a. NonEmpty a -> [a] toList NonEmpty (Identifier, Maybe Type) -params +params
where - inferFun' :: [(Identifier, Maybe Type)] -> Infer UType -inferFun' [(Identifier, Maybe Type)] -params' = case [(Identifier, Maybe Type)] -params' of + inferFun' :: [(Identifier, Maybe Type)] -> Infer UType +inferFun' [(Identifier, Maybe Type)] +params' = case [(Identifier, Maybe Type)] +params' of [] -> do - UType -bodyT <- Expression -> Infer UType + UType +bodyT <- Expression -> Infer UType inferExpr Expression -body +body UType -> Maybe Type -> Infer UType checkByAnnotation UType -bodyT Maybe Type -resT - (Identifier -ident, Maybe Type -t) : [(Identifier, Maybe Type)] -params'' -> do - UType -t' <- Infer UType -> (Type -> Infer UType) -> Maybe Type -> Infer UType +bodyT Maybe Type +resT + (Identifier +ident, Maybe Type +t) : [(Identifier, Maybe Type)] +params'' -> do + UType +t' <- Infer UType -> (Type -> Infer UType) -> Maybe Type -> Infer UType forall b a. b -> (a -> b) -> Maybe a -> b maybe Infer UType fresh (UType -> Infer UType @@ -665,58 +665,58 @@ forall b c a. (b -> c) -> (a -> b) -> a -> c . Type -> UType toUType) Maybe Type -t +t
Identifier -> UPolytype -> Infer UType -> Infer UType forall (m :: * -> *) a. MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a withBinding Identifier -ident ([Identifier] -> UType -> UPolytype +ident ([Identifier] -> UType -> UPolytype forall t. [Identifier] -> t -> Poly t Forall [] UType -t') (Infer UType -> Infer UType) -> Infer UType -> Infer UType +t') (Infer UType -> Infer UType) -> Infer UType -> Infer UType forall a b. (a -> b) -> a -> b $ UType -> UType -> UType UTFun UType -t' (UType -> UType) -> Infer UType -> Infer UType +t' (UType -> UType) -> Infer UType -> Infer UType forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [(Identifier, Maybe Type)] -> Infer UType -inferFun' [(Identifier, Maybe Type)] -params'' +inferFun'
[(Identifier, Maybe Type)] +params'' -- ** Utils check :: Expression -> UType -> Infer UType check :: Expression -> UType -> Infer UType -check Expression -expr UType -t = do - UType -exprT <- Expression -> Infer UType +check
Expression +expr UType +t = do + UType +exprT <- Expression -> Infer UType inferExpr Expression -expr +expr
UType -t UType -> UType -> Infer UType +t UType -> UType -> Infer UType =:= UType -exprT +exprT
checkByAnnotation :: UType -> Maybe L.Type -> Infer UType checkByAnnotation :: UType -> Maybe Type -> Infer UType -checkByAnnotation UType -t Maybe Type -ann = case Maybe Type -ann of - Just Type -annT -> Type -> UType +checkByAnnotation
UType +t Maybe Type +ann = case Maybe Type +ann of + Just Type +annT -> Type -> UType toUType Type -annT UType -> UType -> Infer UType +annT UType -> UType -> Infer UType =:= UType -t +t
Maybe Type Nothing -> UType -> Infer UType forall a. a -> ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity)) a forall (m :: * -> *) a. Monad m => a -> m a return UType -t +t
\ No newline at end of file