File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -842,25 +842,26 @@ composeR f g x =
842842{- | Saying `x |> f` is exactly the same as `f x`.
843843
844844It is called the “pipe” operator because it lets you write “pipelined” code.
845- For example, say we have a `sanitize` function for turning user input in
846- degrees into integers. We can rewrite it like this:
847-
848- import Maybe
845+ For example, say we have a `sanitize` function for turning user input into
846+ integers:
849847
850848 -- BEFORE
851849 sanitize : String -> Maybe Int
852850 sanitize input =
853851 String.toInt (String.trim input)
854852
853+ We can rewrite it like this:
854+
855855 -- AFTER
856856 sanitize : String -> Maybe Int
857857 sanitize input =
858858 input
859859 |> String.trim
860860 |> String.toInt
861861
862- To get a better intuition, I recommend trying to rewrite code that uses `x |> f`
863- into code like `f x` until there are no pipes left.
862+ Totally equivalent! I recommend trying to rewrite code that uses `x |> f`
863+ into code like `f x` until there are no pipes left. That can help you build
864+ your intuition.
864865
865866**Note:** This can be overused! I think folks find it quite neat, but when you
866867have three or four steps, the code often gets clearer if you break out a
You can’t perform that action at this time.
0 commit comments