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

This is a great example of how haskell makes these things obvious ;)

    clamped = num `max` min' `min` max'


no idea what's going on there, I know some of those variables are actually functions but the whole thing is unreadable unless you have experience in haskell imo


The backticks turn regular functions into left-associative operators of the highest priority (by default).

So

    a `foo` b `bar` c
is

    (bar (foo a b) c)


Oohh nice. So kinda like a pipe.

I really think we deserve more syntax that allowed something like this, because otherwise one needs to read `(bar (foo a b) c)` inside-out.


> Oohh nice. So kinda like a pipe.

I never thought of it that way, but it is true that it can be used as a pipe.

Fundamentally it's just the dual of (): Haskell lets you use operators as infix functions by wrapping them in () so

    (+) 1 2
is the same as

    1 + 2
and conversely lets you use prefix (binary) functions as operators by wrapping them in backticks.

You can even combine those through sections, which serve to partially apply infix operators: https://wiki.haskell.org/Section_of_an_infix_operator




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: