Jose A. Lopes | 12 Jul 13:45 2013
Picon

Reify type

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
Michael Sloan | 12 Jul 14:07 2013
Picon

Re: Reify type

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

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 <at> 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 <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Jose A. Lopes | 12 Jul 14:17 2013
Picon

Re: Reify type

That's exactly what I mean!
I'll give it a try.

Thanks Michael,
Jose
Jose A. Lopes | 12 Jul 14:49 2013
Picon

Re: Reify type

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
Michael Sloan | 12 Jul 15:08 2013
Picon

Re: Reify type

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 <at> 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

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane