[Template-haskell] Pattern matching against lists.

Hampus Ram template-haskell@haskell.org
Mon, 26 May 2003 15:52:27 +0200


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"