base libraries
Bulat Ziganshin
bulat.ziganshin at gmail.com
Sun Nov 26 14:02:14 EST 2006
Hello Udo,
Sunday, November 26, 2006, 5:21:29 PM, you wrote:
>> you shouldn't mix C++ template system with Haskell classes. C++ can't
>> check templates at the time where template defined that leads to
>> too late error messages. just imagine that improper definition of
>> 'sum' will barks on each call site with a message that you can't use
>> (&&) on Ints.
> Instead it will tell you that there is no instance for (Boolean Int),
> and it will do so at every call site, assuming (&&) was indeed
> overloaded. Where's the difference? And conversely, a properly defined
> 'sum' will tell you that there is no instance for (Num String) at every
> wrong call site, which again is just the same, of course assuming that
> nobody made String into an instance of Num. Sounds like we're actually
> in violent agreement here.
seems that you never used type signatures. just try:
sum :: Num a => [a] -> a
sum = foldr1 (&&)
--
Best regards,
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Libraries
mailing list