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

Donn Cave donn at avvanta.com
Fri Feb 3 17:10:40 CET 2012


Quoth AntC <anthony_clayden at clear.net.nz>,
...
> We're on the slippery slope! Where will it end?
>
> And now that I've found it, I so love:
>
>     customer.lastName.tail.head.toUpper    -- Yay!

... compared to present practice, with where dot is function
composition only -

    (toUpper.head.tail.lastName) customer

So two competing meanings of ".", where one is literally the reverse
of the other.  Of course we won't be able to spell composition
without spaces any more, so technically the backwards and forward
sense of . are distinct, but it seems kind of unfortunate anyway.

...

If you'll consider an idea from the peanut gallery ...  for me, the
dot notation for fields may as well be "spelling" as an operator -
that is, customer.lastName deploys a field named ".lastName".

If someone modified Haskell to allow postfix notation from this
perspective, when compiler sees "customer.lastName", it would
look for an identifier ".lastName", so it would work only where
the fields are so declared:

data Customer = Customer { .lastName :: String, .firstName :: String }

Without explicit dot nomenclature (as per current practice), only
normal function application syntax would be supported (as per current
practice.)  Unspaced composition (fromInteger.ord) would still be
broken, I suppose, but the error (Not in scope: `.ord') would at
least be pretty obvious.

	Donn



More information about the Haskell-Cafe mailing list