[Template-haskell] Pattern matching against lists.

Derek Elkins ddarius@hotpop.com
Sat, 24 May 2003 06:50:04 -0400


On Sat, 24 May 2003 12:18:59 +0200
Hampus Ram <d00ram@dtek.chalmers.se> wrote:

> Hi,
> 
> 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?
> 
> /Hampus

Experimentation is a wonderful thing. (Though so is documentation ;)
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 5.05
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Prelude> :set -package haskell-src
Loading package haskell98 ... linking ... done.
Loading package haskell-src ... linking ... done.
Prelude> :set -fglasgow-exts
Prelude> :m Language.Haskell.THSyntax
Prelude Language.Haskell.THSyntax>
Prelude Language.Haskell.THSyntax> runQ [d| foo (x:_) = x |] >>= print
[Fun "foo" [Clause [Pcon "GHC.Base::" [Pvar "x'0",Pwild]] (Normal (Var
"x'0")) []]]
Prelude Language.Haskell.THSyntax>