Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-11 Thread Derek Elkins
On Thu, 2008-04-10 at 11:53 -0700, Adam Smyczek wrote: Thanks a lot for all explanations! It looks like 'ioAction' is the key to the solution and if the Browser module did not provide/expose this function, no IO actions could be run inside the BrowserAction monad? If yes, is this a

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-11 Thread Ryan Ingram
On 4/10/08, Adam Smyczek [EMAIL PROTECTED] wrote: If yes, is this a general concept/pattern how to hide functionality of a underlying monad, in this case hide IO entirely? Yes, that's correct, although with IO you can't hide it entirely; eventually you need a way to actually run the

[Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Adam Smyczek
For a small webapi binding I try to implement a session like monad by building a stack including BrowserAction from Network.Browser module as following: newtype RBAction a = RBAction { exec :: ErrorT String (StateT RBState BrowserAction) a } deriving (Functor, Monad, MonadState RBState)

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Ryan Ingram
Assuming you have ioAction :: IO x - BrowserAction x (from http://homepages.paradise.net.nz/warrickg/haskell/http/#browser) you can do: instance MonadIO BrowserAction where liftIO = ioAction Then you can derive MonadIO with GHC's newtype deriving. Alternatively, you can implement it directly

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Antoine Latter
On Thu, Apr 10, 2008 at 9:50 AM, Adam Smyczek [EMAIL PROTECTED] wrote: For a small webapi binding I try to implement a session like monad by building a stack including BrowserAction from Network.Browser module as following: newtype RBAction a = RBAction { exec :: ErrorT String (StateT

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Antoine Latter
On Thu, Apr 10, 2008 at 12:44 PM, Antoine Latter [EMAIL PROTECTED] wrote: {-# LANGUAGE GeneralizedNewtypeDeriving #-} import Control.Monad.Trans import Control.Monad.State import Control.Monad.Error type BrowserAction = IO -- or something else which is in MondaIO data RBState =

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Judah Jacobson
On Thu, Apr 10, 2008 at 7:50 AM, Adam Smyczek [EMAIL PROTECTED] wrote: For a small webapi binding I try to implement a session like monad by building a stack including BrowserAction from Network.Browser module as following: newtype RBAction a = RBAction { exec :: ErrorT String (StateT

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Adam Smyczek
Thanks a lot for all explanations! It looks like 'ioAction' is the key to the solution and if the Browser module did not provide/expose this function, no IO actions could be run inside the BrowserAction monad? If yes, is this a general concept/pattern how to hide functionality of a underlying

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Luke Palmer
On Thu, Apr 10, 2008 at 2:50 PM, Adam Smyczek [EMAIL PROTECTED] wrote: For a small webapi binding I try to implement a session like monad by building a stack including BrowserAction from Network.Browser module as following: newtype RBAction a = RBAction { exec :: ErrorT String (StateT

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Tillmann Rendel
Adam Smyczek wrote: For a small webapi binding I try to implement a session like monad by building a stack including BrowserAction from Network.Browser module as following: newtype RBAction a = RBAction { exec :: ErrorT String (StateT RBState BrowserAction) a } deriving (Functor, Monad,

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Adam Smyczek
On Apr 10, 2008, at 12:42 PM, Luke Palmer wrote: On Thu, Apr 10, 2008 at 2:50 PM, Adam Smyczek [EMAIL PROTECTED] wrote: For a small webapi binding I try to implement a session like monad by building a stack including BrowserAction from Network.Browser module as following: newtype