STM check/MonadPlus

Remi Turk rturk at
Sun Feb 6 15:25:18 EST 2005


I have a few questions about the `check' function from

First, in the paper its definition contains a (type) error:

check :: Bool -> STM a
check True  = return ()
check False = retry

in fptools, however, it is defined as follows:

check :: Bool -> STM a
check b = if b then return undefined else retry

As we already have guard, and STM is an instance of MonadPlus,
I wonder why such a simple utility function as check is wanted
at all.

guard           :: (MonadPlus m) => Bool -> m ()
guard True      =  return ()
guard False     =  mzero


Nobody can be exactly like me. Even I have trouble doing it.

More information about the Glasgow-haskell-users mailing list