Re: [Haskell-cafe] Generalizing IO

2009-10-06 Thread Floptical Logic
> class StreamMonad m where >        fetchLine = m >        sendLine = String -> m () > > instance StreamMonad IO where >        fetchLine = getLine >        sendLine = putLine > > fetchLineFromStream = lift fetchLine > sendLineToStream = lift . sendLine This approach makes more sense to me. The

Re: [Haskell-cafe] Generalizing IO

2009-10-05 Thread Floptical Logic
> Instead of specifying the monad implementation, specify the interface. > That is, you are using state operations (from MonadState) and IO > operations (from MonadIO). Try removing all the type signatures that > mention PDState and see what you get. > > E.g., loop :: (MonadState PD m, MonadIO m) =

[Haskell-cafe] Generalizing IO

2009-10-05 Thread Floptical Logic
The code below is a little interactive program that uses some state. It uses StateT with IO to keep state. My question is: what is the best way to generalize this program to work with any IO-like monad/medium? For example, I would like the program to function as it does now using stdin but I woul