@@ -24,15 +24,32 @@ module Prelude
24 , Unit(..), unit
24 , Unit(..), unit
27+ -- | An alias for `true`, which can be useful in guard clauses:
31+ -- | max x y | x >= y = x
27 otherwise :: Boolean
33 otherwise :: Boolean
28 otherwise = true
34 otherwise = true
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
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
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.
49+ -- | main = print $ [] `asTypeOf` [0]
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