[Haskell-beginners] Why the length function I wrote has such a type signature?

amazingjxq amazingjxq at gmail.com
Thu Nov 11 05:01:30 EST 2010


Thanks everyone. I didn't even think about it.

2010/11/11 Isaac Dupree <ml at isaac.cedarswampstudios.org>

> On 11/11/10 03:24, 贾旭卿 wrote:
>
>> This is exercise 3.1 of Real World Haskell. I have my length function like
>> this:
>>
>> myLength [] = 0
>> myLength (_:xs) = 1 + (myLength xs)
>>
>> And I assumed the type signature is like this:
>> mylength :: [a] ->  Num
>>
>> But when I wrote this into the file and reloaded it into ghci, there is an
>> error.
>>
>>      The type signature for `mylength' lacks an accompanying binding
>>> Failed, modules loaded: none.
>>>
>>
> In addition to what Chaddaï Fouché said, this particular error is simply
> due to writing "mylength" when it should be "myLength" (L uppercase).
>
> -Isaac
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20101111/6765b0b0/attachment.html


More information about the Beginners mailing list