[Haskell-beginners] Why do i need to specify the class of a here at all?
Patrik Iselind
patrik.mrx at gmail.com
Sun Nov 26 21:46:29 UTC 2017
Den 2017-11-26 kl. 20:48, skrev Quentin Liu:
>> ```
>> exercises.hs:33:13:
>> Couldn't match expected type ‘[b0]’ with actual type ‘a’
>> ‘a’ is a rigid type variable bound by
>> the type signature for myOrderFunc :: a -> a -> Ordering
>> at exercises.hs:31:16
>> Relevant bindings include
>> y :: a (bound at exercises.hs:32:15)
>> x :: a (bound at exercises.hs:32:13)
>> myOrderFunc :: a -> a -> Ordering (bound at exercises.hs:32:1)
>> In the first argument of ‘myLen’, namely ‘x’
>> In the first argument of ‘(<)’, namely ‘myLen x’
>> Failed, modules loaded: none.
>> ```
>
> Your guess is correct. The problem is, Haskell does not consider `a`
> in `myOrderFunc` and `[b]` in `myLen` equivalent. `a` means you feed
> the function any type, while `[b]` means it must be a list of values
> of the same type. So changing `a` to `[a]` woud eliminate the error.
Thanks a lot for the clarification.
// Patrik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20171126/760c4d34/attachment.html>
More information about the Beginners
mailing list