Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Imho this looks good. It will save on key strokes and maybe bring more readability. I always liked "." or "->" syntax in different languages.

My only worry is . being function composition operator so it might not be crazy amazing for readability only you get

a . b . c . d.e

So maybe it should have been something like "->".



> So maybe it should have been something like "->".

The problem is that "->" has an even more special meaning than "." in Haskell, since "->" separates the arguments of an unnamed function from its definition.

So, for example

    addOne = \x -> x + 1
and

    addOne x = x + 1
are equivalent.

This means that "->" is about as special as "=". Which leads me to think it would require some very substantial changes to the parser, and perhaps even defeat the purpose of increased readability. For example, how readable is the following?

    getY = \x -> x -> y
(which reads as "getY = \x -> x.y" in the current proposal)


I thought conflating the dot with function composition wouldn't be too bad because they're similar in a sense, but then I remembered that the two work in the reverse order in the sense that:

(.a.b.c) . (.d.e.f) = (.d.e.f.a.b.c)

If you use -> both for the member function and for reverse function composition you'd get:

(->a->b->c) -> (->d->e->f) = (->a->b->c->d->e->f)

which is somehow nicer, especially because accessing a member and composing functions become the same thing when you view a value as the unique function sending the initial object to that value.

But unfortunately we've spent centuries composing functions the wrong way round, so now we're forced to deal with the consequences.


You can do left to right function composition with (>>>)

Given functions f, g , h,

h >>> g >>> f is equivalent to f . g . h

Its from Control.Category, so it generalizes to other things, but for functions specifically its left to right composition.

( theres also (<<<), which in this case is identical to (.) )

( Also present in Control.Arrow . Why? I dont know this topic well enough to explain. My understanding is limited to what these operators mean in the specific of functions. Functions(->) are a type as well, so they can be instances of typeclasses. for example

  instance Functor ((->) r) where  
        fmap = (.)

)


Almost, but you are conflating function composition (lambda x: lambda y: f(x(y))) with function application (lambda x: f(x)).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: