johnynek / bosatsu

A python-ish pure and total functional programming language
Apache License 2.0
226 stars 11 forks source link

Reconsider equality checking in patterns #1263

Open johnynek opened 3 days ago

johnynek commented 3 days ago

I've resisted saying that:

match (a, b):
  case (x, x):

Should only match on equality because it seems like I need some magic equality. But it occurs to me the types that can pattern match are already the kinds that often have deep equality.

Generic tuples wouldn't work as in this case but if the things being matched were data all the way down it could work.

That said given that it fails on generics maybe that's the argument not to do it unless we could restrict the generic to being a Data kind, which I have thought about before.