idris-1.3.4: Functional Programming Language with Dependent Types
LicenseBSD3
MaintainerThe Idris Community.
Safe HaskellSafe-Inferred
LanguageHaskell2010

IRTS.Defunctionalise

Description

To defunctionalise:

  1. Create a data constructor for each function
  2. Create a data constructor for each underapplication of a function
  3. Convert underapplications to their corresponding constructors
  4. Create an EVAL function which calls the appropriate function for data constructors created as part of step 1
  5. Create an APPLY function which adds an argument to each underapplication (or calls APPLY again for an exact application)
  6. Wrap overapplications in chains of APPLY
  7. Wrap unknown applications (i.e. applications of local variables) in chains of APPLY
  8. Add explicit EVAL to case, primitives, and foreign calls
Synopsis

Documentation

data DExp Source #

Instances

Instances details
ToJSON DExp 
Instance details

Defined in IRTS.Portable

Methods

toJSON :: DExp -> Value

toEncoding :: DExp -> Encoding

toJSONList :: [DExp] -> Value

toEncodingList :: [DExp] -> Encoding

Show DExp Source # 
Instance details

Defined in IRTS.Defunctionalise

Methods

showsPrec :: Int -> DExp -> ShowS

show :: DExp -> String

showList :: [DExp] -> ShowS

Eq DExp Source # 
Instance details

Defined in IRTS.Defunctionalise

Methods

(==) :: DExp -> DExp -> Bool

(/=) :: DExp -> DExp -> Bool

data DAlt Source #

Instances

Instances details
ToJSON DAlt 
Instance details

Defined in IRTS.Portable

Methods

toJSON :: DAlt -> Value

toEncoding :: DAlt -> Encoding

toJSONList :: [DAlt] -> Value

toEncodingList :: [DAlt] -> Encoding

Show DAlt Source # 
Instance details

Defined in IRTS.Defunctionalise

Methods

showsPrec :: Int -> DAlt -> ShowS

show :: DAlt -> String

showList :: [DAlt] -> ShowS

Eq DAlt Source # 
Instance details

Defined in IRTS.Defunctionalise

Methods

(==) :: DAlt -> DAlt -> Bool

(/=) :: DAlt -> DAlt -> Bool

data DDecl Source #

Constructors

DFun Name [Name] DExp 
DConstructor Name Int Int 

Instances

Instances details
ToJSON DDecl 
Instance details

Defined in IRTS.Portable

Methods

toJSON :: DDecl -> Value

toEncoding :: DDecl -> Encoding

toJSONList :: [DDecl] -> Value

toEncodingList :: [DDecl] -> Encoding

Show DDecl Source # 
Instance details

Defined in IRTS.Defunctionalise

Methods

showsPrec :: Int -> DDecl -> ShowS

show :: DDecl -> String

showList :: [DDecl] -> ShowS

Eq DDecl Source # 
Instance details

Defined in IRTS.Defunctionalise

Methods

(==) :: DDecl -> DDecl -> Bool

(/=) :: DDecl -> DDecl -> Bool

data EvalApply a Source #

Constructors

EvalCase (Name -> a) 
ApplyCase a 
Apply2Case a 

addApps :: LDefs -> (Name, LDecl) -> State ([Name], [(Name, Int)]) (Name, DDecl) Source #

toCons :: [Name] -> (Name, Int) -> [(Name, Int, EvalApply DAlt)] Source #

getFn :: [(Name, LDecl)] -> [(Name, Int)] Source #

toConsA :: [(Name, Int)] -> (Name, Int) -> [(Name, Int, EvalApply DAlt)] Source #

mkEval :: [(Name, Int, EvalApply DAlt)] -> (Name, DDecl) Source #

declare :: Int -> [(Name, Int, EvalApply DAlt)] -> [(Name, DDecl)] Source #

mkUnderCon :: Name -> Int -> Name Source #

mkFnCon :: Show a => a -> Name Source #

genArgs :: Int -> [Name] Source #

mkApplyCase :: Name -> Int -> Int -> [(Name, Int, EvalApply DAlt)] Source #

mkBigCase :: p -> Int -> DExp -> [DAlt] -> DExp Source #

Divide up a large case expression so that each has a maximum of max branches

groupsOf :: Int -> [DAlt] -> [[DAlt]] Source #

dumpDefuns :: DDefs -> String Source #

module IRTS.Lang