[Haskell-cafe] How to call constructor from Template Haskell

Baa aquagnu at gmail.com
Mon Dec 11 12:03:48 UTC 2017


Hello All!
May be topic is not for Haskell beginners, so I'll re-send it to Cafe.


I have function which constructs some data type. It has signature `Name -> Q [Dec]`.
Somewhere in its body I'm extracting constructors of another type with
pattern-matching:

  case tyCons of
    DataD ctx nm tyVars mbKind cs derivs -> ...
 
Type of those constructors `cs` instantiates some class like this:
 
   class MyClass a where
     specialValue :: a
     
So, I'm iterating over those `cs` but I want to skip one of them which is
equal to `specialValue`. Something like this:
 
   [c | c <- cs, c /= specialValue]
 
How to do this with Template Haskell's `Con` type (`c`::Con)? I can't
simply call it to compare created value with a `specialValue`.
 
===
Best regards, Paul



More information about the Haskell-Cafe mailing list