[erlang-questions] Must and May convention
Richard A. O'Keefe
ok@REDACTED
Fri Sep 29 04:17:44 CEST 2017
On 29/09/17 5:49 AM, Vans S wrote:
>
> The 'fad' languages are very interesting testing grounds for ideas. A
> thing like the pipe operator has had many forms, but I'm not sure I'd
> call them a fad. They have existed in some form of other as:
The pipe operator is a very shallow thing indeed.
% fsi
> (|>);;
val it : ('a -> ('a -> 'b) -> 'b) = <fun:it@REDACTED>
There's really only one function with that type:
'T'(A, F) -> F(A).
It's the T combinator
(http://www.angelfire.com/tx4/cus/combinator/birds.html)
written as an infix operator.
The equivalent in Haskell is not monads but
flip ($), and the normal Haskell equivalent of
a |> f |> g |> h
is just
h $ g $ f $ a
or even
(h . g . f) a
There really isn't anything special about |> in a
functional language. The only real issue is whether
the syntax adapts well to user-defined combinators,
and Erlang syntax doesn't. That's purely a syntax
issue and says nothing about the soundness of the basic
model.
More information about the erlang-questions
mailing list