[Haskell-cafe] How to understand `|` in this code snippet ?
Brandon S. Allbery KF8NH
allbery at ece.cmu.edu
Sat Feb 27 04:29:09 EST 2010
On Feb 27, 2010, at 04:07 , zaxis wrote:
> xxxMain = do
> timeout <- getEnv "xxx_TIMEOUT"
> case timeout of
> Just str | [(t, _)] <- reads str -> do
> addTimeout t (hPutStrLn stderr "*** TIMEOUT" >> _exit 1)
> return ()
> _ -> return ()
> What does the `|` mean in "Just str | [(t, _)] <- reads str" ?
> Is it a logical `or` ?
It's a guard. Same as with function definitions (in fact, function
definitions of that form are converted to case expressions).
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100227/42e42ce6/PGP.bin
More information about the Haskell-Cafe