Haskell is known for its very strong static type checking, which eliminates a lot of runtime errors.

 

But the following simple program crashes at runtime:

 

data D = A | B

f A = True

main = print (f B)

 

I understand this has nothing to do with type checking, but why can’t the compiler give a warning about this? Or is this by design or because it is impossible to check with more complex recursive data types?

 

Thanks,

Peter