2

I am currently trying to figure out in which order Haskell tries to applicate certain functions. If I've got a function call like:

exec:: Stm -> State -> State
exec (Seq s1 s2) = \s -> exec s2 (exec s1 s) 

This is part of a bigger program executing a program where each code fragment could possibly alter the structure of the environment, which keeps track of the current variable assignment. In that case how can I be sure that haskell not accidentally executes the wrong part first? Im asking because if I do this exact line in continuation style, it would look like this:

type Cont = State -> State
exec:: Stm -> Cont -> Cont
exec (Seq s1 s2) = \c -> exec s1 (exec s2 c) 

If haskell executes the inner parts in the brackets first it could probably change the meaning of the progam because it messes up the order. I would really appreciate some help because I cant seem to figure this out by myself.

4

0 回答 0