[Haskell-cafe] Re: Patter matching beginner question
Tom Pledger
tom at pledger.gen.nz
Mon Dec 17 05:12:43 EST 2007
Adam Smyczek <adam.smyczek <at> gmail.com> writes:
[...]
> But when I extract a and b to constants:
>
> c_a = "a" :: String
> c_b = "b" :: String
>
> case name of
> c_a -> ...
> c_b -> ...
> I get Patterns match(es) are overlapped.
Do you require 'name' and the constants to be of type String?
If not, you could get around the issue Brandon described by declaring a data
type for them:
data Name = A | B
...
case name of
A -> ...
B -> ...
The type system would then prevent A and B from being used in places where a
String is expected. This may be an advantage, depending on the style of the
rest of the program.
Regards,
Tom
More information about the Haskell-Cafe
mailing list