Why is GHC complaining about non-exhaustive patterns?

后端 未结 3 1300
梦如初夏
梦如初夏 2020-12-10 10:19

When I compile the following code with GHC (using the -Wall flag):

module Main where

data Tree a = EmptyTree | Node a (Tree a) (Tree a) derivin         


        
3条回答
  •  时光取名叫无心
    2020-12-10 11:09

    It's because the pattern matching is incomplete. There's no guarantee that one of x==a, x, or x>a holds. For instance, if the type is Double and x is NaN then none of them are True.

提交回复
热议问题