3 ms·
> Actually, I kind of wish IO was split up a bit... I have been meaning to play with rolling some typeclasses (with an IO instance and a testing instance) that
by blaenk 14y ago
> Actually, I kind of wish IO was split up a bit... I have been meaning to play with rolling some typeclasses (with an IO instance and a testing instance) that wrap up IO of various types, so I define my functions in terms of these and spot what kind of IO various functions might do - I'm not yet sure how much of a win it will be, but it seems like something to explore.
There's a section on this practice in Real World Haskell: http://book.realworldhaskell.org/read/programming-with-monads.html#id648782 http://book.realworldhaskell.org/read/programming-with-monad...
- dllthomas 14y agoRight, that's very much what I had in mind - I might very well have got it from there and forgotten; I've read much if not all of RWH at one point or another. I would point out that in addition to the mentioned testing use (itself not to be underestimated - QuickCheck is amazing and making more things tractable to QuickCheck is great), there's also some other big potential wins. If I have a function that deals with local files in a monad that's an instance of MonadHandle, I can write an instance for a RemoteIO type that performs file operations on a remote system through a network connection, and suddenly the function that was local also works remotely.
- tel 14y agoOH! That's where I saw it. I couldn't remember, but I know the idea has been floating around for a long while.