idris-1.0: Functional Programming Language with Dependent Types

CopyrightLicense : BSD3
MaintainerThe Idris Community.
Safe HaskellNone
LanguageHaskell98

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 DAlt #

Instances

Eq DAlt # 

Methods

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

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

Show DAlt # 

Methods

showsPrec :: Int -> DAlt -> ShowS #

show :: DAlt -> String #

showList :: [DAlt] -> ShowS #

data DDecl #

Instances

Eq DDecl # 

Methods

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

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

Show DDecl # 

Methods

showsPrec :: Int -> DDecl -> ShowS #

show :: DDecl -> String #

showList :: [DDecl] -> ShowS #

type DDefs = Ctxt DDecl #

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

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

data EvalApply a #

Constructors

EvalCase (Name -> a) 
ApplyCase a 
Apply2Case a 

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

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

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

genArgs :: Int -> [Name] #

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

mkBigCase :: t -> Int -> DExp -> [DAlt] -> DExp #

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

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

module IRTS.Lang