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

前端 未结 10 1628
鱼传尺愫
鱼传尺愫 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:41

    I think we're confusing things. Haskell's (.) is equivalent to F#'s (>>). Not to be confused with F#'s (|>) which is just inverted function application and is like Haskell's ($) - reversed:

    let (>>) f g x = g (f x)
    let (|>) x f = f x
    

    I believe Haskell programmers do use $ often. Perhaps not as often as F# programmers tend to use |>. On the other hand, some F# guys use >> to a ridiculous degree: http://blogs.msdn.com/b/ashleyf/archive/2011/04/21/programming-is-pointless.aspx

提交回复
热议问题