Tue Apr 3 12:52:25 CEST 2012
Imperative programming in Haskell
So I'm kind of fed up with this inability to express imperative
algorithms in Haskell. Let's go for it.
1. collection of nodes -> Set STRef
2. collection of equations bound to nodes -> [STRef]
For specification we don't need to use String as node names; all can
be embedded in a monad such that lexical names can be used for nodes.
[n1,n2,...] <- makeNodes n
eq1 <- newEq [n1,n2,...]
eq2 <- newEq [n1,n2,...]
input n1 v1 -- (*)
input n2 v2 -- (*)
return $ values [n1,n2, ...]
MAIN IDEA: The part marked (*) is what we'd like to change easily (in
the code) without having to change all the other code.