RE: TH2 bug

"Simon Peyton-Jones" <[email protected]>
Newsgroups gmane.comp.lang.haskell.template
Message-ID <036EAC76E7F5EC4996A3B3C3657D4116FE20F0@EUR-MSG-21.europe.corp.microsoft.com>
OK, now I get it.  I'm copying the TH list in the hope that other TH
aficionados will chime in.

The problem is with reify, not the '' notation.  Here it is in a
nutshell: 

	what value should be returned by the call  (reify ''(->) )?

Recall that
	reify :: Name -> Q Info

So reify claims to return an Info, and for a type constructor it
currently returns a TyConI; but a TyConI contains a  Dec, and there
simply is no Dec in the TH syntax for a function type; it's built in,
rather like Int# etc.  So reify falls over in a bad way.

It's obviously unsatisfactory for reify to just fall over in this case,
but what would you like?  A new constructor in Info for primitive
tycons?  A new constructor in Dec?  

And what questions do you want to be able to ask of the value in the
Info?  For example would it be enough to day

  data Info = TyConI Dec
	| PrimTyCon
	| ClassI Dec
	...etc...

where the PrimTyCon is returned for (->), Int#, etc?

Nothing difficult about fixing this once the design is clear.

Simon

| -----Original Message-----
| From: Keean Schupke [mailto:[email protected]]
| Sent: 27 October 2004 11:14
| To: Simon Peyton-Jones
| Subject: Re: TH2 bug
| 
| Yup, using HEAD. Here's an example template:
| 
|     ttypeshow :: Name -> Q [Dec]
|     ttypeshow q = do
|         r <- reify q
|        case r of
|           (TyConI t) -> runIO . putStrLn . show $ t
|           _ -> return ()
|        return []
| 
| Then in another file we do:
| 
|     $(ttypeshow ''(->))
| 
| Which fails, as does ''(), and ''(,) etc...
| 
| ''[] works okay however
| 
|     Keean.
| 
| 
| Simon Peyton-Jones wrote:
| 
| >I can't reproduce this.  Works for me.  What version of GHC are you
| >using?  The HEAD I assume?
| >
| >Simon
| >
| >| -----Original Message-----
| >| From: MR K P SCHUPKE [mailto:[email protected]]
| >| Sent: 22 October 2004 18:23
| >| To: [email protected]; Simon Peyton-Jones
| >| Subject: TH2 bug
| >|
| >|
| >| Just reporting a bug, taking types using '' works fine for:
| >|
| >| 	''Int
| >| 	''[]
| >|
| >| But when you try:
| >|
| >| 	''(->)
| >|
| >| 	you get:
| >|
| >| 	No match in record selector TyCon.algTcRhs
| >|
| >| Please report it as a compiler bug to
| >[email protected],
| >| or http://sourceforge.net/projects/ghc/.
| >|
| >|
| >| 	Keean.
| >
| >
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.