On Thursday 02 July 2009 6:36:09 am Jon Fairbairn wrote:
check :: (MonadPlus m) = (a - Bool) - a - m a
check p a
| p a = return a
| otherwise = mzero
I tried Hoogling for a function like check, but couldn't find it. Surely
there's one in a library somewhere? It looks useful to me.
On Mon, Jul 6, 2009 at 8:49 PM, Dan Doeldan.d...@gmail.com wrote:
I've often noticed the need for a similar function in conjunction with
unfoldr:
-- This is overly general for unfoldr, but it lines up with check
stopAt :: (MonadPlus m) = (a - Bool) - (a - b) - a - m b
stopAt p f x
|
Dan Doel dan.d...@gmail.com writes:
There was talk of adding a readMaybe a while ago, but apparently it
never happened.
As it is, you can use reads, read s becomes:
case reads s of
[(a, rest)] | all isSpace rest - code using a
_ - error case
On Thu, Jul 2, 2009 at 3:36 AM, Jon Fairbairnjon.fairba...@cl.cam.ac.uk wrote:
Dan Doel dan.d...@gmail.com writes:
There was talk of adding a readMaybe a while ago, but apparently it
never happened.
As it is, you can use reads, read s becomes:
case reads s of
[(a, rest)] | all