I have a data type:
data Instr = LOADI Val| LOAD Val| ADD Val| STORE Val | JMP Val| JMPLESS Val| JMPGE Val deriving (Eq, Read, Show) and a function iexec that takes an instruction and a configuration to perform a process and returns the new configuration.
iexec :: Instr -> Config -> Config where Config is defined as: type Config = (Int, [*], [*]) An example is LOADI which takes value Val (an Integer) and loads it onto a stack, with the config argument giving the information on the stack. It would look something like this in GHCI:
>iexec (LOADI 5) (0, empty, []) > (1, fromList[], [5]) where the program counter increases to 1, and 5 is added to the stack (I'm not sure what the fromList[] means, any explanation for that would be appreciated). I'm also not sure if my config type declaration is correct.
How would I finish the iexec function to allow this to work? Anything to point me in the right direction would be appreciated. Thank you.
1is the "program counter? and the third one is the stack, but it is unclear what the second item does.