How to examine a quoted data constructor name in Template Haskell?
问题 I'm trying to learn some Template Haskell. As an exercise, I wrote a function that can generate things like isLeft and isRight (inspired by this question). Here's my humble attempt: isA connam = do ConE nam <- connam nn <- newName "p" lamE [varP nn] $ caseE (varE nn) [ match (conP nam [wildP]) ( normalB [| True |] ) [], match wildP ( normalB [| False |] ) [] ] The problem is that it only works with one-argument constructors. The culprit is the conP nam [wildP] pattern. Ideally, it should look