On Wed, 30 Jan 2002, Kevin Glynn wrote:
I think the Haskell Wiki was going to be the place to collect
interesting code fragments.
However, I must add that these functions are already part of the
Haskell 98 standard. See the Monad module in the Library Report.
Ah, cool, both points sound
In the following code, will other things be executed or the return ()
will end function f? I guess the answer is yes (other things WILL be
executed anyway), but I'd like to understand why won't the return () be
the [state change/result produced] created by f.
f :: IO ()
f = do
-- lots of
In the following code, will other things be executed or the return ()
will end function f? I guess the answer is yes (other things WILL be
executed anyway), but I'd like to understand why won't the return () be
the [state change/result produced] created by f.
f :: IO ()
f = do
--
Hi again,
Forgot to mention this in my last email. I find myself writing a lot
of if-then-elses in do notation, and most often the else branch is return ().
This gets a bit cumbersome to write and messes up the code.
So now I tend to use:
doIf :: Monad a = Bool - [a b] - a ()
doIf b e =
On 29-Jan-2002, Andre W B Furtado [EMAIL PROTECTED] wrote:
In the following code, will other things be executed or the return ()
will end function f? I guess the answer is yes (other things WILL be
executed anyway), but I'd like to understand why won't the return () be
the [state
Forgot to mention this in my last email. I find myself writing a lot
of if-then-elses in do notation, and most often the else branch is return ().
This gets a bit cumbersome to write and messes up the code.
There's also the Monad library http://haskell.org/onlinelibrary/monad.html
that
Oops,
Thanks to Kevin who pointed out:
when :: (Monad m) = Bool - m () - m ()
when p s = if p then s else return ()
unless :: (Monad m) = Bool - m () - m ()
unless p s= when (not p) s
So now I tend to use:
doIf :: Monad a = Bool - [a b] - a ()
On Wed, 30 Jan 2002, Bernard James POPE wrote:
(snip)
when :: (Monad m) = Bool - m () - m ()
when p s = if p then s else return ()
unless :: (Monad m) = Bool - m () - m ()
unless p s= when (not p) s
(snip)
That's cute. People post all sorts of handy
I think the Haskell Wiki was going to be the place to collect
interesting code fragments.
However, I must add that these functions are already part of the
Haskell 98 standard. See the Monad module in the Library Report.
cheers
k
Mark Carroll writes:
On Wed, 30 Jan 2002, Bernard James