[Haskell-cafe] Some thoughts on Type-Directed Name Resolution

Ertugrul Söylemez es at ertes.de
Fri Feb 3 14:55:41 CET 2012

Steve Horne <sh006d3592 at blueyonder.co.uk> wrote:

> There's a proposal at the moment to add support for TDNR to Haskell -
> to leverage "the power of the dot" (e.g. for intellisense).
> http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution

I'm not sure whether this should really be a language feature.  A smart
editor together with compiler support can do this without language

The basic problem is that without the dot style you write the function
before you write its argument.  For an intellisense-like feature you
need to write the argument before you write the function.

Now in a smart editor you could write "x.", at which point the editor
could examine the source file to find the actual type of 'x' as well as
the expected type of the spot where you are currently writing.  Once it
has built a list of suitable functions, it could rewrite the "x." to
"x", place the cursor in front of it and let you browse the list of

    -> [suggestions]_ x

An even smarter editor could provide something like agda-mode's hole
feature.  In Agda you can write "f ?", at which point agda-mode replaces
the question mark by a hole.  You can then ask for the type of the term
that goes into the hole as well as try to infer the value.  Agda-mode
doesn't provide you with a list of suggestions, but in Haskell with type
inference this could certainly be possible.  I would prefer holes over


nightmare = unsafePerformIO (getWrongWife >>= sex)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120203/d9ed4c86/attachment.pgp>

More information about the Haskell-Cafe mailing list