top | item 43752601

(no title)

jose_zap | 10 months ago

Haskell has & which goes the other way:

    users
      & map validate
      & catMaybes
      & mapM persist

discuss

order

taolson|10 months ago

Yes, `&` (reverse apply) is equivalent to `|>`, but it is interesting that there is no common operator for reversed compose `.`, so function compositions are still read right-to-left.

In my programming language, I added `.>` as a reverse-compose operator, so pipelines of function compositions can also be read uniformly left-to-right, e.g.

    process = map validate .> catMaybes .> mapM persist

1-more|10 months ago

Elm (written in Haskell) uses |> and <| for pipelining forwards and backwards, and function composition is >> and <<. These have made it into Haskell via nri-prelude https://hackage.haskell.org/package/nri-prelude (written by a company that uses a lot of Elm in order to make writing Haskell look more like writing Elm).

There is also https://hackage.haskell.org/package/flow which uses .> and <. for function composition.

EDIT: in no way do I want to claim the originality of these things in Elm or the Haskell package inspired by it. AFAIK |> came from F# but it could be miles earlier.

shadytrees|10 months ago

Maybe not common, but there’s Control.Arrow.(>>>)

lgas|10 months ago

Also you can (|>) = (&) (with an appropriate fixity declaration) to get

  users
    |> map validate
    |> catMaybes
    |> mapM persist

Symmetry|10 months ago

I guess I'm showing how long it's been since I was a student of Haskell then. Glad to see the addition!