[Hugs-users] [noob] Typing error with nested list and tuple pattern?

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Sep 7 03:23:14 EDT 2006

Hello Peter,

Thursday, September 7, 2006, 11:02:12 AM, you wrote:

> [10] test :: [(Int, Double)] -> Int
> [11] test [(i,v):ps] = i

test ((i,v):ps) = i

your mistake was using for grouping [] instead of ()

[] should be used only with ',' or '..':

[(1,0.7), (2,0.8)]

(x:xs) means constructing list from element representing head
of new list and old list representing all remaining elements

[x:xs] is equivalent to [(x:xs)] and means constructing singleton
(one-element) list which only element is another list, namely (x:xs).
so, you got list of lists

ps: btw, it's better to ask newbie questions in haskell-cafe list

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Hugs-Users mailing list