[Ur] Functional infix operators ?
Gabriel Riba
griba2001 at gmail.com
Wed Feb 11 11:04:23 EST 2015
A functional language cannot lack functional infix operators :)
They enhance code readability and save parenthesis.
The reverse functional application, which I like the most, gives a data
navigation aspect
val expr = xs |> filter isEven
|> map double
|> foldl myop z
|> show
The left-to-right composition shows the composition as a sequence.
In Haskell (with Arrow operators from Data.Category)):
rebalance = decreaseLevel >>> skew >>> skewRight >>> skewRightRight >>>
split >>> splitRight
Haskell's backtick quoting converts any function in infix. (Scala does it
without backticks)
val rebalance = decreaseLevel `andThen` skew `andThen` skewRight
Others operators:
* Functional aplication (forward and reverse)
OCaml (@@) and (|>)
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Pervasives.html#6_Compositionoperators
FSharp (<|) and (|>) https://msdn.microsoft.com/en-us/library/dd233228.aspx
Haskell ($) and (proposed (.$))
Elm (<|) and (|>) http://elm-lang.org/learn/Syntax.elm
* Functional composition (right-to-left and left-to-right)
Standard ML (o)
Haskell ( . )
FSharp (<<) and (>>)
OCaml Batteries (%) and (%>)
http://ocaml-batteries-team.github.io/batteries-included/hdoc2/BatPervasives.html
Haskell Category (<<<) and (>>>)
Scala (compose) and (andThen)
More information about the Ur
mailing list