Re: [noob] Typing error with nested list and tuple pattern?
Malcolm Wallace <[email protected]> Thu, 7 Sep 2006 11:21:40 +0100
| Newsgroups | gmane.comp.lang.haskell.hugs.user |
|---|---|
| Organization | Dept of Computer Science, University of York |
| Message-ID | <[email protected]> |
Peter Arrenbrecht <[email protected]> wrote: > ERROR file:.\cube.hs:11 - Type error in explicitly typed binding > *** Term : [(i,v) : ps] > *** Type : [[(a,b)]] > *** Does not match : [(Int,Double)] > [10] test :: [(Int, Double)] -> Int > [11] test [(i,v):ps] = i The error message does contain the answer. Your pattern [(i,v):ps] represents a singleton list containing a list of pairs. That is a list of lists. What the explicit type signature reveals to be your intention was a single-level list of pairs. To fix, use round parens around the pattern, not square brackets: ((i,v):ps) Regards, Malcolm