git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
A start on #852
commit2b4b1b08991e7e773c52da713949d3be60e425a0 authorPhil Freeman <paf31@cantab.net> dateTue 10 Feb 2015, 14:15 (12 years ago) parentf78b8d5
2 files changed+33
prelude/README.md+16 prelude/prelude.purs+17
prelude/README.md+16
@@ -276,6 +276,13 @@
276276
277277#### `asTypeOf`
278278
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+
279286 asTypeOf :: forall a. a -> a -> a
280287
281288#### `cons`
@@ -284,10 +291,14 @@
284291
285292#### `const`
286293
294+Returns its first argument and ignores its second.
295+
287296 const :: forall a b. a -> b -> a
288297
289298#### `flip`
290299
300+Flips the order of the arguments to a function of two arguments.
301+
291302 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
292303
293304#### `liftA1`
@@ -300,6 +311,11 @@
300311
301312#### `otherwise`
302313
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+
303319 otherwise :: Boolean
304320
305321#### `refEq`
prelude/prelude.purs+17
@@ -24,15 +24,32 @@ module Prelude
2424 , Unit(..), unit
2525 ) where
2626
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
2733 otherwise :: Boolean
2834 otherwise = true
2935
36+ -- | Flips the order of the arguments to a function of two arguments.
3037 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
3138 flip f b a = f a b
3239
40+ -- | Returns its first argument and ignores its second.
3341 const :: forall a b. a -> b -> a
3442 const a _ = a
3543
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.
3653 asTypeOf :: forall a. a -> a -> a
3754 asTypeOf x _ = x
3855