TDNR without new operators or syntax changes

Peter voldermort at hotmail.com
Thu May 26 09:14:45 UTC 2016


Thank you for feeding my thoughts. How would this do for a slightly more
detailed definition?

1. If the compiler encounters an ambiguous function, it will temporarily
give it the type a -> b, or the type declared in the signature if there is
one.
2. Type inference completes as normal.
3. If the inferred or declared type for an ambiguous name is sufficient to
disambiguate it, it will be bound to the correct definition.


Dan Doel wrote
> f :: T -> Int
> f t = ...
> 
> f :: U -> Int -> Char
> f u = ...
> 
> t :: T
> t = ...
> 
> u :: U
> u = ...
> 
> i1 :: Int
> i1 = f t

Solving for everything but f, we get f :: T -> Int.


> g :: (T -> Int) -> Int
> g h = h t
> 
> i2 :: Int
> i2 = g f

Solving for everything but f, we get f :: T -> Int.


> v :: T
> v = t
> 
> v :: U
> v = u
> 
> i3 :: Int
> i3 = f v

May not be solvable, would fail to disambiguate.



--
View this message in context: http://haskell.1045720.n5.nabble.com/TDNR-without-new-operators-or-syntax-changes-tp5835927p5836657.html
Sent from the Haskell - Glasgow-haskell-users mailing list archive at Nabble.com.


More information about the Glasgow-haskell-users mailing list