Well, ‘n is really a splice (of a limited sort), and we don’t allow splices in patterns (for good reasons). The good reasons don’t really apply to patterns
that bind nothing, like in this case.
My sense is that it would make sense to include this idea as part of the overhaul of TH that is sketch at
http://hackage.haskell.org/trac/ghc/blog/Template%20Haskell%20Proposal
Trouble is, I am failing to make any progress on implementing the ideas there. Help welcomed.
Simon
From: libraries-bounces@haskell.org [mailto:libraries-bounces@haskell.org]
On Behalf Of Conal Elliott
Sent: 24 January 2012 05:59
To: libraries
Subject: Template Haskell: 'foo in patterns?
If I understand correctly, 'foo, of type Name, is a constant value in any given context. And yet it doesn't appear to be allowed in patterns, thus leading to awkwardly explicit use of variables and equality guards in otherwise pattern-matching
code. Are there reasons not to allow 'foo in patterns?
-- Conal