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, Sascha Ecks

Version: October 2022

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

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 

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

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