[erlang-questions] Pipe Operator in Erlang?

Pierre Fenoll pierrefenoll@REDACTED
Fri Jul 10 10:23:29 CEST 2015


Loic: what's wrong is you can't xref it, AFAIK.


Cheers,
-- 
Pierre Fenoll


On 10 July 2015 at 01:15, Loïc Hoguin <essen@REDACTED> wrote:

> On 07/10/2015 07:17 AM, Pierre Fenoll wrote:
>
>> A pipe operator would turn this structure-specific code into something
>> more readable and editable too.
>> Maybe like something like this:
>>
>>      NewContext = Context
>>          |> cb_context:set_doc(_, [])
>>          |> cb_context:set_resp_status(_, success)
>>          |> cb_context:set_resp_data(_, [])
>>          |> cb_context:set_resp_etag(_, undefined)
>>
>> Where m:f(_, A2) is fun (_1) -> m:f(_1, A2) end; thus redefining _ for
>> pipes (in non-matching contexts…).
>>
>
> What's wrong with this?
>
> NewContext = cb_context:set(#{doc=>[], resp_status=success...}, Context)
>
> Has less repetition/verbosity, is most likely faster, already works today,
> and you can also use a proplist if you're a map hater.
>
>
> --
> Loïc Hoguin
> http://ninenines.eu
> Author of The Erlanger Playbook,
> A book about software development using Erlang
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150710/bf05f753/attachment.htm>


More information about the erlang-questions mailing list