[Haskell-cafe] Re: Functional version of this OO snippet

Apfelmus, Heinrich apfelmus at quantentunnel.de
Fri Dec 5 10:42:54 EST 2008


Thomas Davie wrote:
>> You don't even need a type class, a simple data type is enough.
> 
> Very true, but I disagree that you've made it functional in any way, IO
> is all about sequencing things, it's very much not a functional style
>>
>>  data Engine = Engine { foo :: IO (), bar :: String -> IO () }
>
> This is much nicer done as functions from String -> String

Sure, I agree. I was just replicating  foo  and  bar  from the OP
because I don't know what kind of effect he had in mind. I mean, instead
of merely mapping each command in isolation, he could want to accumulate
a value or read files or something.


Regards,
H. Apfelmus



More information about the Haskell-Cafe mailing list