-Ursprüngliche Nachricht-
Von: adamtheturtle
Gesendet: 22.03.2010 04:52:19
An: haskell-cafe@haskell.org
Betreff: [Haskell-cafe] Re: Occurs check error, help!
>Ivan Miljenovic writes:
>
>>
>> Since my answer before to your question obviously wasn't clear enough,
On 22 March 2010 14:52, adamtheturtle wrote:
> So sorry to keep on going on about this but I have been set to start with
> "shuffle :: Int -> [a] -> [a]" so I have to do that and can't use the given
> code
> and I
> really don't know where to put (Eq a)
First of all, do a tutorial or something r
Ivan Miljenovic gmail.com> writes:
>
> Since my answer before to your question obviously wasn't clear enough,
> let me highlight the lines of the error message that summarise what
> you have to do:
>
> On 22 March 2010 14:31, adamtheturtle hotmail.com>
wrote:
> > Possible fix:
> > add
Since my answer before to your question obviously wasn't clear enough,
let me highlight the lines of the error message that summarise what
you have to do:
On 22 March 2010 14:31, adamtheturtle wrote:
> Possible fix:
> add (Eq a) to the context of the type signature for `shuffle'
Alternat
On Sun, Mar 21, 2010 at 11:31 PM, adamtheturtle wrote:
> 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 somet
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
On 22 March 2010 13:49, adamtheturtle wrote:
> Just tried 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 I get:
>
> Could not deduce (Eq a)
boblettoj msn.com> writes:
>
>
> Haha, much better now!
> Thanks for all your help, it's working great!
>
>
Just tried 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)
boblettoj writes:
> newStdGen results in IO Ints whereas i need normal Ints and it seems theres
> no easy way to convert them without a lot more knowledge of haskell. I have
> tried using a where clause instead of using do but this is giving me the
> occurs check error again!
>
> --function used