@@ -46,7 +46,7 @@ which happen to be radians.
46@docs fst, snd
46@docs fst, snd
48# Higher-Order Helpers
48# Higher-Order Helpers
49−@docs id, always, (<|), (|>), (.), flip, curry, uncurry
49+@docs id, always, (<|), (|>), (<<), (>>), flip, curry, uncurry
@@ -301,21 +301,32 @@ isInfinite = Native.Basics.isInfinite
302-- Function Helpers
302-- Function Helpers
304+{-| Function composition, passing results along in the suggested direction. For
304−{-| Function composition. For example, the following code checks if the square
305+example, the following code checks if the square root of a number is odd:
305−root of a number is odd:
307− not . isEven . sqrt
307+ not << isEven << sqrt
309You can think of this operator as equivalent to the following:
309You can think of this operator as equivalent to the following:
311− (f . g) == (\x -> f (g x))
311+ (g << f) == (\x -> g (f x))
313−So our example is expanding things out to this:
313+So our example expands out to something like this:
315− \number -> not (isEven (sqrt number))
315+ \n -> not (isEven (sqrt n))
317−(.) : (b -> c) -> (a -> b) -> (a -> c)
317+(<<) : (b -> c) -> (a -> b) -> (a -> c)
320+{-| Function composition, passing results along in the suggested direction. For
321+example, the following code checks if the square root of a number is odd:
323+ sqrt >> isEven >> not
325+This direction of function composition seems less pleasant than `(<<)` which
326+reads nicely in expressions like: `filter (not << isRegistered) students`
328+(>>) : (a -> b) -> (b -> c) -> (a -> c)
318−(.) f g x = f (g x)
329+(>>) f g x = g (f x)
320{-| Forward function application `x |> f == f x`. This function is useful
331{-| Forward function application `x |> f == f x`. This function is useful
321for avoiding parenthesis and writing code in a more natural way.
332for avoiding parenthesis and writing code in a more natural way.
@@ -344,7 +355,8 @@ This can also be written as:
344(<|) : (a -> b) -> a -> b
355(<|) : (a -> b) -> a -> b
345f <| x = f x
356f <| x = f x
347−infixr 9 .
358+infixr 9 <<
348infixr 0 <|
360infixr 0 <|
349infixl 0 |>
361infixl 0 |>