re-definition of '.'

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

re-definition of '.'

Bulat Ziganshin
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:[hidden email]



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: re-definition of '.'

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

 - Cale

On 19/11/05, Bulat Ziganshin <[hidden email]> 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:[hidden email]
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: re-definition of '.'

Max Eronin
In reply to this post by Bulat Ziganshin
> 2) sequential functions application in OOP style:
>
> [1..100] .map (2*) .sum

Great proposal! And the only feature haskell will lack is computable go to!
And if we add both haskell would become the most expressive and
powerful programming language since INTERCAL

--max
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: re-definition of '.'

jerzy.karczmarczuk
Max Eronin:

>> 2) sequential functions application in OOP style:
>>
>> [1..100] .map (2*) .sum
>
> Great proposal! And the only feature haskell will lack is computable go to!
> And if we add both haskell would become the most expressive and
> powerful programming language since INTERCAL

But we have those computed gotos already.

Actually, all irony apart, seriously, I have a theorem for you.

It says:

 At least 2 times per month somebody
 tries to reinvent continuations.

Jerzy Karczmarczuk


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re[2]: re-definition of '.'

Bulat Ziganshin
In reply to this post by Max Eronin
Hello Max,

Tuesday, November 22, 2005, 2:30:23 AM, you wrote:

>> 2) sequential functions application in OOP style:
>>
>> [1..100] .map (2*) .sum

ME> Great proposal! And the only feature haskell will lack is computable go to!
ME> And if we add both haskell would become the most expressive and
ME> powerful programming language since INTERCAL

is the word OOP persuade so strange on you? two days above someone
wrote about the same operator, just with different name and i don't
see any critics from you or any other FP purists

you missed the key of my idea - because '.' syntax is so needed for
modules and records, we must either support this as special syntax
rules or invent some functional explanation for this syntax. i propose
just such explanations, while all other records proposals just say
"this must become a special syntax"



--
Best regards,
 Bulat                            mailto:[hidden email]



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: re-definition of '.'

Max Eronin
> is the word OOP persuade so strange on you?

No, my brain exploded by the examples and proposed rules made me look so....
When it is exploding I often start acting funnily. And I was fortunate
enough not to begin biting the dogs and scratching the cats after an
attempt to predict an order of application with two different (but not
so) operators that bubble arguments left to right and then throw them
backward and over again.
bow-wow
Something like "PLEASE READ OUT" statement in INTERCAL.

There was nothing about OOP in my posting (as well as in yours).

> see any critics from you or any other FP purists

Not sure I see what you mean by 'FP purists' in the context of Haskell language
But whatever -, Haskell is still a pure language, isn't it?
Looks like now it's time to change this inadvertence. Let it be
impure, vulgar, dirty and scripting!

And you are absolutely right. I missed the key of your idea. My brain
is erupted, you know... :(


||amx
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe