[haskell-art] OpenSoundControl/Transport - a custom monad class

Henning Thielemann lemming at henning-thielemann.de
Fri Jan 23 20:36:33 GMT 2009


On Thu, 25 Dec 2008, Henning Thielemann wrote:

> Recently I stumpled about nearly the same issue in the HTTP package.
> There I had an idea, which can be applied to hosc, too:
>
> class Monad m => Transporter m where
>   send :: OSC -> m ()
>   recv :: m OSC
>   close :: m ()
>
> instance (Transport t, MonadIO io) => Transporter (ReaderT t io) where
>   send osc = ask >>= \t -> lift (liftIO (Transport.send t osc))
>   ...
>
> data Offline a = Offline (Writer ByteString a)
>
> instance Transporter Offline where
>   send osc = Offline (tell osc)
>   ...

I have implemented that idea in:
    http://hackage.haskell.org/cgi-bin/hackage-scripts/package/opensoundcontrol-ht


More information about the haskell-art mailing list