reifyDecl and reifyType not working

View: New views
8 Messages — Rating Filter:   Alert me  

reifyDecl and reifyType not working

by Wolfgang Jeltsch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

reifyDecl and reifyType seem to be recognized as identifiers and not as part
of TH syntax by GHC 6.7.20070903.  Take, for example, the following code:

    {-# LANGUAGE TemplateHaskell #-}

    x = reifyDecl ()

If I compile this (with or without -fth), I get the error message “Not in
scope: `reifyDecl'”.  What’s wrong here?

Best wishes,
Wolfgang
_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell

RE: reifyDecl and reifyType not working

by Simon Peyton-Jones :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

'reifyDecl' is not a language construct; it's a function.  You need to import Language.Haskell.TH to bring it into scope.

If the user manual suggests otherwise, could you suggest improved wording?

Simon

| -----Original Message-----
| From: template-haskell-bounces@... [mailto:template-haskell-bounces@...] On Behalf Of
| Wolfgang Jeltsch
| Sent: 08 September 2007 23:27
| To: template-haskell@...
| Subject: [Template-haskell] reifyDecl and reifyType not working
|
| Hello,
|
| reifyDecl and reifyType seem to be recognized as identifiers and not as part
| of TH syntax by GHC 6.7.20070903.  Take, for example, the following code:
|
|     {-# LANGUAGE TemplateHaskell #-}
|
|     x = reifyDecl ()
|
| If I compile this (with or without -fth), I get the error message “Not in
| scope: `reifyDecl'”.  What’s wrong here?
|
| Best wishes,
| Wolfgang
| _______________________________________________
| template-haskell mailing list
| template-haskell@...
| http://www.haskell.org/mailman/listinfo/template-haskell

_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell

Re: reifyDecl and reifyType not working

by Ian Lynagh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Sep 10, 2007 at 08:59:45AM +0100, Simon Peyton-Jones wrote:
> 'reifyDecl' is not a language construct; it's a function.  You need to import Language.Haskell.TH to bring it into scope.

It's also just called reify these days.


Thanks
Ian

_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell

Re: reifyDecl and reifyType not working

by Wolfgang Jeltsch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Montag, 10. September 2007 14:18 schrieb Ian Lynagh:
> On Mon, Sep 10, 2007 at 08:59:45AM +0100, Simon Peyton-Jones wrote:
> > 'reifyDecl' is not a language construct; it's a function.  You need to
> > import Language.Haskell.TH to bring it into scope.
>
> It's also just called reify these days.

This is not what the GHC User’s Guide talks about when discussing reifyDecl
and reifyType.  In an expression reifyDecl A, A has to be a type constructor
or a class, and in an expression reifyType a, a has to be an identifier.  So
reifyDecl and reifyType cannot be functions but must be language constructs.  
On the other hand, reify expects a value of type Name as an argument.

The problem is that I wanted to use reifyDecl as a workaround to create values
of type Name.  The Template Haskell library doesn’t seem to provide a way to
create a Name value which always refers to the same entity, regardless of the
splice where it is used.  So I wanted to use workarounds like this:

    className :: Name
    ClassD _ className _ _ _ = reifyDecl Class

Best wishes,
Wolfgang
_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell

Re: reifyDecl and reifyType not working

by Ian Lynagh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Sep 10, 2007 at 06:57:09PM +0200, Wolfgang Jeltsch wrote:

> Am Montag, 10. September 2007 14:18 schrieb Ian Lynagh:
> > On Mon, Sep 10, 2007 at 08:59:45AM +0100, Simon Peyton-Jones wrote:
> > > 'reifyDecl' is not a language construct; it's a function.  You need to
> > > import Language.Haskell.TH to bring it into scope.
> >
> > It's also just called reify these days.
>
> of type Name.  The Template Haskell library doesn’t seem to provide a way to
> create a Name value which always refers to the same entity, regardless of the
> splice where it is used.  So I wanted to use workarounds like this:
>
>     className :: Name
>     ClassD _ className _ _ _ = reifyDecl Class

You can get names with the ' and '' syntax:

$ ghci -fth
Prelude> ''Eq
GHC.Base.Eq
Prelude> 'id
GHC.Base.id


Thanks
Ian

_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell

Re: reifyDecl and reifyType not working

by Wolfgang Jeltsch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Am Montag, 10. September 2007 22:13 schrieb Ian Lynagh:

> On Mon, Sep 10, 2007 at 06:57:09PM +0200, Wolfgang Jeltsch wrote:
> > Am Montag, 10. September 2007 14:18 schrieb Ian Lynagh:
> > > On Mon, Sep 10, 2007 at 08:59:45AM +0100, Simon Peyton-Jones wrote:
> > > > 'reifyDecl' is not a language construct; it's a function.  You need
> > > > to import Language.Haskell.TH to bring it into scope.
> > >
> > > It's also just called reify these days.
> >
> > of type Name.  The Template Haskell library doesn’t seem to provide a way
> > to create a Name value which always refers to the same entity, regardless
> > of the splice where it is used.  So I wanted to use workarounds like
> > this:
> >
> >     className :: Name
> >     ClassD _ className _ _ _ = reifyDecl Class
>
> You can get names with the ' and '' syntax:

Oh, I didn’t know about this syntax.  Is this documented somewhere?

>[…]

Best wishes,
Wolfgang
_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell

Re[2]: reifyDecl and reifyType not working

by Bulat Ziganshin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Wolfgang,

Tuesday, September 11, 2007, 1:59:15 AM, you wrote:
>> > > > 'reifyDecl' is not a language construct; it's a function.  You need

>> You can get names with the ' and '' syntax:

> Oh, I didn’t know about this syntax.  Is this documented somewhere?

afair, reifyDecl was described in the first TH paper while reify and
'/'' in the second one: http://www.haskell.org/ghc/docs/papers/th2.ps

you may also look at http://www.haskell.org/bz/thdoc.htm (written by me)
which describes whole TH

--
Best regards,
 Bulat                            mailto:Bulat.Ziganshin@...

_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell

RE: Re[2]: reifyDecl and reifyType not working

by Simon Peyton-Jones :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'll improve the documentation too

S

| -----Original Message-----
| From: template-haskell-bounces@... [mailto:template-haskell-bounces@...] On Behalf Of
| Bulat Ziganshin
| Sent: 11 September 2007 07:54
| To: Wolfgang Jeltsch
| Cc: template-haskell@...
| Subject: Re[2]: [Template-haskell] reifyDecl and reifyType not working
|
| Hello Wolfgang,
|
| Tuesday, September 11, 2007, 1:59:15 AM, you wrote:
| >> > > > 'reifyDecl' is not a language construct; it's a function.  You need
|
| >> You can get names with the ' and '' syntax:
|
| > Oh, I didn’t know about this syntax.  Is this documented somewhere?
|
| afair, reifyDecl was described in the first TH paper while reify and
| '/'' in the second one: http://www.haskell.org/ghc/docs/papers/th2.ps
|
| you may also look at http://www.haskell.org/bz/thdoc.htm (written by me)
| which describes whole TH
|
| --
| Best regards,
|  Bulat                            mailto:Bulat.Ziganshin@...
|
| _______________________________________________
| template-haskell mailing list
| template-haskell@...
| http://www.haskell.org/mailman/listinfo/template-haskell

_______________________________________________
template-haskell mailing list
template-haskell@...
http://www.haskell.org/mailman/listinfo/template-haskell
LightInTheBox - Buy quality products at wholesale price