On Thu, 11 Mar 2021, Richard Eisenberg wrote:
You're right that these features sit in a similar space. The difference is that, with a pattern synonym, the required context might be useful. This is because pattern synonyms can perform computation (via view patterns), and this computation might plausibly require some class constraint. An easy example: pattern Positive :: (Ord a, Num a) => a pattern Positive <- ((>0) -> True)
Heck, even just pattern matching on `0` (no view patterns) Requires the scrutinee to be both `Num` and `Eq`. To see why, ponder the inferred type of the following function:
``` foo 0 = True foo _ = False ``` _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users