Module ICurry.Interpreter

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.

Author: Michael Hanus

Version: July 2021

Summary of exported operations:

defOpts :: IOptions  Deterministic 
withGraph :: IOptions -> Int  Deterministic 
lookupInEnv :: Int -> [(Int,Int)] -> Int  Deterministic 
updateEnv :: [(Int,Int)] -> Int -> Int -> [(Int,Int)]  Deterministic 
rootOfTask :: Task -> Int  Deterministic 
currentNodeOfTask :: Task -> Int  Deterministic 
initState :: [IFunction] -> Graph -> Int -> State  Deterministic 
rootsOfState :: State -> [Int]  Deterministic 
showResults :: State -> String  Deterministic 
addResult :: Int -> State -> State  Deterministic 
printState :: IOptions -> State -> IO ()  Deterministic 
askProceed :: IOptions -> IO Bool  Deterministic 
execProg :: IOptions -> String -> String -> IO ()  Non-deterministic 
execIProg :: IOptions -> IProg -> String -> IO ()  Deterministic 
runWith :: IOptions -> State -> IO IOptions  Deterministic 
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 
extendGraphL :: Graph -> [(Int,Int)] -> [IExpr] -> (Graph,[Int])  Deterministic 
showILit :: ILiteral -> String  Deterministic 
funcOf :: String -> [IFunction] -> IFunction  Deterministic 
bodyOf :: String -> [IFunction] -> IFuncBody  Deterministic 
demandOf :: String -> [IFunction] -> Maybe Int  Deterministic 
choiceOfDemand :: State -> Int -> Maybe IExpr  Deterministic 
funApply :: IFunction  Deterministic 
funSeq :: IFunction  Deterministic 
funDollarBang :: IFunction  Deterministic 
funDollarDollarBang :: IFunction  Deterministic 
funDollarHash :: IFunction  Deterministic 
funNormalForm :: IFunction  Deterministic 
standardFuncs :: [IFunction]  Deterministic 

Exported datatypes:


IOptions

Constructors:

  • IOptions :: ICOptions -> Bool -> Int -> Int -> IOptions

    Fields:

    • icOptions :: ICOptions
    • showAllExps :: Bool
    • waitTime :: Int
    • stepNum :: Int

FingerPrint

Type synonym: FingerPrint = [(ChoiceID,Int)]


Control

Constructors:


IEnv

Type synonym: IEnv = [(IVarIndex,NodeID)]


Task

Constructors:


State

Constructors:


Exported operations:

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 

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

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

askProceed :: IOptions -> IO Bool  Deterministic 

execProg :: IOptions -> String -> String -> IO ()  Non-deterministic 

execIProg :: IOptions -> IProg -> String -> IO ()  Deterministic 

runWith :: IOptions -> State -> IO IOptions  Deterministic 

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 

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 

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

showILit :: ILiteral -> String  Deterministic 

funcOf :: String -> [IFunction] -> IFunction  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

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