Hello,
In a recent thread, it has been asserted that defining type class is
something you seldom need when programming in Haskell.
There is one thing that as non-professional Haskell programmer I found
type-classes useful for: Testing. This is probably very OO and is pretty
much influenced by
Is this badly designed code that tries to mimic OO in a functional setting?
If the answer is yes, how could I achieve same result (eg. testing the code
that does command REPL) without defining type classes?
Here's how I do it:
data InteractiveState = InteractiveState {
state_read :: IO
On Tue, Jun 7, 2011 at 10:32 PM, Evan Laforge qdun...@gmail.com wrote:
Is this badly designed code that tries to mimic OO in a functional
setting?
If the answer is yes, how could I achieve same result (eg. testing the
code
that does command REPL) without defining type classes?
Here's
Here's how I do it:
data InteractiveState = InteractiveState {
state_read :: IO Command
, state_write :: Result - IO ()
}
How about :
data InteractiveState io = InteractiveState {
state_read :: io Command
, state_write :: Result - io ()
}
I guess you could, but I like it
On Tue, Jun 7, 2011 at 16:16, Arnaud Bailly arnaud.oq...@gmail.com wrote:
For example, while designing some program (a game...) I defined a type class
thus:
class (Monad io) = CommandIO io where
readCommand :: io Command
writeResult :: CommandResult - io ()
This is in fact one of the
Is this badly designed code that tries to mimic OO in a functional
setting? If the answer is yes, how could I achieve same result (eg. testing
the code that does command REPL) without defining type classes?
Why would that be badly designed? And why would that be more OO? IMO it is a
perfectly
...and the other one being operational (which I find simpler).
2011/6/8 Brandon Allbery allber...@gmail.com
On Tue, Jun 7, 2011 at 16:16, Arnaud Bailly arnaud.oq...@gmail.com
wrote:
For example, while designing some program (a game...) I defined a type
class
thus:
class (Monad io) =