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

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Sep 7 06:21:40 EDT 2006


Peter Arrenbrecht <peter.arrenbrecht at gmail.com> 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


More information about the Hugs-Users mailing list