[Haskell-cafe] Stupid error, probably
daniel.is.fischer at web.de
Mon Oct 12 20:02:01 EDT 2009
Am Dienstag 13 Oktober 2009 01:03:24 schrieb b1g3ar5:
> I can't get the following to work in Leksah - but it works OK in GHC.
> Can anyone spot the error?
> I wondered if it was becasue the libraries loaded are different - but
> I'm just a Haskell beginner ...
> I have:
> myGroupBy :: Int→ [a]→ [[a]]
That "Int" isn't used in the definition of myGroupBy
perhaps you intended to write
myGroupBy k = takeWhile (not . null) . unfoldr (Just . splitAt k)
> myGroupBy = takeWhile not . null . (unfoldr (Just . (splitAt 3)))
> and I am getting the error:
> Couldn't match expected type `Int' against inferred type `[a]'
> In the second argument of `(.)', namely `(splitAt 3)'
> In the first argument of `unfoldr', namely `(Just . (splitAt 3))'
> In the second argument of `(.)', namely
> `(unfoldr (Just . (splitAt 3)))'
> But I think that
> splitAt :: Int->[a]->([a],[a])
> splitAt 3 :: [a]->([a], [a])
> Just.(splitAt 3) :: [a]->Maybe ([a], [a])
> which seems OK as the first argument of unfoldr:
> unfoldr :: (b-> Maybe(a,b))->b->[a]
> with the a and b of unfoldr being [a] and [a].
> The mention of Int in the error makes me wonder if I've got the wrong
> splitAt - with the arguments reversed maybe.
> Any ideas?
More information about the Haskell-Cafe