I am trying to modify the Elm example that shows a single spacer so that it renders multiple spacers of different colors:
import Color exposing (red, blue, yellow)
import Graphics.Element exposing (Element, color, spacer, flow, right)
colors = [ yellow, red, blue ]
presentColors : List Element
presentColors = List.map (color ??? (spacer 30 30)) colors
main : Element
main =
flow right presentColors
However as you can see the function color
takes the color argument first and so I cannot create a partially applied version of it for List.map
to use.
So how can I flip the arguments to color
so that it can be partially applied?
As of Elm 0.19, flip
is no longer included by default. The docs recommend named helper functions instead.
Go to the Elm (pre v0.19) libraries page. Press Standard Libraries. In the search box, type in flip
and click the function that comes up. That'll give you the documentation for
flip : (a -> b -> c) -> b -> a -> c
Flip the order of the first two arguments to a function.
With which you can do
flip color (spacer 30 30)
which is the same thing as
\c -> color c (spacer 30 30)
Flip was removed from elm/core in 0.19
. You could try:
pilatch/flip package instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With