Re: [Haskell-cafe] flip dot

2006-09-28 Thread Greg Fitzgerald
 You mean apply the function on the right to the result of the left?Yes.(.) :: a - (a - b) - bx.f == f xPrefix usage:given: (f :: Integer - Char) and (g :: Double - Double - Integer)
(foo = .f) == \x - f x(bar = .g) == \x y = g x yfoo :: Double - Double - Charfoo = .g.f  How about making . reverse composition, and...symbol for flip ($) [1,2,3]#null.not
that works too, and is clearly easier to implement, but there's an opportunity to shorten the gap between Haskell and the mainstream languages, and without losing functional composition.Also, if you flip the meaning of dot, some existing code will still compile, but produce different values (map ((+1) . (*2))). By changing the type signature of the infix operator, it would break all existing code at *compile-time*.
With the prefix dot operator, I like how small the transition from pointwise to point-free code is:f x = x.null.notf = .null.notSame is true of the hash-dot style too, of course:f x = x#null.not
f = null.notBoth are quite a better than Haskell today:f x = not (null x)f x = not $ null xf x = (not . null) xf = not . null left-to-right order lets you think of the starting value and make a sequence of transformations
does syntax affect this? if someone views a solution with an imperative point-of-view, won't they just use $ or parenthesis everywhere anyway?Thanks,Greg
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flip dot

2006-09-28 Thread Brian Hulley

On Thursday, September 28, 2006 1:33 AM, Greg Fitzgerald  wrote:

Since there's talk of removal of the composition operator in 
Haskell-prime,

how about this:

Instead of:
foo = f . g

you write:
foo = .g.f

A leading dot would mean, apply all unnamed parameters
to the function on the right.  A trailing dot would mean,
apply the result of the left to the function on the right.


Hi -

I think the H' proposal 
http://hackage.haskell.org/trac/haskell-prime/wiki/CompositionAsDot is an 
extremely bad idea. I really don't see why people have so many problems with 
the idea of just placing spaces before and after the dot when used as an 
operator, and in any case it's hard to think of a more important operator in 
a functional language than composition and a more fitting symbol for it than 
the simple dot.


