@@ -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