Re: Re: TH2 bug

Keean Schupke <[email protected]>
Newsgroups gmane.comp.lang.haskell.template
Message-ID <[email protected]>
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: [email protected]
>[mailto:[email protected]] On
>| Behalf Of Keean Schupke
>| Sent: 27 October 2004 15:12
>| To: Keean Schupke
>| Cc: [email protected]; 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.
>| 
>| Keean Schupke wrote:
>| 
>| > Actually I would like it to be a special name... but I guess there
>| > are other possibilities.
>| >
>| > Ideally I would like:
>| >
>| > case info of
>| >    (PrimTyCon name) -> instanceD (cxt []) (appT (conT classname)
>(appT
>| > (appT (conT name) (varT a) (varT b)))
>| >
>| > to generate:
>| >
>| >    instance ClassName (a -> b)
>| >
>| >
>| >    Keean
>| >
>| > Simon Peyton-Jones wrote:
>| >
>| >> 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.
>| >> | >
>| >> | >
>| >>
>| >>
>| >>
>| >
>| > _______________________________________________
>| > template-haskell mailing list
>| > [email protected]
>| > http://www.haskell.org/mailman/listinfo/template-haskell
>| 
>| 
>| _______________________________________________
>| template-haskell mailing list
>| [email protected]
>| http://www.haskell.org/mailman/listinfo/template-haskell
>  
>
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.