-- case expression 和 patterm matching
head' :: [a] -> a
head' [] = error "Empty lists"
head' (x: _) = x

headcase' :: [a] -> a
headcase' xs = case xs of [] -> error "empty lists"
                          (x: _) -> x

--  case vs pattern-matching
describeList :: [a] -> String
describeList xs = "The list is " ++ case xs of [] -> "empty."
                                              [x] -> "a singleton list."
                                              xs  -> "a longer list."

describeList' :: [a] -> String
describeList' xs = "The list is " ++ what xs
    where what [] = "empty."
          what [x] = "a singleton list"
          what xs = "a longer list."
