Hello everyone, Is there a way to automatically reify a type ? In other words, to do the following: reifyType (LitT ...) = ConT ''LitT ... I am using Template Haskell and I want the generated code to have access to Type datatypes that were available to the Template Haskell code. Cheers, Jose
Hello! I'm not sure if this is what you're asking for, as it doesn't fit that line of code. 'LitT' is a data constructor not a type constructor. So instead it'd be reifyType (LitT ...) = ConE 'LitT ... If this is what you're looking for, then 'lift' is what you want: http://hackage.haskell.org/packages/archive/th-lift/latest/doc/html/Language-Haskell-TH-Lift.html<http://hackage.haskell.org/packages/archive/th-lift/0.5.5/doc/html/Language-Haskell-TH-Lift.html> In particular, I recommend using this package of template haskell orphans, rather than deriving your own: http://hackage.haskell.org/package/th-orphans Hope that helps! -Michael On Fri, Jul 12, 2013 at 4:45 AM, Jose A. Lopes <jabolopes@google.com> wrote:
Hello everyone,
Is there a way to automatically reify a type ? In other words, to do the following:
reifyType (LitT ...) = ConT ''LitT ...
I am using Template Haskell and I want the generated code to have access to Type datatypes that were available to the Template Haskell code.
Cheers, Jose
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Hello, I am getting the following error message: No instance for (Lift Type) arising from a use of `lift' Possible fix: add an instance declaration for (Lift Type) I have imported Language.Haskell.TH.Instances. Is there anything else I have to do ? Regards, Jose
You might need to cabal update - I recently uploaded a new version to hackage, because I realized the package was a bit out of date from the github repo. It works for me: https://gist.github.com/mgsloan/f9238b2272df43e53896 On Fri, Jul 12, 2013 at 5:49 AM, Jose A. Lopes <jabolopes@google.com> wrote:
Hello,
I am getting the following error message:
No instance for (Lift Type) arising from a use of `lift' Possible fix: add an instance declaration for (Lift Type)
I have imported Language.Haskell.TH.Instances. Is there anything else I have to do ?
Regards, Jose
participants (2)
-
Jose A. Lopes -
Michael Sloan