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

Cale Gibbard cgibbard at gmail.com
Sat Nov 19 18:23:20 EST 2005


We don't need another ($) though, and writing things backwards looks funny. :)

 - Cale

On 19/11/05, Bulat Ziganshin <bulatz at hotpop.com> wrote:
> 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
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list