Is there an inverse of the Haskell $ operator?

前端 未结 6 429
感情败类
感情败类 2021-02-01 13:44

A quick question, is there an operator in Haskell that works like the dollar sign but gives precedence to the left hand side. I.E. instead of

f (x 1) 
         


        
6条回答
  •  深忆病人
    2021-02-01 14:22

    I do not know, whether there is an standart operator, but what prevents you from writing your own? This works in ghci:

    Prelude> let a $> b = b a
    Prelude> 1 $> (+2)
    3
    Prelude> sum [1, 2] $> (+2)
    5
    Prelude> map (+2) [1, 2] $> map (+3)
    [6,7]
    

    UPDATE: searching on hoogle for a -> (a -> b) -> b (it is the type of this operator) found nothing useful.

提交回复
热议问题