empty case, empty definitions

Neil Mitchell ndmitchell at gmail.com
Fri Aug 15 14:41:21 EDT 2008


> 1. Allow empty case, i.e. "case some_variable of { }" (GHC ticket [1]).
>  This adds consistency, it always causes a pattern-match error, and it is a
> sensible way to look at all the cases of types with no constructors (recall
> EmptyDataDecls will probably be in Haskell' [4]) -- especially for automatic
> tools (or programmers familiar with dependent types; GADTs have some of
> these effects :-)). Presumably, any time that some_variable could be
> non-bottom, GHC will warn about the incomplete patterns :-).

Sounds good. Great for consistency and auto-generation of code.

> 2. When a type signature for a function is given, allow to not define any
> patterns (GHC ticket [2]).  The result of calling the function is a pattern
> match failure (presumably the source-location given for the match failure
> will be the location of the type-signature).  This can also be useful for
> calling functions before implementing them, helping the type-checker help me
> do incremental work (again, obviously produces a warning if the function
> could possibly be non-bottom).

Sounds bad. Consider:

gray :: Color
grey = newColor "#ccc"

This fairly common style of bug now becomes perfectly valid Haskell,
and if you always refer to "grey", you may never even have a clue that
the bug is present.



More information about the Haskell-prime mailing list