[Haskell-beginners] Inferring functions from parameter types
Russ Abbott
russ.abbott at gmail.com
Tue Dec 7 07:35:58 CET 2010
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?
*
-- Russ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20101206/6f3c0fea/attachment.htm>
More information about the Beginners
mailing list