@@ -31,27 +31,38 @@ module Prelude
3131
3232 -- | An alias for `true`, which can be useful in guard clauses:
3333 -- |
34− -- | E.g.
34+ -- | ```purescript
35+ -- | max x y | x >= y = x
36+ -- | | otherwise = y
37+ -- | ```
3538 -- |
36− -- | max x y | x >= y = x
37− -- | | otherwise = y
3839 otherwise :: Boolean
3940 otherwise = true
4041
4142 -- | Flips the order of the arguments to a function of two arguments.
43+ -- |
44+ -- | ```purescript
45+ -- | flip const 1 2 = const 2 1 = 2
46+ -- | ```
47+ -- |
4248 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
4349 flip f b a = f a b
4450
4551 -- | Returns its first argument and ignores its second.
52+ -- |
53+ -- | ```purescript
54+ -- | const 1 "hello" = 1
55+ -- | ```
56+ -- |
4657 const :: forall a b. a -> b -> a
4758 const a _ = a
4859
4960 -- | This function returns its first argument, and can be used to assert type equalities.
5061 -- | This can be useful when types are otherwise ambiguous.
5162 -- |
52− -- | E.g.
53− -- |
54− -- | main = print $ [] `asTypeOf` [0]
63+ -- | ```purescript
64+ -- | main = print $ [] `asTypeOf` [0]
65+ -- | ```
5566 -- |
5667 -- | If instead, we had written `main = print []`, the type of the argument `[]` would have
5768 -- | been ambiguous, resulting in a compile-time error.
@@ -98,14 +109,50 @@ module Prelude
98109 infixr 0 $
99110 infixl 0 #
100111
112+ -- | Applies a function to its argument
113+ -- |
114+ -- | ```purescript
115+ -- | length $ groupBy productCategory $ filter isInStock products
116+ -- | ```
117+ -- |
118+ -- | is equivalent to
119+ -- |
120+ -- | ```purescript
121+ -- | length (groupBy productCategory (filter isInStock (products)))
122+ -- | ```
123+ -- |
124+ -- | `($)` is different from [`(#)`](#-2) because it is right-infix instead of left, so
125+ -- | `a $ b $ c $ d x` = `a (b (c (d x)))`
126+ -- |
101127 ($) :: forall a b. (a -> b) -> a -> b
102128 ($) f x = f x
103129
130+ -- | Applies a function to its argument
131+ -- |
132+ -- | ```purescript
133+ -- | products # groupBy productCategory # filter isInStock # length
134+ -- | ```
135+ -- |
136+ -- | is equivalent to
137+ -- |
138+ -- | ```purescript
139+ -- | length (groupBy productCategory (filter isInStock (products)))
140+ -- | ```
141+ -- |
142+ -- | `(#)` is different from [`($)`](#-1) because it is left-infix instead of right, so
143+ -- | `x # a # b # c # d` = `(((x a) b) c) d`
144+ -- |
104145 (#) :: forall a b. a -> (a -> b) -> b
105146 (#) x f = f x
106147
107148 infixr 6 :
108149
150+ -- | Attaches an element to the front of a list.
151+ -- |
152+ -- | ```purescript
153+ -- | 1 : [2, 3, 4] = [1, 2, 3, 4]
154+ -- | ```
155+ -- |
109156 (:) :: forall a. a -> [a] -> [a]
110157 (:) = cons
111158
@@ -452,7 +499,7 @@ module Prelude
452499 show LT = "LT"
453500 show GT = "GT"
454501 show EQ = "EQ"
455−
502+
456503 instance semigroupOrdening :: Semigroup Ordering where
457504 (<>) LT _ = LT
458505 (<>) GT _ = GT