License | BSD3 |
---|---|
Maintainer | The Idris Community. |
Safe Haskell | None |
Language | Haskell2010 |
To defunctionalise:
- Create a data constructor for each function
- Create a data constructor for each underapplication of a function
- Convert underapplications to their corresponding constructors
- Create an EVAL function which calls the appropriate function for data constructors created as part of step 1
- Create an APPLY function which adds an argument to each underapplication (or calls APPLY again for an exact application)
- Wrap overapplications in chains of APPLY
- Wrap unknown applications (i.e. applications of local variables) in chains of APPLY
- Add explicit EVAL to case, primitives, and foreign calls
Synopsis
- data EvalApply a
- = EvalCase (Name -> a)
- | ApplyCase a
- | Apply2Case a
- type DDefs = Ctxt DDecl
- data DDecl
- data DAlt
- = DConCase Int Name [Name] DExp
- | DConstCase Const DExp
- | DDefaultCase DExp
- data DExp
- defunctionalise :: Int -> LDefs -> DDefs
- getFn :: [(Name, LDecl)] -> [(Name, Int)]
- addApps :: LDefs -> (Name, LDecl) -> State ([Name], [(Name, Int)]) (Name, DDecl)
- eEVAL :: DExp -> DExp
- toCons :: [Name] -> (Name, Int) -> [(Name, Int, EvalApply DAlt)]
- toConsA :: [(Name, Int)] -> (Name, Int) -> [(Name, Int, EvalApply DAlt)]
- mkApplyCase :: Name -> Int -> Int -> [(Name, Int, EvalApply DAlt)]
- mkEval :: [(Name, Int, EvalApply DAlt)] -> (Name, DDecl)
- mkApply :: [(Name, Int, EvalApply DAlt)] -> (Name, DDecl)
- mkApply2 :: [(Name, Int, EvalApply DAlt)] -> (Name, DDecl)
- declare :: Int -> [(Name, Int, EvalApply DAlt)] -> [(Name, DDecl)]
- genArgs :: Int -> [Name]
- mkFnCon :: Show a => a -> Name
- mkUnderCon :: Name -> Int -> Name
- mkBigCase :: p -> Int -> DExp -> [DAlt] -> DExp
- groupsOf :: Int -> [DAlt] -> [[DAlt]]
- dumpDefuns :: DDefs -> String
- module IRTS.Lang
Documentation
DV Name | |
DApp Bool Name [DExp] | |
DLet Name DExp DExp | |
DUpdate Name DExp | |
DProj DExp Int | |
DC (Maybe Name) Int Name [DExp] | |
DCase CaseType DExp [DAlt] | |
DChkCase DExp [DAlt] | |
DConst Const | |
DForeign FDesc FDesc [(FDesc, DExp)] | |
DOp PrimFn [DExp] | |
DNothing | |
DError String |
mkBigCase :: p -> Int -> DExp -> [DAlt] -> DExp Source #
Divide up a large case expression so that each has a maximum of
max
branches
dumpDefuns :: DDefs -> String Source #
module IRTS.Lang