Re: [Haskell-cafe] generating Maybe

2007-11-07 Thread Yitzchak Gale
guarded = liftM2 ((>>) . guard) toMaybe = (. return) . (>>) . guard Regards, lambdabot :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] generating Maybe

2007-11-07 Thread Henning Thielemann
On Thu, 8 Nov 2007, Stuart Cook wrote: > On 11/8/07, Tim Newsham <[EMAIL PROTECTED]> wrote: > > Data.Maybe has functions for processing Maybe's but nothing useful > > for creating maybe. I think the following would be a very useful > > addition, a guarded function: > > > > guarded :: (a ->

Re: [Haskell-cafe] generating Maybe

2007-11-07 Thread Henning Thielemann
On Wed, 7 Nov 2007, Tim Newsham wrote: > Data.Maybe has functions for processing Maybe's but nothing useful > for creating maybe. I think the following would be a very useful > addition, a guarded function: > > guarded :: (a -> Bool) -> (a -> b) -> a -> Maybe b > guarded p f x | p x

Re: [Haskell-cafe] generating Maybe

2007-11-07 Thread Stuart Cook
On 11/8/07, Tim Newsham <[EMAIL PROTECTED]> wrote: > Data.Maybe has functions for processing Maybe's but nothing useful > for creating maybe. I think the following would be a very useful > addition, a guarded function: > > guarded :: (a -> Bool) -> (a -> b) -> a -> Maybe b > guarded p f

Re: [Haskell-cafe] generating Maybe

2007-11-07 Thread Jonathan Cast
On 7 Nov 2007, at 12:40 PM, Tim Newsham wrote: Data.Maybe has functions for processing Maybe's but nothing useful for creating maybe. I think the following would be a very useful addition, a guarded function: guarded :: (a -> Bool) -> (a -> b) -> a -> Maybe b guarded p f x | p x

[Haskell-cafe] generating Maybe

2007-11-07 Thread Tim Newsham
Data.Maybe has functions for processing Maybe's but nothing useful for creating maybe. I think the following would be a very useful addition, a guarded function: guarded :: (a -> Bool) -> (a -> b) -> a -> Maybe b guarded p f x | p x = Just (f x) | otherwise = Noth