Module ICurry.Interpreter

Author
Michael Hanus, Sascha Ecks
Version
October 2022

A simple interpreter for ICurry based on the a small-step semantics.

The following invariants are required for ICurry programs:

  1. No nested case expression
  2. If there is a case expression, it is on some argument and the argument index is contained in the demand information of the function.

Exported Datatypes


data IOptions

Constructors:


type FingerPrint = [(ChoiceID, Int)]
data Control

Constructors:

Known instances:


type IEnv = [(IVarIndex, NodeID)]
data Task

Constructors:

Known instances:


data State

Constructors:

Known instances:


Exported Functions


defOpts :: IOptions  Deterministic 


withGraph :: IOptions -> Int  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

lookupInEnv :: Int -> [(Int, Int)] -> Int  Deterministic 


updateEnv :: [(Int, Int)] -> Int -> Int -> [(Int, Int)]  Deterministic 


rootOfTask :: Task -> Int  Deterministic 

Further infos:
  • partially defined

currentNodeOfTask :: Task -> Int  Deterministic 


initState :: [IFunction] -> Graph -> Int -> State  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

rootsOfState :: State -> [Int]  Deterministic 


showResults :: State -> String  Deterministic 


addResult :: Int -> State -> State  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

addTGState :: ICOptions -> State -> [State] -> [State]  Deterministic 


printState :: IOptions -> State -> IO ()  Deterministic 


askProceed :: IOptions -> IO Bool  Deterministic 


execProg :: IOptions -> String -> String -> IO [State]  Non-deterministic 


execIProg :: IOptions -> IProg -> String -> IO [State]  Deterministic 


runWith :: IOptions -> State -> [State] -> IO (IOptions, [State])  Deterministic 

Further infos:
  • partially defined

evalFun :: IProg -> String -> [String]  Deterministic 


step :: State -> State  Deterministic 


evalFirstTask :: State -> [Task] -> State  Deterministic 


invokeFunction :: State -> [Task] -> State  Deterministic 


evalExternal :: Graph -> String -> [Int] -> Node  Deterministic 


lookupIntNode :: Int -> Graph -> Int  Deterministic 


selectConsBranch :: Node -> [IConsBranch] -> IBlock  Deterministic 


selectLitBranch :: Node -> [ILitBranch] -> IBlock  Deterministic 


addVarDecls :: Graph -> [(Int, Int)] -> [IVarDecl] -> (Graph, [(Int, Int)])  Deterministic 


addAssigns :: Graph -> [(Int, Int)] -> [IAssign] -> (Graph, [(Int, Int)])  Deterministic 


replaceNodeArg :: Graph -> Int -> Int -> Int -> Graph  Deterministic 


followPath :: Graph -> Int -> [Int] -> Int  Deterministic 


extendGraph :: Graph -> [(Int, Int)] -> IExpr -> (Graph, Either Int Node)  Deterministic 

Further infos:
  • partially defined

extendGraphL :: Graph -> [(Int, Int)] -> [IExpr] -> (Graph, [Int])  Deterministic 


showILit :: ILiteral -> String  Deterministic 


funcOf :: String -> [IFunction] -> IFunction  Deterministic 


arityOf :: String -> [IFunction] -> Int  Deterministic 


bodyOf :: String -> [IFunction] -> IFuncBody  Deterministic 


demandOf :: String -> [IFunction] -> Maybe Int  Deterministic 


choiceOfDemand :: State -> Int -> Maybe IExpr  Deterministic 


funApply :: IFunction  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

funSeq :: IFunction  Deterministic 


funDollarBang :: IFunction  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

funDollarDollarBang :: IFunction  Deterministic 


funDollarHash :: IFunction  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

funNormalForm :: IFunction  Deterministic 

Further infos:
  • solution complete, i.e., able to compute all solutions

standardFuncs :: [IFunction]  Deterministic