Simon Peyton-Jones | 2 Dec 18:20 2004
Picon

RE: Bug? Unique class names...

I've just committed a fix for this.

SImon

| -----Original Message-----
| From: template-haskell-bounces <at> haskell.org
[mailto:template-haskell-bounces <at> haskell.org] On
| Behalf Of Keean Schupke
| Sent: 26 November 2004 11:09
| To: Ian Lynagh
| Cc: template-haskell <at> haskell.org; Simon Peyton-Jones
| Subject: [Template-haskell] Bug? Unique class names...
| 
| Hi,
|     I am trying to generate classes on the fly... as classes may get
| generated more
| than once, I want guaranteed unique names (sounds like a job for
newName)...
| However, whilst the first example works, the second fails:
| 
|  >-- this works
|  >test :: Q [Dec]
|  >test = do
|  >   k <- newName "k"
|  >   c <- classD (cxt []) (mkName "MyClass") [k] [] []
|  >   return [c]
| 
|  >-- this fails
|  >test :: Q [Dec]
|  >test = do
(Continue reading)

Simon Peyton-Jones | 3 Dec 11:40 2004
Picon

RE: template-haskell names in 6.3

Acutally it's there already:
	qCurrentModule :: Q String

Simon

| -----Original Message-----
| From: Keean Schupke [mailto:k.schupke <at> imperial.ac.uk]
| Sent: 02 December 2004 17:37
| To: Simon Peyton-Jones
| Subject: Re: template-haskell names in 6.3
| 
| Simon Peyton-Jones wrote:
| 
| Okay I want a globaly unique label, so I want to prepend the module
name
| to the string...
| 
| module SomeLib.MyModule where
| 
| $(label "myLabel") -- splices: myLabel = "SomeLib.MyModule.myLabel"
| 
| I guess what I want is a reifyModuleName?
| 
|     Keean.
| 
| >| -----Original Message-----
| >| From: MR K P SCHUPKE [mailto:k.schupke <at> imperial.ac.uk]
| >| Sent: 22 October 2004 13:05
| >| To: glasgow-haskell-users <at> haskell.org; Simon Peyton-Jones
| >| Subject: template-haskell names in 6.3
(Continue reading)

Keean Schupke | 3 Dec 11:59 2004
Picon

Re: template-haskell names in 6.3

Simon Peyton-Jones wrote:

Right... I had a good look through the library source, but must have 
missed it...
It seems the functions to build and extract the 'module' part of Names 
is not
exported... is there any reason why it can't be?

    Keean.

>Acutally it's there already:
>	qCurrentModule :: Q String
>
>Simon
>
>| -----Original Message-----
>| From: Keean Schupke [mailto:k.schupke <at> imperial.ac.uk]
>| Sent: 02 December 2004 17:37
>| To: Simon Peyton-Jones
>| Subject: Re: template-haskell names in 6.3
>| 
>| Simon Peyton-Jones wrote:
>| 
>| Okay I want a globaly unique label, so I want to prepend the module
>name
>| to the string...
>| 
>| module SomeLib.MyModule where
>| 
>| $(label "myLabel") -- splices: myLabel = "SomeLib.MyModule.myLabel"
(Continue reading)

Simon Peyton-Jones | 3 Dec 13:17 2004
Picon

RE: Re: template-haskell names in 6.3

Reasonable idea.  I've added

	nameModule :: Name -> Maybe String
to join the existing
	nameBase :: Name -> String

The 'Maybe' is needed because not all names  have modules; in
particular, ones that are made with mkName or newName.

OK?

Simon

| -----Original Message-----
| From: template-haskell-bounces <at> haskell.org
[mailto:template-haskell-bounces <at> haskell.org] On
| Behalf Of Keean Schupke
| Sent: 03 December 2004 11:00
| To: Simon Peyton-Jones
| Cc: template-haskell <at> haskell.org
| Subject: [Template-haskell] Re: template-haskell names in 6.3
| 
| Simon Peyton-Jones wrote:
| 
| Right... I had a good look through the library source, but must have
| missed it...
| It seems the functions to build and extract the 'module' part of Names
| is not
| exported... is there any reason why it can't be?
| 
(Continue reading)

Keean Schupke | 3 Dec 13:21 2004
Picon

Re: Re: template-haskell names in 6.3

Simon Peyton-Jones wrote:

>Reasonable idea.  I've added
>
>	nameModule :: Name -> Maybe String
>to join the existing
>	nameBase :: Name -> String
>
>The 'Maybe' is needed because not all names  have modules; in
>particular, ones that are made with mkName or newName.
>
>OK?
>  
>
That looks great - one final request is there any problems with exporting
a generic constructor for these two part Names... like:

    mkNameG :: String -> String -> Name

    or perhaps

    makeName :: Maybe String -> String -> Name

       which would make either a local name or a global name depending
       on whether a module name were specified...

