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

Daniel Fischer daniel.is.fischer at web.de
Thu Sep 7 06:44:50 EDT 2006


Am Donnerstag, 7. September 2006 09:02 schrieb Peter Arrenbrecht:
> Hi all
>
> I am baffled by the following error message from Hugs 98 (Version May
> 2006):
>
> ERROR file:.\cube.hs:11 - Type error in explicitly typed binding
> *** Term           : [(i,v) : ps]
> *** Type           : [[(a,b)]]
> *** Does not match : [(Int,Double)]
>
> when attempting to compile the following declaration (line numbers in
> brackets):
>
> [10] test :: [(Int, Double)] -> Int
> [11] test [(i,v):ps] = i
>
> Is this a bug? If not, how do I write the pattern properly?

No bug.
You should write

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

The pattern [(i,v):ps] has type list of lists of (Int,Double) pairs, one more 
layer of list than you want.
>
> Thanks,
> Peter Arrenbrecht

You're welcome,
Daniel

-- 

"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
	-- Blair P. Houghton



More information about the Hugs-Users mailing list