on master help sign in
Improve docs for (.) a bit
12011d8Evan Czaplicki
libraries/Basics.elm+14−2
@@ -46,7 +46,7 @@ which happen to be radians.
46@docs fst, snd
46@docs fst, snd
47
47
48# Higher-Order Helpers
48# Higher-Order Helpers
49−@docs id, (<|), (|>), (.), always, flip, curry, uncurry
49+@docs id, always, (<|), (|>), (.), flip, curry, uncurry
50
50
51-}
51-}
52
52
@@ -301,7 +301,19 @@ isInfinite = Native.Basics.isInfinite
301
301
302-- Function Helpers
302-- Function Helpers
303
303
304−{-| Function composition: `(f . g == (\\x -> f (g x)))` -}
304+{-| Function composition. For example, the following code checks if the square
305+root of a number is odd:
306+
307+ not . isEven . sqrt
308+
309+You can think of this operator as equivalent to the following:
310+
311+ (f . g) == (\x -> f (g x))
312+
313+So our example is expanding things out to this:
314+
315+ \number -> not (isEven (sqrt number))
316+-}
305(.) : (b -> c) -> (a -> b) -> (a -> c)
317(.) : (b -> c) -> (a -> b) -> (a -> c)
306(.) f g x = f (g x)
318(.) f g x = f (g x)
307
319