Keean.
Simon Peyton-Jones | 3 Dec 14:48 2004
Picon

RE: Re: TH2 bug

Did I mention that I've committed this change.

  | PrimTyConI 	-- Ones that can't be expressed with a data type 
		-- decl, such as (->), Int#
	Name 
	Int	-- Arity
	Bool	-- False => lifted type; True => unlifted

| -----Original Message-----
| From: template-haskell-bounces <at> haskell.org
[mailto:template-haskell-bounces <at> haskell.org] On
| Behalf Of Keean Schupke
| Sent: 27 October 2004 15:12
| To: Keean Schupke
| Cc: template-haskell <at> haskell.org; Simon Peyton-Jones
| Subject: Re: [Template-haskell] Re: TH2 bug
| 
| Just checked and 'Type' has an entry (ArrowT) for functions.
| Why not just use the existing Type. IE
| 
| reify ''(->)
| 
|     data Info =
|        PrimTyCon Type
|        TyConI Dec
| 
| This would be fine for tuples as well, I wonder if () could be
| encoded as a tuple of 0?
| 
|     Keean.
(Continue reading)

Keean Schupke | 3 Dec 14:48 2004
Picon

Re: Re: TH2 bug

Cool, that means I can derive instances of TTypeable (type level type rep)
for primitive types...

    Keean.

Simon Peyton-Jones wrote:

>Did I mention that I've committed this change.
>
>  | PrimTyConI 	-- Ones that can't be expressed with a data type 
>		-- decl, such as (->), Int#
>	Name 
>	Int	-- Arity
>	Bool	-- False => lifted type; True => unlifted
>
>
>| -----Original Message-----
>| From: template-haskell-bounces <at> haskell.org
>[mailto:template-haskell-bounces <at> haskell.org] On
>| Behalf Of Keean Schupke
>| Sent: 27 October 2004 15:12
>| To: Keean Schupke
>| Cc: template-haskell <at> haskell.org; Simon Peyton-Jones
>| Subject: Re: [Template-haskell] Re: TH2 bug
>| 
>| Just checked and 'Type' has an entry (ArrowT) for functions.
>| Why not just use the existing Type. IE
>| 
>| reify ''(->)
>| 
(Continue reading)

Simon Peyton-Jones | 3 Dec 15:13 2004
Picon

RE: Re: template-haskell names in 6.3

do you mean 
	n <- newName s
or
	let n = mkName s
?

If the former, you'll get a new decl like
	data Foo_24 = Foo_098 Foo_24
which definitely won't clash.  We discussed this, and I've implemented
it.

If the latter, you will get 
	data Foo = Foo Foo

... and then I see what you want.  You want a version of mkName that is
like giving a qualified name in Haskell.  It's dynamically scoped just
like mkName, but it obeys the usual rules for qualified names in
Haskell.

To be totally explicit, suppose I have

	foo = [| mkQualName "Foo" "baz" |]

then if I call foo thus

	wibble = \baz -> $foo

the $foo splice will expand to "Foo.baz", and that won't see the \baz;
it'll see whatever Foo.baz is in scope.

(Continue reading)

Keean Schupke | 3 Dec 15:38 2004
Picon

Re: Re: template-haskell names in 6.3

Simon Peyton-Jones wrote:

>do you mean 
>	n <- newName s
>or
>	let n = mkName s
>?
>  
>
I mean the latter... or perhaps: "n <- return $ mkName s"... 

>If the latter, you will get 
>	data Foo = Foo Foo
>
>... and then I see what you want.  You want a version of mkName that is
>like giving a qualified name in Haskell.  It's dynamically scoped just
>like mkName, but it obeys the usual rules for qualified names in
>Haskell.
>
>To be totally explicit, suppose I have
>
>	foo = [| mkQualName "Foo" "baz" |]
>
>then if I call foo thus
>
>	wibble = \baz -> $foo
>
>the $foo splice will expand to "Foo.baz", and that won't see the \baz;
>it'll see whatever Foo.baz is in scope.
>  
(Continue reading)

Simon Peyton-Jones | 3 Dec 18:03 2004
Picon

RE: template haskell printf doesn't compile...

Redirecting this to the Template Haskell mailing list

Guys, can you help Alex?

Simon

| -----Original Message-----
| From: S. Alexander Jacobson [mailto:alex <at> alexjacobson.com]
| Sent: 03 December 2004 16:59
| To: Simon Peyton-Jones
| Cc: GHC users
| Subject: RE: template haskell printf doesn't compile...
| 
| I was able to use the library documentation to get
| printf to compile.  But I still can't figure out
| how to produce Declarations. Is there a directory
| somewhere with more examples?
| 
| Note this is being used to overhaul my relational
| database code.
| 
| -Alex-
| 
| ______________________________________________________________
| S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
| 
| 
| 
| On Fri, 3 Dec 2004, Simon Peyton-Jones wrote:
| 
(Continue reading)


Gmane