Plug isn't a great example, because it maps closer to a with than a
pipeline, because any step can halt the pipeline. The compilation stuff
removes the need for you to check if the pipeline is halted after each
step. What you would write would be something roughly like:

with {:ok, conn} <- accept(conn, "html"),
  {:ok, conn} <- fetch_session(conn),
  ... do
  #...
else
  {:halt, conn} ->
    #...
end

Allen Madsen
http://www.allenmadsen.com


On Wed, Oct 26, 2022 at 11:49 AM pragdave <pragd...@gmail.com> wrote:

>
>
> On Tuesday, October 25, 2022 at 9:56:14 PM UTC-5 dorga...@gmail.com wrote:
>
>> For the plugs example, how is it better than the alternative that exists
>> today?
>>
>
> Because it is written without the magic. The way Plug currently works is
> needlessly nonfunctional and opaque.  With this small change, we could turn
> it from "some compile time magic" into "just more code.
>
> Why write `Plug :accept, ["html"]` when you can just write
> `accept("html")` as part of a standard Elixir pipeline?
>
>
> Function composition is a key part of FP.
>>>
>> Agreed, but functional composition(h = g ∘ f) is not the way the
>> overwhelming majority of elixir code is written.
>>
>
> Of course, because Elixir doesn't support it. I'm suggesting a simple,
> non-breaking and noninvasice change that would add support. Then, in a
> year's time, we can see if there's any adoption.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/4debfa0c-7489-4e70-8025-be746a40d63an%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/4debfa0c-7489-4e70-8025-be746a40d63an%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3CsuhPxZpHVM4Gzhp-CdkBGbWhvL1AGvGGOKb6-8TbRLWA%40mail.gmail.com.

Reply via email to