Let's say I have:
data T0
data T1
data T a where
A :: T T0
B :: T T1
Then I can write the following without getting any non-exhaustive
pattern match warnings:
t :: T T0 - String
t a = case a of
A - A
However, if I use type classes to constrain the constructors, instead
of using the
Type classes are open, so nothing prevents someone from adding an
instance 'C0 T1' and calling 't' with constructor 'B', causing a crash
due to the missing pattern.
Erik
On Thu, Jan 12, 2012 at 21:40, Tom Hawkins tomahawk...@gmail.com wrote:
Let's say I have:
data T0
data T1
data T a where
Type classes are inherently open. The compiler uses only the facts that there
ARE some instances of the classes it needs, but it doesn't attempt to use
information that some types AREN'T instances of certain classes. So, it can't
use information that T0 isn't an instance of C1. And that's right