haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] Why is this strict in its arguments?

Subject: Re: [Haskell-cafe] Why is this strict in its arguments?
From: "Ryan Ingram"
Date: Thu, 6 Dec 2007 14:21:28 -0800
On 12/6/07, Luke Palmer <lrpalmer@xxxxxxxxx> wrote:
I have actually seen this pattern a lot recently.  Recently I have
started using a function:

mergeMaybes :: (a -> a -> a) -> Maybe a -> Maybe a -> Maybe a
mergeMaybes f Nothing y = y
mergeMaybes f x Nothing = x
mergeMaybes f (Just x) (Just y) = Just (f x y)
 
mergeMaybes = liftM2 -- from Control.Monad

 
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe
<Prev in Thread] Current Thread [Next in Thread>