Why do functions not inherit class when renamed?

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/

Hello, On Thu, Mar 19, 2009 at 05:49:34PM -0600, Duane Johnson wrote:
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?
This is the monomorphism restriction kicking in. See http://www.haskell.org/haskellwiki/Monomorphism_restriction.
Prelude> let (...) = (*) Prelude> :t (...) (...) :: Integer -> Integer -> Integer
Prelude> :set -fno-monomorphism-restriction Prelude> let (...) = (*) Prelude> :t (...) (...) :: (Num a) => a -> a -> a
-- Tomáš Janoušek, a.k.a. Liskni_si, http://work.lisk.in/

Tomáš Janoušek
Hello,
On Thu, Mar 19, 2009 at 05:49:34PM -0600, Duane Johnson wrote:
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?
This is the monomorphism restriction kicking in.
See http://www.haskell.org/haskellwiki/Monomorphism_restriction.
Prelude> let (...) = (*) Prelude> :t (...) (...) :: Integer -> Integer -> Integer
Prelude> :set -fno-monomorphism-restriction Prelude> let (...) = (*) Prelude> :t (...) (...) :: (Num a) => a -> a -> a
I believe it is a good practice to always write the function type.
Prelude> let mult :: Num a => a -> a -> a ; mult = (*) Prelude> :i mult mult :: (Num a) => a -> a -> a -- Defined at <interactive>:1:35-38 -- c/* __o/* <\ * (__ */\ <
participants (3)
-
Duane Johnson
-
Tomáš Janoušek
-
Xiao-Yong Jin