[Haskell-cafe] Why do functions not inherit class when renamed?
Duane Johnson
duane.johnson at gmail.com
Thu Mar 19 19:49:34 EDT 2009
I'm not sure I understand what is going on here, but it seems to me
that the following assignment of "mult = (*)" causes "mult" to lose
out on some of the polymorphic behavior of (*). Is that right? If
so, why?
> Prelude Data.Function Data.List Data.Char> let sizeMult = (*) `on`
> length
> Prelude Data.Function Data.List Data.Char> sizeMult "Duane" "Johnson"
> 35
> Prelude Data.Function Data.List Data.Char> let mult = (*)
> Prelude Data.Function Data.List Data.Char> let sizeMult2 = mult `on`
> length
>
> <interactive>:1:26:
> Couldn't match expected type `Integer' against inferred type `Int'
> In the second argument of `on', namely `length'
> In the expression: mult `on` length
> In the definition of `sizeMult2': sizeMult2 = mult `on` length
> Prelude Data.Function Data.List Data.Char>
Thanks,
Duane Johnson
http://blog.inquirylabs.com/
More information about the Haskell-Cafe
mailing list