Comment Comment by Peaker The content of Fun is actually the type: Context -> Value -> (Context, Value).If you flip the arguments, you get: Value -> Context -> (Context, Value). The (Context -> (Context, Value)) is actually the State type: State s a = s -> (s, a) I modified your code to use this type. During the process, I encountered some peculiar things (and factored out some things), see comments in code.https://gist.github.com/950445Funny that it turns out slightly longer when re-using more code due to syntactic artifacts. Monad comprehensions (recently restored to GHC via an extension) would resolve that. parent Peaker 15 years ago
If you flip the arguments, you get: Value -> Context -> (Context, Value). The (Context -> (Context, Value)) is actually the State type:
I modified your code to use this type. During the process, I encountered some peculiar things (and factored out some things), see comments in code.https://gist.github.com/950445
Funny that it turns out slightly longer when re-using more code due to syntactic artifacts. Monad comprehensions (recently restored to GHC via an extension) would resolve that.