Also, the syntax .x with no spaces between the '.' and the 'x' is needed 
for at least one record poposal (eg 
http://www.haskell.org/pipermail/haskell-cafe/2006-August/017466.html)


Regards, Brian.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flip dot

2006-09-28 Thread Tim Walkenhorst

Thoughts?


Without considering the subtleties of the different meanings of . in 
Haskell, I fail to see what people find so exciting about left to right 
function composition. I find not . null much easier to read than null 
 not, let alone .null.not.


IMO, the following are good reasons for keeping the current 
semantics/notation of .:

- It's a conventional notation (, unlike for example ).
- It makes it easy to switch back and force between point-wise($) and 
point-free(.) notation when appropriate. I do this a lot.


If I were to fix the language I would probably use something like : or 
:: for selection and keep . for composition.


Tim
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flip dot

2006-09-28 Thread Sebastian Sylvan

On 9/28/06, Brian Hulley [EMAIL PROTECTED] wrote:

On Thursday, September 28, 2006 1:33 AM, Greg Fitzgerald  wrote:

 Since there's talk of removal of the composition operator in
 Haskell-prime,
 how about this:

 Instead of:
 foo = f . g

 you write:
 foo = .g.f

 A leading dot would mean, apply all unnamed parameters
 to the function on the right.  A trailing dot would mean,
apply the result of the left to the function on the right.

Hi -

I think the H' proposal
http://hackage.haskell.org/trac/haskell-prime/wiki/CompositionAsDot is an
extremely bad idea. I really don't see why people have so many problems with
the idea of just placing spaces before and after the dot when used as an
operator,


If C had something like that, we would use it as yet more reasons to
make fun of it for. Spaces around operators shouldn't be significant.
It's just extremly messy and ugly IMO.


and in any case it's hard to think of a more important operator in
a functional language than composition and a more fitting symbol for it than
the simple dot.


Well I would think that '=' is more important, for example. Or how
about -? There are many operators that absolutely essential for the
langauge. Composition is, after all, merely a library function. The
dot is a nice low-noise operator that could be put to good use as
selectors of records and modules (being simliar to other languages in
that regard is not a goal in itself, but certainly doesn't hurt).
Reserved symbols should get to choose first IMO, and then the rest
can be used for library functions.

How aboug using  for compositon? It almost looks like a ring.



--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flip dot

2006-09-28 Thread David House

On 28/09/06, Brian Hulley [EMAIL PROTECTED] wrote:

I think the H' proposal
http://hackage.haskell.org/trac/haskell-prime/wiki/CompositionAsDot is an
extremely bad idea.


Hear, hear. Besides the fact that it's a proposal I disagree with
anyway, it would break _every single Haskell program ever_, and
therefore it should be thrown out of the window completely.

--
-David House, [EMAIL PROTECTED]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flip dot

2006-09-28 Thread Tim Newsham

(.) :: a - (a - b) - b
x.f == f x


Looks like a parallel of (=).
Sounds interesting and useful, but why hijack dot? Would work nicely with 
record gettor functions (but not the settors).



Greg


Tim Newsham
http://www.thenewsh.com/~newsham/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] flip dot

2006-09-27 Thread Greg Fitzgerald
Since there's talk of removal of the composition operator in Haskell-prime, how about this:
Instead of:foo = f . gyou write:foo = .g.fA leading dot would mean, apply all unnamed parameters to the function on the right. A trailing dot would mean, apply the result of the left to the function on the right.
Prelude notNull = .null.not= [a] - BoolnotNull [1,2,3]= True[1,2,3].notNull= True[1,2,3].null.not
= TrueI like this because it has the same perks as the composition operator, yet it looks like OO code and the data flows nicely from left to right. It reads especially well when using the bind operator on the same line.
Thoughts?Thanks,Greg
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flip dot

2006-09-27 Thread Brandon Moore

Greg Fitzgerald wrote:
Since there's talk of removal of the composition operator in 
Haskell-prime 
http://hackage.haskell.org/trac/haskell-prime/wiki/CompositionAsDot, 
how about this:


Instead of:
foo = f . g

you write:
foo = .g.f

A leading dot would mean, apply all unnamed parameters to the 
function on the right.  A trailing dot would mean, apply the result 
of the left to the function on the right.
You mean apply the function on the right to the result of the left? 
Otherwise .g.f == \x - (g x) f



Prelude notNull = .null.not
= [a] - Bool
notNull [1,2,3]
= True

[1,2,3].notNull
= True
[1,2,3].null.not
= True

I like this because it has the same perks as the composition operator, 
yet it looks like OO code and the data flows nicely from left to 
right.  It reads especially well when using the bind operator on the 
same line.


Thoughts?
The left-to-right flow is pretty nice. I don't like the mechanics of 
your leading and internal dots - I don't see any way to interpret the 
internal dots as an infix operator without using some fancy typeclasses, 
whatever the leading dot gets to do. The infix dot would have to work at 
types

(a - b) - (b - c) - (a - b)
and a - (a - b) - b

Instead, How about making . reverse composition, and having some other 
symbol for flip ($), maybe '#'. Then you get things like


[1,2,3]#null.not

Which still vaguely resemble OO operations, if you think of composing 
together a path of accessors first, and then indexing with it.


you can even work with mutable fields reasonably nicely,
obj#a.b.c.readIORef
obj#a.b.c.flip writeIORef newVal

Finally,

Writing things in this left-to-right order lets you think of the 
starting value and make a sequence of transformations to get a result. 
Dangerously imperative ;)


The existing order instead calls to mind successively reducing the 
problem of producing desired output to simpler problems, eventually 
reaching a previously produced value. Wonderfully mathematical ;)


Brandon
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] flip dot

2006-09-27 Thread Brandon Moore

Brandon Moore wrote:

Greg Fitzgerald wrote:
Since there's talk of removal of the composition operator in 
Haskell-prime 
http://hackage.haskell.org/trac/haskell-prime/wiki/CompositionAsDot, 
how about this:


Instead of:
foo = f . g

you write:
foo = .g.f

A leading dot would mean, apply all unnamed parameters to the 
function on the right.  A trailing dot would mean, apply the result 
of the left to the function on the right.
You mean apply the function on the right to the result of the left? 
Otherwise .g.f == \x - (g x) f



Prelude notNull = .null.not
= [a] - Bool
notNull [1,2,3]
= True

[1,2,3].notNull
= True
[1,2,3].null.not
= True

I like this because it has the same perks as the composition 
operator, yet it looks like OO code and the data flows nicely from 
left to right.  It reads especially well when using the bind operator 
on the same line.


Thoughts?
The left-to-right flow is pretty nice. I don't like the mechanics of 
your leading and internal dots - I don't see any way to interpret the 
internal dots as an infix operator without using some fancy 
typeclasses, whatever the leading dot gets to do. The infix dot would 
have to work at types

(a - b) - (b - c) - (a - b)
and a - (a - b) - b

Instead, How about making . reverse composition, and having some other 
symbol for flip ($), maybe '#'. Then you get things like


[1,2,3]#null.not

Which still vaguely resemble OO operations, if you think of composing 
together a path of accessors first, and then indexing with it.


you can even work with mutable fields reasonably nicely,
obj#a.b.c.readIORef
obj#a.b.c.flip writeIORef newVal

Finally,

Writing things in this left-to-right order lets you think of the 
starting value and make a sequence of transformations to get a result. 
Dangerously imperative ;)


The existing order instead calls to mind successively reducing the 
problem of producing desired output to simpler problems, eventually 
reaching a previously produced value. Wonderfully mathematical ;)
Or, think of taking the continuation of your expression, and 
transforming it in left-to-right steps into one prepared to accept the 
value you've got.


Brandon
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe