[Haskell-cafe] re-definition of '.'

Bulat Ziganshin bulatz at HotPOP.com
Sat Nov 19 14:33:33 EST 2005


Hello haskell-cafe,

if we will define "." as:

a.b = b a

then we can use "." for

1) field selection

2) sequential functions application in OOP style:

[1..100] .map (2*) .sum

3) qualified identifiers - if we treat module name as the record
containing all its exported functions:

"import M (f,g,h)" defines record M with fields f, g and h



The only problem is priority of this operation - for field selection
it need to be greater than for application:

infixl 11 .

while for OOP-styled operations with arguments - its priority must be
minimal. one possible solution is rather revolitionary: raise priority
of "." if there is no spaces around it, so the following will be
interpreted precisely as we want:

record.field .List.map (2*) .sum


-- 
Best regards,
 Bulat                          mailto:bulatz at HotPOP.com





More information about the Haskell-Cafe mailing list