@@ -36,26 +36,31 @@ toPolar (x,y) = (N.sqrt (x^2 + y^2), N.atan2 y x)
3636-- Integer division, remainder is discarded.
3737div : Int -> Int -> Int
3838
39−-- Finds the remainder after dividing one number by another: 4 `rem` 3 == 1
39+-- Finds the remainder after dividing one number by another: ``4 `rem` 3 == 1``
4040rem : Int -> Int -> Int
4141
42−-- Perform modular arithmetic: 7 `mod` 2 == 1
42+-- Perform modular arithmetic: ``7 `mod` 2 == 1``
4343mod : Int -> Int -> Int
4444
4545-- Exponentiation: `3^2 == 9`
4646(^) : Number a -> Number a -> Number a
4747
48−-- Basic functions of trigonometry.
4948cos : Float -> Float
5049sin : Float -> Float
5150tan : Float -> Float
5251acos : Float -> Float
5352asin : Float -> Float
53+
54+-- You probably do not want to use this. Because it takes `(y/x)` as the argument
55+-- there is no way to know where the negative signs come from so the resulting
56+-- angle is always between π/2 and -π/2 (in quadrants I and IV).
5457atan : Float -> Float
5558
56−-- Returns the arctangent of the quotient of its arguments in radians.
57−-- So `atan2 y x` computes the angle from the positive x-axis to the vector
58−-- starting at the origin and ending at (x,y).
59+-- This helps you find the angle of a cartesian coordinate.
60+-- You will almost certainly want to use this instead of `atan`.
61+-- So `atan2 y x` computes *atan(y/x)* but also keeps track of which
62+-- quadrant the angle should really be in. The result will be between
63+-- π and -π, giving you the full range of angles.
5964atan2 : Float -> Float -> Float
6065
6166-- Take the square root of a number.
@@ -67,12 +72,18 @@ abs : Number a -> Number a
6772-- Calculate the logarithm of a number with a given base: `logBase 10 100 == 2`
6873logBase : Number a -> Number a -> Number a
6974
70−-- Given two numbers, returns the smaller (or greater respectively).
75+-- Given two numbers, returns the smaller one.
7176min : Number a -> Number a -> Number a
77+
78+-- Given two numbers, returns the larger one.
7279max : Number a -> Number a -> Number a
7380
74−-- Clamps a number within a given range, so `clamp 100 200 x` is 200 for
75−-- x >= 200, 100 for x <= 100, and x for any 100 < x < 200
81+-- Clamps a number within a given range. With the expression `clamp 100 200 x`
82+-- the results are as follows:
83+--
84+-- * `100 if x < 100`
85+-- * ` x if 100 <= x < 200`
86+-- * `200 if 200 <= x`
7687clamp : Number a -> Number a -> Number a -> Number a
7788
7889-- An approximation of pi.
@@ -81,21 +92,22 @@ pi : Float
8192-- An approximation of e.
8293e : Float
8394
84−-- Compare any two values for structural equality and inequality.
85−-- Functions cannot be compared.
95+-- Compare any two values for structural equality. Functions cannot be compared.
8696(==) : a -> a -> Bool
8797(/=) : a -> a -> Bool
8898
89−-- Compare any two comparable values. Comparable values include String, Char,
90−-- Int, Float, Time, or a list or tuple containing comparable values.
91−-- These are also the only values that work as Dictionary keys or Set members.
9299(<) : Comparable a -> Comparable a -> Bool
93100(>) : Comparable a -> Comparable a -> Bool
94101(<=) : Comparable a -> Comparable a -> Bool
95102(>=) : Comparable a -> Comparable a -> Bool
96103
104+-- Compare any two comparable values. Comparable values include `String`, `Char`,
105+-- `Int`, `Float`, `Time`, or a list or tuple containing comparable values.
106+-- These are also the only values that work as `Dict` keys or `Set` members.
97107compare : Comparable a -> Comparable a -> Order
98108
109+-- Represents the relative ordering of two things.
110+-- The relations are less than, equal to, and greater than.
99111data Order = LT | EQ | GT
100112
101113-- The and operator. True if both inputs are True.
@@ -107,7 +119,7 @@ data Order = LT | EQ | GT
107119-- The exclusive-or operator. True if exactly one input is True.
108120xor : Bool -> Bool -> Bool
109121
110−-- Negate a boolean value: (not True == False) and (not False == True)
122+-- Negate a boolean value: `(not True == False)` and `(not False == True)`
111123not : Bool -> Bool
112124
113125-- Equal to true. Useful as the last case of a multi-way-if.
@@ -143,30 +155,30 @@ readFloat : String -> Maybe Float
143155
144156-- Function Helpers
145157
146−-- Function composition: f . g == (\x -> f (g x))
158+-- Function composition: `(f . g == (\\x -> f (g x)))`
147159(.) : (b -> c) -> (a -> b) -> (a -> c)
148160
149161-- Forward function application `x |> f == f x`. This function is useful
150162-- for avoiding parenthesis and writing code in a more natural way.
151163-- Consider the following code to create a pentagon:
152164--
153−-- scale 2 (move 100 100 (filled blue (ngon 5 30)))
165+-- scale 2 (move (10,10) (filled blue (ngon 5 30)))
154166--
155167-- This can also be written as:
156168--
157−-- ngon 5 30 |> filled blue
158−-- |> move 100 100
159−-- |> scale 2
169+-- ngon 5 30 |> filled blue
170+-- |> move (10,10)
171+-- |> scale 2
160172(|>) : a -> (a -> b) -> b
161173
162174-- Function application `f <| x == f x`. This function is useful for avoiding
163175-- parenthesis. Consider the following code to create a text element:
164176--
165−-- text (monospace (toText "code"))
177+-- text (monospace (toText "code"))
166178--
167179-- This can also be written as:
168180--
169−-- text . monospace <| toText "code"
181+-- text . monospace <| toText "code"
170182(<|) : (a -> b) -> a -> b
171183
172184-- Given a value, returns exactly the same value.