Haskell composition (.) vs F#'s pipe forward operator (|>)

前端 未结 10 1635
鱼传尺愫
鱼传尺愫 2020-12-04 07:36

In F#, use of the the pipe-forward operator, |>, is pretty common. However, in Haskell I\'ve only ever seen function composition, (.), being us

10条回答
  •  广开言路
    2020-12-04 07:58

    More speculation, this time from the predominantly Haskell side...

    ($) is the flip of (|>), and its use is quite common when you can't write point-free code. So the main reason that (|>) not used in Haskell is that its place is already taken by ($).

    Also, speaking from a bit of F# experience, I think (|>) is so popular in F# code because it resembles the Subject.Verb(Object) structure of OO. Since F# is aiming for a smooth functional/OO integration, Subject |> Verb Object is a pretty smooth transition for new functional programmers.

    Personally, I like thinking left-to-right too, so I use (|>) in Haskell, but I don't think many other people do.

提交回复
热议问题