[Haskell-cafe] Occurs check error, help!

boblettoj boblettoj99 at msn.com
Sat Mar 20 14:26:34 EDT 2010

Hi i am writing a shuffle function which takes in a random number i and a
list and then produces a jumbled up version of the list at the end. Here is
what i have at the moment (i'm not sure if it works yet as it won't compile!

--function used to shuffle cards 
--list equals random member of array plus the rest of the array
--i is randomly generated from range of length equal to that of cards.
shuffle :: int -> [a] -> [a]
shuffle i [] = []
shuffle i [cards] = (cards!!i) + 
	(shuffle (randomR (0, ((length cards)-2)))
	(delete (cards!!i) cards))

I get this error message when i try to compile:

Occurs check: cannot construct the infinite type: a = [[a]]

I'm very new to haskell so you'll have to excuse any ignorance!
View this message in context: http://old.nabble.com/Occurs-check-error%2C-help%21-tp27966341p27966341.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list