Is there any theoretical reason why GHC (or Haskell) doesn't permit functions to be inferred from their parameter types?
For example, if I write
null Data.Set.empty
I get a diagnostic saying
Ambiguous occurrence `null'
It could refer to either `List.null', imported from Data.List at ...
or `Map.null', imported from Data.Map at ...
or `IntSet.null', imported from Data.IntSet at ...
Why doesn't GHC figure it out?
More generally it would be nice to be able to define:
f :: Type1 -> ResultType1
f :: Type2 -> ResultType2
and expect GHC to select the appropriate f based on the argument and implied result types. Even if the type can't always be determined, why not do it when possible and issue a complaint when it can't?