# Infix operators sectioning

**URL:** <https://discourse.elm-lang.org/t/infix-operators-sectioning/7106>\
**Category:** Request Feedback\
**Created:** [March 16, 2021, 4:39pm UTC](https://discourse.elm-lang.org/t/infix-operators-sectioning/7106 "2021-03-16T16:39:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorgoroth](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/gorgoroth/32/3355_2.png) [@gorgoroth](https://discourse.elm-lang.org/u/gorgoroth)\
**Post date:** [March 16, 2021, 4:39pm UTC](https://discourse.elm-lang.org/t/infix-operators-sectioning/7106/1 "2021-03-16T16:39:23Z")

</div>

Is there a chance that ELM will support sectioning for the built-in infix operators?

If I’m not wrong, there is no way to do something like:

`List.map (^2) [1,2,3]`

or

`List.map (2^) [1,2,3]`

if not using a lambda:

`List.map (\v -> v^2) [1,2,3]`

or

`List.map (\v -> 2^v) [1,2,3]`

is this a feature that make sense in Elm?

---

<div class="post-metadata">

**Author:** ![pdamoc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pdamoc/32/36_2.png) [@pdamoc](https://discourse.elm-lang.org/u/pdamoc)\
**Post date:** [March 16, 2021, 4:59pm UTC](https://discourse.elm-lang.org/t/infix-operators-sectioning/7106/2 "2021-03-16T16:59:33Z")

</div>

You can raise a number to a set of powers by using the function format of the infix operator:

`List.map ((^) 2) [1,2,3]` (this would be the equivalent to what you are trying to do with `List.map (2^) [1,2,3]`

For the first version you need a flipped version of that function. The core used to have a function called `flip`

```elm
{-| Flip the order of the first two arguments to a function. -}
flip : (a -> b -> c) -> (b -> a -> c)
flip f b a =
  f a b

```

With this function you can write `List.map (flip (^) 2) [1,2,3]` as an equivalent to what you tried to do with `List.map (^2) [1,2,3]`. However, just because you can, it doesn’t mean that you should. I don’t think it looks good and if you do this enough, you will end up with very ugly code. `flip` was not removed without reason.

I would go for a lambda even for the first option.

> [@gorgoroth](#):
>
> is this a feature that make sense in Elm?

I don’t think it would encourage clear, easy to read code.

I’ve used infix operators as functions sometime in my code. It feels great in the moment, like a prize for solving a puzzle BUT, it does not make for easy to read code. If the goal is to feel good about myself while writing code… then stuff like this might help me reach my goal. If the goal is to feel good about myself 6 months from now while reading the code… at least in my case… this stuff would not help me reach my goal.

---

<div class="post-metadata">

**Author:** ![joelq](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/joelq/32/445_2.png) [@joelq](https://discourse.elm-lang.org/u/joelq)\
**Post date:** [March 16, 2021, 5:48pm UTC](https://discourse.elm-lang.org/t/infix-operators-sectioning/7106/3 "2021-03-16T17:48:34Z")

</div>

You are correct, Elm does not support sectioning and likely never will. Elm only offers limited support for infix operators (on purpose) and in general tries to push you towards using a lambda in situations like the one you’re describing.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [March 26, 2021, 5:49pm UTC](https://discourse.elm-lang.org/t/infix-operators-sectioning/7106/4 "2021-03-26T17:49:17Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
