[Haskell-cafe] Language semantics

Jon Cast jcast at ou.edu
Wed Jun 27 22:58:17 EDT 2007


On Wednesday 27 June 2007, you wrote:
> Andrew: Try using catchalls in your guards
>
>
> pattern1
>
> | guard1 =
> | guard2 =
> | otherwise =
>
> This makes it much easier to use pattern guards.
> "otherwise" is a reserved word used for this stuff in ghc.

Since we're quoting the standard and all, my inner pedant can't help but 
quibble: otherwise is not a keyword, it's a synonym for True defined in the 
Standard Prelude (and, in particular, goes away if you say import Prelude 
()):

$ cat > Foo.hs
import Prelude

main = print otherwise
$ ghc Foo.hs -o foo
$ ./foo
True
$ cat > Foo.hs
import Prelude (print)

main = print otherwise
$ ghc Foo.hs -o foo

Foo.hs:3:13: Not in scope: `otherwise'


Sincerely,
Jonathan Cast
Computer Programmer
http://sourceforge.net/projects/fid-core
http://sourceforge.net/projects/fid-emacs


More information about the Haskell-Cafe mailing list