RE: [Template-haskell] Pattern matching against lists.
Right. Then you need the magic names "GHC.Base::" etc. As Derek Ekins says, the thing to do is to write it quoted and then print; you'll then see the magic names. Tim and I are ruminating about this stuff. We're planning a way to let you name global things like (:) just by saying '(:) rather than with magic strings where you have to know about GHC.Base. But that won't arrive for a month or two Meanwhile this should get you unglued Simon | -----Original Message----- | From: template-haskell-admin@haskell.org [mailto:template-haskell-admin@haskell.org] On Behalf Of | Hampus Ram | Sent: 26 May 2003 14:52 | To: template-haskell@haskell.org | Subject: Re: [Template-haskell] Pattern matching against lists. | | On Mon, May 26 2003, Simon Peyton-Jones wrote: | > | > reading through THSyntax.hs I can find no way of matching against | > | > lists when creating functions. Is there something obvious that I've | > | > missed or is this something that is relly missing? | > | > [d| f (x:xs) = x |] | | Nothing, except that I needed to create pattern matching functions of | different lengths (so I need to construct them with the datatypes). I | tried conPat with just ":" and "[]" and that didn't work. I also tried | reifying declarations to see "behind the scenes", but reification does | seldom work for me... The solution was of course to use GHC.base:: and | GHC.base:[] and now everything works. One should perhaps not be too | quick to ask for help :) | | (btw. the new names are much better than the old) | | /Hampus | | -- | Homepage: http://www.dtek.chalmers.se/~d00ram | E-mail: d00ram@dtek.chalmers.se | | "Det är aldrig försent att ge upp" | _______________________________________________ | template-haskell mailing list | template-haskell@haskell.org | http://www.haskell.org/mailman/listinfo/template-haskell
On Mon, May 26 2003, Simon Peyton-Jones wrote:
We're planning a way to let you name global things like (:) just by saying '(:) rather than with magic strings where you have to know about GHC.Base. But that won't arrive for a month or two
All good things come to those who wait... For now I'll have to make do with the "ugly" names and indeed my TH lexer generator seems to work (it would be really cool to rewrite Happy as a TH module...) /Hampus (and yes, I have subscribed to the list) -- Homepage: http://www.dtek.chalmers.se/~d00ram E-mail: d00ram@dtek.chalmers.se "Det är aldrig försent att ge upp"
participants (2)
-
Hampus Ram -
Simon Peyton-Jones