[Haskell-cafe] Re: Occurs check error, help!
adamtheturtle
kill2thrill at hotmail.com
Sun Mar 21 23:31:12 EDT 2010
So I have the code
shuffle :: Int -> [a] -> [a]
shuffle i [] = []
shuffle i cards = (cards!!i) : shuffle (fst pair) (delete (cards!!i) cards)
where pair = randomR (0, 51) (mkStdGen 42)
and it doesn't work, am I missing something?
Cards.hs:39:51:
Could not deduce (Eq a) from the context ()
arising from a use of `delete' at Cards.hs:39:51-73
Possible fix:
add (Eq a) to the context of the type signature for `shuffle'
In the second argument of `shuffle', namely
`(delete (cards !! i) cards)'
In the second argument of `(:)', namely
`shuffle (fst pair) (delete (cards !! i) cards)'
In the expression:
(cards !! i) : shuffle (fst pair) (delete (cards !! i) cards)
Failed, modules loaded: none.
More information about the Haskell-Cafe
mailing list