git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
A start on #852
2b4b1b0Phil Freeman
prelude/README.md+16
@@ -276,6 +276,13 @@
276
276
277#### `asTypeOf`
277#### `asTypeOf`
278
278
279+This function returns its first argument, and can be used to assert type equalities.
280+This can be useful when types are otherwise ambiguous.
281+E.g.
282+ main = print $ [] `asTypeOf` [0]
283+If instead, we had written `main = print []`, the type of the argument `[]` would have
284+been ambiguous, resulting in a compile-time error.
285+
279 asTypeOf :: forall a. a -> a -> a
286 asTypeOf :: forall a. a -> a -> a
280
287
281#### `cons`
288#### `cons`
@@ -284,10 +291,14 @@
284
291
285#### `const`
292#### `const`
286
293
294+Returns its first argument and ignores its second.
295+
287 const :: forall a b. a -> b -> a
296 const :: forall a b. a -> b -> a
288
297
289#### `flip`
298#### `flip`
290
299
300+Flips the order of the arguments to a function of two arguments.
301+
291 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
302 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
292
303
293#### `liftA1`
304#### `liftA1`
@@ -300,6 +311,11 @@
300
311
301#### `otherwise`
312#### `otherwise`
302
313
314+An alias for `true`, which can be useful in guard clauses:
315+E.g.
316+ max x y | x >= y = x
317+ | otherwise = y
318+
303 otherwise :: Boolean
319 otherwise :: Boolean
304
320
305#### `refEq`
321#### `refEq`
prelude/prelude.purs+17
@@ -24,15 +24,32 @@ module Prelude
24 , Unit(..), unit
24 , Unit(..), unit
25 ) where
25 ) where
26
26
27+ -- | An alias for `true`, which can be useful in guard clauses:
28+ -- |
29+ -- | E.g.
30+ -- |
31+ -- | max x y | x >= y = x
32+ -- | | otherwise = y
27 otherwise :: Boolean
33 otherwise :: Boolean
28 otherwise = true
34 otherwise = true
29
35
36+ -- | Flips the order of the arguments to a function of two arguments.
30 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
37 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
31 flip f b a = f a b
38 flip f b a = f a b
32
39
40+ -- | Returns its first argument and ignores its second.
33 const :: forall a b. a -> b -> a
41 const :: forall a b. a -> b -> a
34 const a _ = a
42 const a _ = a
35
43
44+ -- | This function returns its first argument, and can be used to assert type equalities.
45+ -- | This can be useful when types are otherwise ambiguous.
46+ -- |
47+ -- | E.g.
48+ -- |
49+ -- | main = print $ [] `asTypeOf` [0]
50+ -- |
51+ -- | If instead, we had written `main = print []`, the type of the argument `[]` would have
52+ -- | been ambiguous, resulting in a compile-time error.
36 asTypeOf :: forall a. a -> a -> a
53 asTypeOf :: forall a. a -> a -> a
37 asTypeOf x _ = x
54 asTypeOf x _ = x
38
55