[Template-haskell] Pattern matching against lists.

Simon Peyton-Jones simonpj@microsoft.com
Mon, 26 May 2003 17:09:45 +0100


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.
|=20
| 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) =3D x |]
|=20
| 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 :)
|=20
| (btw. the new names are much better than the old)
|=20
| /Hampus
|=20
| --
| Homepage: http://www.dtek.chalmers.se/~d00ram
| E-mail: d00ram@dtek.chalmers.se
|=20
| "Det =E4r aldrig f=F6rsent att ge upp"
| _______________________________________________
| template-haskell mailing list
| template-haskell@haskell.org
| http://www.haskell.org/mailman/listinfo/template-haskell