This post poses the question for the case of !!
. The accepted answer tell us that what you are actually doing is creating a new function !!
and then you should avoid importing the standard one.
But, why to do so if the new function is to be applied to different types than the standard one? Is not the compiler able to choose the right one according to its parameters? Is there any compiler flag to allow this?
For instance, if *
is not defined for [Float] * Float
Why the compiler cries
> Ambiguous occurrence * > It could refer to either `Main.*', defined at Vec.hs:4:1 > or `Prelude.*',
for this code:
(*) :: [Float] -> Float -> [Float]
(*) as k = map (\a -> a*k) as -- here: clearly Float*Float
r = [1.0, 2.0, 3.0] :: [Float]
s = r * 2.0 -- here: clearly [Float] * Float
main = do
print r
print s