On Sat, Feb 27, 2010 at 05:08:18PM -0800, zaxis wrote:
> Then can i change it to :
> case timeout of
>         Just str -> do
>             [(t, _)] <- reads str
>             addTimeout t (hPutStrLn stderr "*** TIMEOUT" >> _exit 1)
>             return ()
>         _ -> return ()

No, that's different.  You could change it to:

case timeout of
  Just str -> case reads str of
    [(t, _)] -> do addTimeout t (hPutStrLn stderr "*** TIMEOUT" >> _exit 1)
                   return ()
    _        -> other -- (1)
  _        -> other -- (2)
where other = return ()

The cases (1) and (2) are the same and simulate the fact that
when the pattern guard fails, then execution falls to the next
case.

Of course you could just write

case fmap (reads str) timeout of
  Just [(t, _)] -> ...
  _             -> ...

HTH,

--
Felipe.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to