On 9/17/07, Hugh Perkins
Just out of curiosity, how could one do something like a factory, so that by default a library uses, say, Data.Map, but by making a simple assignment we can switch the library to use a different implementation?
(This is alluded to above, but not explicitly stated. I guess it's too easy, but someone has to ask the newbie questions :-D )
I guess we would need to have some sort of "init" function that returns a state containing our various factories. The user could update the factories with their own factories if they choose. The state would need to be passed into each function call to the library (!) ?
Or maybe one should store the state in a monad, and run everything inside a monad?
Why would you want to do this in Haskell? Please explain in simple language for those of us who haven't been initiated into the secrets of design patterns. Cheers, Tim -- Tim Chevalier * catamorphism.org * Often in error, never in doubt "In fact, a sense of essence is, in essence, the essence of sense, in effect." -- Douglas Hofstadter