[Haskell-beginners] Implementing a Local Propagation Network
patrick.leboutillier at gmail.com
Mon May 17 20:59:11 EDT 2010
After learning some Haskell recently, I decided to revisit a book
about functional programming techniques for Perl: Higher Order Perl. I
didn't fully understand the book at the time but now my Haskell
experience has proved to be very insightful.
Towards the end of the book the author implements a local propagation network.
Here is the Perl source code:
The PDF of the specific chapter is here:
I would like to experiment with something similar in Haskell, but the
way this network is designed is all about state and references:
- Wires have a values that can change over time;
- Wires have references to nodes;
- Nodes have references to wires;
I'm a bit stuck as to how to approach the "object has a list
references to other objects" situation from Haskell. I tried this:
type Name = String
data Node = Node Name [Wire]
data Wire = Wire Name Node Double [Node]
But that doesn't seem like it would work since when I change a Wire I
must find all "copies" of it (in the Node objects) and update them
also. Perhaps I should just refer to Wires/Nodes by name and use an
association list to lookup them up, but that seems cumbersome.
Anybody have any suggestions?
Thanks a lot,
Rosemère, Québec, Canada
More information about the Beginners