Re: [Haskell-cafe] Properties of monads

2007-11-19 Thread Radosław Grzanka
Hi Benja, Something like the following might feel cleaner, though: maybeT :: Maybe a - MaybeT m a maybeT = MaybeT . return downloadFile :: String - MaybeT IO String downloadFile s = maybeT (parseURI s) = liftIO . httpGet This is even neater. However, I fail to implement this. It does not

Re: [Haskell-cafe] Properties of monads

2007-11-19 Thread Radosław Grzanka
2007/11/19, Ryan Ingram [EMAIL PROTECTED]: I am pretty sure that the constructor MaybeT is exactly what you are looking for. newtype MaybeT m a = MaybeT (m (Maybe a)) therefore MaybeT :: m (Maybe a) - MaybeT m a I swear I tried it. I swear.. Why didn't it worked than and it works now??

[Haskell-cafe] Properties of monads

2007-11-18 Thread Radosław Grzanka
Hello, I am writing some toys programs to learn and try to apply Monads properties (without success, I must say). Although I spent half a day on this code: http://hpaste.org/3957 I couldn't simplify (shorten) getStrip function. After reading Doing it with class (

Re: [Haskell-cafe] Properties of monads

2007-11-18 Thread Radosław Grzanka
Hi Benja, You can find MaybeT here: http://www.haskell.org/haskellwiki/New_monads/MaybeT Thank you, that you spent some time figuring this out. This is exacly what I have expected. (This print was debug leftovers). Now I will try to understand how exacly this works. My big thanks to you

Re: [Haskell-cafe] Properties of monads

2007-11-18 Thread Benja Fallenstein
Hi Radosław, You should be able to write this with MaybeT as follows: getStrip :: IO ( Maybe String ) getStrip = runMaybeT $ do pageContent - liftIO $ downloadFile mainPageAddress let x = patternForStrip pageContent print x z - x liftIO $ downloadFile $ mainPageAddress ++ z

Re: [Haskell-cafe] Properties of monads

2007-11-18 Thread Benja Fallenstein
On 11/18/07, Benja Fallenstein [EMAIL PROTECTED] wrote: Hi Radosław, You should be able to write this with MaybeT as follows: Correction, sorry. The code in my original mail doesn't take care of converting the 'Maybe's returned by the functions you're calling into 'MaybeT's. The following