@@ -36,26 +36,31 @@ toPolar (x,y) = (N.sqrt (x^2 + y^2), N.atan2 y x)
36-- Integer division, remainder is discarded.
36-- Integer division, remainder is discarded.
37div : Int -> Int -> Int
37div : Int -> Int -> Int
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``
40rem : Int -> Int -> Int
40rem : Int -> Int -> Int
42−-- Perform modular arithmetic: 7 `mod` 2 == 1
42+-- Perform modular arithmetic: ``7 `mod` 2 == 1``
43mod : Int -> Int -> Int
43mod : Int -> Int -> Int
45-- Exponentiation: `3^2 == 9`
45-- Exponentiation: `3^2 == 9`
46(^) : Number a -> Number a -> Number a
46(^) : Number a -> Number a -> Number a
48−-- Basic functions of trigonometry.
49cos : Float -> Float
48cos : Float -> Float
50sin : Float -> Float
49sin : Float -> Float
51tan : Float -> Float
50tan : Float -> Float
52acos : Float -> Float
51acos : Float -> Float
53asin : Float -> Float
52asin : Float -> Float
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).
54atan : Float -> Float
57atan : Float -> Float
56−-- Returns the arctangent of the quotient of its arguments in radians.
59+-- This helps you find the angle of a cartesian coordinate.
57−-- So `atan2 y x` computes the angle from the positive x-axis to the vector
60+-- You will almost certainly want to use this instead of `atan`.
58−-- starting at the origin and ending at (x,y).
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.
59atan2 : Float -> Float -> Float
64atan2 : Float -> Float -> Float
61-- Take the square root of a number.
66-- Take the square root of a number.
@@ -67,12 +72,18 @@ abs : Number a -> Number a
67-- Calculate the logarithm of a number with a given base: `logBase 10 100 == 2`
72-- Calculate the logarithm of a number with a given base: `logBase 10 100 == 2`
68logBase : Number a -> Number a -> Number a
73logBase : Number a -> Number a -> Number a
70−-- Given two numbers, returns the smaller (or greater respectively).
75+-- Given two numbers, returns the smaller one.
71min : Number a -> Number a -> Number a
76min : Number a -> Number a -> Number a
78+-- Given two numbers, returns the larger one.
72max : Number a -> Number a -> Number a
79max : Number a -> Number a -> Number a
74−-- Clamps a number within a given range, so `clamp 100 200 x` is 200 for
81+-- Clamps a number within a given range. With the expression `clamp 100 200 x`
75−-- x >= 200, 100 for x <= 100, and x for any 100 < x < 200
82+-- the results are as follows:
85+-- * ` x if 100 <= x < 200`
86+-- * `200 if 200 <= x`
76clamp : Number a -> Number a -> Number a -> Number a
87clamp : Number a -> Number a -> Number a -> Number a
78-- An approximation of pi.
89-- An approximation of pi.
@@ -81,21 +92,22 @@ pi : Float
81-- An approximation of e.
92-- An approximation of e.
84−-- Compare any two values for structural equality and inequality.
95+-- Compare any two values for structural equality. Functions cannot be compared.
85−-- Functions cannot be compared.
86(==) : a -> a -> Bool
96(==) : a -> a -> Bool
87(/=) : a -> a -> Bool
97(/=) : a -> a -> Bool
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.
92(<) : Comparable a -> Comparable a -> Bool
99(<) : Comparable a -> Comparable a -> Bool
93(>) : Comparable a -> Comparable a -> Bool
100(>) : Comparable a -> Comparable a -> Bool
94(<=) : Comparable a -> Comparable a -> Bool
101(<=) : Comparable a -> Comparable a -> Bool
95(>=) : Comparable a -> Comparable a -> Bool
102(>=) : Comparable a -> Comparable a -> Bool
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.
97compare : Comparable a -> Comparable a -> Order
107compare : Comparable a -> Comparable a -> Order
109+-- Represents the relative ordering of two things.
110+-- The relations are less than, equal to, and greater than.
99data Order = LT | EQ | GT
111data Order = LT | EQ | GT
101-- The and operator. True if both inputs are True.
113-- The and operator. True if both inputs are True.
@@ -107,7 +119,7 @@ data Order = LT | EQ | GT
107-- The exclusive-or operator. True if exactly one input is True.
119-- The exclusive-or operator. True if exactly one input is True.
108xor : Bool -> Bool -> Bool
120xor : Bool -> Bool -> Bool
110−-- Negate a boolean value: (not True == False) and (not False == True)
122+-- Negate a boolean value: `(not True == False)` and `(not False == True)`
111not : Bool -> Bool
123not : Bool -> Bool
113-- Equal to true. Useful as the last case of a multi-way-if.
125-- Equal to true. Useful as the last case of a multi-way-if.
@@ -143,30 +155,30 @@ readFloat : String -> Maybe Float
144-- Function Helpers
156-- Function Helpers
146−-- Function composition: f . g == (\x -> f (g x))
158+-- Function composition: `(f . g == (\\x -> f (g x)))`
147(.) : (b -> c) -> (a -> b) -> (a -> c)
159(.) : (b -> c) -> (a -> b) -> (a -> c)
149-- Forward function application `x |> f == f x`. This function is useful
161-- Forward function application `x |> f == f x`. This function is useful
150-- for avoiding parenthesis and writing code in a more natural way.
162-- for avoiding parenthesis and writing code in a more natural way.
151-- Consider the following code to create a pentagon:
163-- Consider the following code to create a pentagon:
153−-- scale 2 (move 100 100 (filled blue (ngon 5 30)))
165+-- scale 2 (move (10,10) (filled blue (ngon 5 30)))
155-- This can also be written as:
167-- This can also be written as:
157−-- ngon 5 30 |> filled blue
169+-- ngon 5 30 |> filled blue
158−-- |> move 100 100
170+-- |> move (10,10)
159−-- |> scale 2
171+-- |> scale 2
160(|>) : a -> (a -> b) -> b
172(|>) : a -> (a -> b) -> b
162-- Function application `f <| x == f x`. This function is useful for avoiding
174-- Function application `f <| x == f x`. This function is useful for avoiding
163-- parenthesis. Consider the following code to create a text element:
175-- parenthesis. Consider the following code to create a text element:
165−-- text (monospace (toText "code"))
177+-- text (monospace (toText "code"))
167-- This can also be written as:
179-- This can also be written as:
169−-- text . monospace <| toText "code"
181+-- text . monospace <| toText "code"
170(<|) : (a -> b) -> a -> b
182(<|) : (a -> b) -> a -> b
172-- Given a value, returns exactly the same value.
184-- Given a value, returns exactly the same value.