on master help sign in
Merge pull request #808 from mgold/doc-consistencies
da816d5Evan Czaplicki
libraries/Basics.elm+40−28
@@ -66,15 +66,11 @@ One turn is equal to 360°.
66turns : Float -> Float
66turns : Float -> Float
67turns = Native.Basics.turns
67turns = Native.Basics.turns
68
68
69−{-| Start with polar coordinates (r,θ)
69+{-| Convert polar coordinates (r,θ) to cartesian coordinates (x,y). -}
70−and get out cartesian coordinates (x,y).
71−-}
72fromPolar : (Float,Float) -> (Float,Float)
70fromPolar : (Float,Float) -> (Float,Float)
73fromPolar = Native.Basics.fromPolar
71fromPolar = Native.Basics.fromPolar
74
72
75−{-| Start with cartesian coordinates (x,y)
73+{-| Convert cartesian coordinates (x,y) to polar coordinates (r,θ). -}
76−and get out polar coordinates (r,θ).
77−-}
78toPolar : (Float,Float) -> (Float,Float)
74toPolar : (Float,Float) -> (Float,Float)
79toPolar = Native.Basics.toPolar
75toPolar = Native.Basics.toPolar
80
76
@@ -101,11 +97,11 @@ infixl 7 //
101infixl 7 %
97infixl 7 %
102infixl 7 `rem`
98infixl 7 `rem`
103
99
104−{-| Integer division, remainder is discarded. -}
100+{-| Integer division. The remainder is discarded. -}
105(//) : Int -> Int -> Int
101(//) : Int -> Int -> Int
106(//) = Native.Basics.div
102(//) = Native.Basics.div
107
103
108−{-| Finds the remainder after dividing one number by another:
104+{-| Find the remainder after dividing one number by another.
109
105
110 7 `rem` 2 == 1
106 7 `rem` 2 == 1
111 -1 `rem` 4 == -1
107 -1 `rem` 4 == -1
@@ -113,7 +109,7 @@ infixl 7 `rem`
113rem : Int -> Int -> Int
109rem : Int -> Int -> Int
114rem = Native.Basics.rem
110rem = Native.Basics.rem
115
111
116−{-| Perform [modular arithmetic](http://en.wikipedia.org/wiki/Modular_arithmetic):
112+{-| Perform [modular arithmetic](http://en.wikipedia.org/wiki/Modular_arithmetic).
117
113
118 7 % 2 == 1
114 7 % 2 == 1
119 -1 % 4 == 3
115 -1 % 4 == 3
@@ -121,7 +117,10 @@ rem = Native.Basics.rem
121(%) : Int -> Int -> Int
117(%) : Int -> Int -> Int
122(%) = Native.Basics.mod
118(%) = Native.Basics.mod
123
119
124−{-| Exponentiation: `3^2 == 9` -}
120+{-| Exponentiation
121+
122+ 3^2 == 9`
123+-}
125(^) : number -> number -> number
124(^) : number -> number -> number
126(^) = Native.Basics.exp
125(^) = Native.Basics.exp
127
126
@@ -161,7 +160,12 @@ atan2 = Native.Basics.atan2
161sqrt : Float -> Float
160sqrt : Float -> Float
162sqrt = Native.Basics.sqrt
161sqrt = Native.Basics.sqrt
163
162
164−{-| Negate any number: `negate 42 == -42` -}
163+{-| Negate a number.
164+
165+ negate 42 == -42
166+ negate -42 == 42
167+ negate 0 == 0
168+-}
165negate : number -> number
169negate : number -> number
166negate = Native.Basics.negate
170negate = Native.Basics.negate
167
171
@@ -169,7 +173,11 @@ negate = Native.Basics.negate
169abs : number -> number
173abs : number -> number
170abs = Native.Basics.abs
174abs = Native.Basics.abs
171
175
172−{-| Calculate the logarithm of a number with a given base: `logBase 10 100 == 2` -}
176+{-| Calculate the logarithm of a number with a given base.
177+
178+ logBase 10 100 == 2
179+ logBase 2 256 == 8
180+-}
173logBase : Float -> Float -> Float
181logBase : Float -> Float -> Float
174logBase = Native.Basics.logBase
182logBase = Native.Basics.logBase
175
183
@@ -228,22 +236,22 @@ The relations are less than, equal to, and greater than.
228-}
236-}
229data Order = LT | EQ | GT
237data Order = LT | EQ | GT
230
238
231−{-| Given two comparables, returns the smaller one. -}
239+{-| Find the smaller of two comparables. -}
232min : comparable -> comparable -> comparable
240min : comparable -> comparable -> comparable
233min = Native.Basics.min
241min = Native.Basics.min
234
242
235−{-| Given two comparables, returns the larger one. -}
243+{-| Find the larger of two comparables. -}
236max : comparable -> comparable -> comparable
244max : comparable -> comparable -> comparable
237max = Native.Basics.max
245max = Native.Basics.max
238
246
239−{-| The and operator. True if both inputs are True.
247+{-| The logical AND operator. `True` if both inputs are `True`.
240−This operator short-circuits if the first argument is False.
248+This operator short-circuits to `False` if the first argument is `False`.
241-}
249-}
242(&&) : Bool -> Bool -> Bool
250(&&) : Bool -> Bool -> Bool
243(&&) = Native.Basics.and
251(&&) = Native.Basics.and
244
252
245−{-| The or operator. True if one or both inputs are True.
253+{-| The logical OR operator. `True` if one or both inputs are `True`.
246−This operator short-circuits if the first argument is True.
254+This operator short-circuits to `True` if the first argument is True.
247-}
255-}
248(||) : Bool -> Bool -> Bool
256(||) : Bool -> Bool -> Bool
249(||) = Native.Basics.or
257(||) = Native.Basics.or
@@ -251,15 +259,19 @@ This operator short-circuits if the first argument is True.
251infixr 3 &&
259infixr 3 &&
252infixr 2 ||
260infixr 2 ||
253
261
254−{-| The exclusive-or operator. True if exactly one input is True. -}
262+{-| The exclusive-or operator. `True` if exactly one input is `True`. -}
255xor : Bool -> Bool -> Bool
263xor : Bool -> Bool -> Bool
256xor = Native.Basics.xor
264xor = Native.Basics.xor
257
265
258−{-| Negate a boolean value: `(not True == False)` and `(not False == True)` -}
266+{-| Negate a boolean value.
267+
268+ not True == False
269+ not False == True
270+-}
259not : Bool -> Bool
271not : Bool -> Bool
260not = Native.Basics.not
272not = Native.Basics.not
261
273
262−{-| Equal to true. Useful as the last case of a multi-way-if. -}
274+{-| Equal to `True`. Useful as the last case of a multi-way-if. -}
263otherwise : Bool
275otherwise : Bool
264otherwise = True
276otherwise = True
265
277
@@ -270,7 +282,7 @@ otherwise = True
270round : Float -> Int
282round : Float -> Int
271round = Native.Basics.round
283round = Native.Basics.round
272
284
273−{-| Truncate a decimal number, rounding towards zero. -}
285+{-| Truncate a number, rounding towards zero. -}
274truncate : Float -> Int
286truncate : Float -> Int
275truncate = Native.Basics.truncate
287truncate = Native.Basics.truncate
276
288
@@ -286,7 +298,7 @@ ceiling = Native.Basics.ceiling
286toFloat : Int -> Float
298toFloat : Int -> Float
287toFloat = Native.Basics.toFloat
299toFloat = Native.Basics.toFloat
288
300
289−{- | Determines whether a float is an undefined or unrepresentable number.
301+{- | Determine whether a float is an undefined or unrepresentable number.
290NaN stands for *not a number* and it is [a standardized part of floating point
302NaN stands for *not a number* and it is [a standardized part of floating point
291numbers](http://en.wikipedia.org/wiki/NaN).
303numbers](http://en.wikipedia.org/wiki/NaN).
292
304
@@ -298,7 +310,7 @@ numbers](http://en.wikipedia.org/wiki/NaN).
298isNaN : Float -> Bool
310isNaN : Float -> Bool
299isNaN = Native.Basics.isNaN
311isNaN = Native.Basics.isNaN
300
312
301−{- | Determines whether a float is positive or negative infinity.
313+{- | Determine whether a float is positive or negative infinity.
302
314
303 isInfinite (0/0) == False
315 isInfinite (0/0) == False
304 isInfinite (sqrt -1) == False
316 isInfinite (sqrt -1) == False
@@ -355,8 +367,8 @@ This can also be written as:
355(|>) : a -> (a -> b) -> b
367(|>) : a -> (a -> b) -> b
356x |> f = f x
368x |> f = f x
357
369
358−{-| Function application `f <| x == f x`. This function is useful for avoiding
370+{-| Backward function application `f <| x == f x`. This function is useful for
359−parenthesis. Consider the following code to create a text element:
371+avoiding parenthesis. Consider the following code to create a text element:
360
372
361 text (monospace (toText "code"))
373 text (monospace (toText "code"))
362
374
@@ -378,7 +390,7 @@ infixl 0 |>
378identity : a -> a
390identity : a -> a
379identity x = x
391identity x = x
380
392
381−{-| Creates a [constant function](http://en.wikipedia.org/wiki/Constant_function),
393+{-| Create a [constant function](http://en.wikipedia.org/wiki/Constant_function),
382a function that *always* returns the same value regardless of what input you give.
394a function that *always* returns the same value regardless of what input you give.
383It is defined as:
395It is defined as:
384
396
@@ -402,7 +414,7 @@ fst (a,_) = a
402snd : (a,b) -> b
414snd : (a,b) -> b
403snd (_,b) = b
415snd (_,b) = b
404
416
405−{-| Flips the order of the first two arguments to a function. -}
417+{-| Flip the order of the first two arguments to a function. -}
406flip : (a -> b -> c) -> (b -> a -> c)
418flip : (a -> b -> c) -> (b -> a -> c)
407flip f b a = f a b
419flip f b a = f a b
408
420
libraries/Date.elm+1−1
@@ -36,7 +36,7 @@ read = Native.Date.read
36toTime : Date -> Time
36toTime : Date -> Time
37toTime = Native.Date.toTime
37toTime = Native.Date.toTime
38
38
39−{-| Take a UNIX time and convert it to a `Date` -}
39+{-| Take a UNIX time and convert it to a `Date`. -}
40fromTime : Time -> Date
40fromTime : Time -> Date
41fromTime = Native.Date.fromTime
41fromTime = Native.Date.fromTime
42
42
libraries/List.elm+82−29
@@ -41,11 +41,15 @@ import Basics (..)
41import Maybe ( Maybe(Just,Nothing) )
41import Maybe ( Maybe(Just,Nothing) )
42import Native.List
42import Native.List
43
43
44−{-| Add an element to the front of a list `(1 :: [2,3] == [1,2,3])` -}
44+{-| Add an element to the front of a list. Pronounced *cons*.
45+
46+ 1 :: [2,3] == [1,2,3]
47+ 1 :: [] == [1]
48+-}
45(::) : a -> [a] -> [a]
49(::) : a -> [a] -> [a]
46(::) = Native.List.cons
50(::) = Native.List.cons
47
51
48−{-| Puts two appendable things together:
52+{-| Put two appendable things together.
49
53
50 [1,1] ++ [2,3] == [1,1,2,3]
54 [1,1] ++ [2,3] == [1,1,2,3]
51 "abc" ++ "123" == "abc123"
55 "abc" ++ "123" == "abc123"
@@ -57,31 +61,40 @@ infixr 5 ::
57infixr 5 ++
61infixr 5 ++
58
62
59{-| Extract the first element of a list. List must be non-empty.
63{-| Extract the first element of a list. List must be non-empty.
64+
60−`(head [1,2,3] == 1)`
65+ head [1,2,3] == 1
61-}
66-}
62head : [a] -> a
67head : [a] -> a
63head = Native.List.head
68head = Native.List.head
64
69
65{-| Extract the elements after the head of the list. List must be non-empty.
70{-| Extract the elements after the head of the list. List must be non-empty.
71+
66−`(tail [1,2,3] == [2,3])`
72+ tail [1,2,3] == [2,3]
67-}
73-}
68tail : [a] -> [a]
74tail : [a] -> [a]
69tail = Native.List.tail
75tail = Native.List.tail
70
76
71{-| Extract the last element of a list. List must be non-empty.
77{-| Extract the last element of a list. List must be non-empty.
78+
72−`(last [1,2,3] == 3)`
79+ last [1,2,3] == 3
73-}
80-}
74last : [a] -> a
81last : [a] -> a
75last = Native.List.last
82last = Native.List.last
76
83
84+{-| Determine if a list is empty.
85+
77−{-| Check if a list is empty `(isEmpty [] == True)` -}
86+ isEmpty [] == True
87+-}
78isEmpty : [a] -> Bool
88isEmpty : [a] -> Bool
79isEmpty xs =
89isEmpty xs =
80 case xs of
90 case xs of
81 [] -> True
91 [] -> True
82 _ -> False
92 _ -> False
83
93
84−{-| Apply a function to every element of a list: `(map sqrt [1,4,9] == [1,2,3])` -}
94+{-| Apply a function to every element of a list.
95+
96+ map sqrt [1,4,9] == [1,2,3]
97+-}
85map : (a -> b) -> [a] -> [b]
98map : (a -> b) -> [a] -> [b]
86map = Native.List.map
99map = Native.List.map
87
100
@@ -94,11 +107,17 @@ indexedMap : (Int -> a -> b) -> [a] -> [b]
94indexedMap f xs =
107indexedMap f xs =
95 zipWith f [ 0 .. length xs - 1 ] xs
108 zipWith f [ 0 .. length xs - 1 ] xs
96
109
97−{-| Reduce a list from the left: `(foldl (::) [] [1,2,3] == [3,2,1])` -}
110+{-| Reduce a list from the left.
111+
112+ foldl (::) [] [1,2,3] == [3,2,1]
113+-}
98foldl : (a -> b -> b) -> b -> [a] -> b
114foldl : (a -> b -> b) -> b -> [a] -> b
99foldl = Native.List.foldl
115foldl = Native.List.foldl
100
116
101−{-| Reduce a list from the right: `(foldr (+) 0 [1,2,3] == 6)` -}
117+{-| Reduce a list from the right.
118+
119+ foldr (+) 0 [1,2,3] == 6
120+-}
102foldr : (a -> b -> b) -> b -> [a] -> b
121foldr : (a -> b -> b) -> b -> [a] -> b
103foldr = Native.List.foldr
122foldr = Native.List.foldr
104
123
@@ -124,8 +143,9 @@ scanl = Native.List.scanl
124scanl1 : (a -> a -> a) -> [a] -> [a]
143scanl1 : (a -> a -> a) -> [a] -> [a]
125scanl1 = Native.List.scanl1
144scanl1 = Native.List.scanl1
126
145
127−{-| Keep only elements that satisfy the predicate:
146+{-| Keep only elements that satisfy the predicate.
147+
128−`(filter isEven [1..6] == [2,4,6])`
148+ filter isEven [1..6] == [2,4,6]
129-}
149-}
130filter : (a -> Bool) -> [a] -> [a]
150filter : (a -> Bool) -> [a] -> [a]
131filter = Native.List.filter
151filter = Native.List.filter
@@ -133,9 +153,9 @@ filter = Native.List.filter
133{-| Apply a function that may succeed to all values in the list, but only keep
153{-| Apply a function that may succeed to all values in the list, but only keep
134the successes.
154the successes.
135
155
136− toInt : String -> Maybe Int
156+ String.toInt : String -> Maybe Int
137
157
138− filterMap toInt ["3", "4.0", "5", "hats"] == [3,5]
158+ filterMap String.toInt ["3", "4.0", "5", "hats"] == [3,5]
139-}
159-}
140filterMap : (a -> Maybe b) -> [a] -> [b]
160filterMap : (a -> Maybe b) -> [a] -> [b]
141filterMap f xs = foldr (maybeCons f) [] xs
161filterMap f xs = foldr (maybeCons f) [] xs
@@ -146,19 +166,35 @@ maybeCons f mx xs =
146 Just x -> x :: xs
166 Just x -> x :: xs
147 Nothing -> xs
167 Nothing -> xs
148
168
149−{-| Determine the length of a list: `(length [1,2,3] == 3)` -}
169+{-| Determine the length of a list.
170+
171+ length [1,2,3] == 3
172+-}
150length : [a] -> Int
173length : [a] -> Int
151length = Native.List.length
174length = Native.List.length
152
175
176+{-| Reverse a list.
177+
153−{-| Reverse a list. `(reverse [1..4] == [4,3,2,1])` -}
178+ reverse [1..4] == [4,3,2,1]
179+-}
154reverse : [a] -> [a]
180reverse : [a] -> [a]
155reverse = Native.List.reverse
181reverse = Native.List.reverse
156
182
157−{-| Check to see if all elements satisfy the predicate. -}
183+{-| Determine if all elements satisfy the predicate.
184+
185+ all isEven [2,4] == True
186+ all isEven [2,3] == False
187+ all isEven [] == True
188+-}
158all : (a -> Bool) -> [a] -> Bool
189all : (a -> Bool) -> [a] -> Bool
159all = Native.List.all
190all = Native.List.all
160
191
161−{-| Check to see if any elements satisfy the predicate. -}
192+{-| Determine if any elements satisfy the predicate.
193+
194+ any isEven [2,3] == True
195+ any isEven [1,3] == False
196+ any isEven [] == False
197+-}
162any : (a -> Bool) -> [a] -> Bool
198any : (a -> Bool) -> [a] -> Bool
163any = Native.List.any
199any = Native.List.any
164
200
@@ -177,19 +213,28 @@ concat = Native.List.concat
177concatMap : (a -> appendable) -> [a] -> appendable
213concatMap : (a -> appendable) -> [a] -> appendable
178concatMap f list = concat (map f list)
214concatMap f list = concat (map f list)
179
215
180−{-| Get the sum of the list elements. `(sum [1..4] == 10)` -}
216+{-| Get the sum of the list elements.
217+
218+ sum [1..4] == 10
219+-}
181sum : [number] -> number
220sum : [number] -> number
182sum = foldl (+) 0
221sum = foldl (+) 0
183
222
184−{-| Get the product of the list elements. `(product [1..4] == 24)` -}
223+{-| Get the product of the list elements.
224+ product [1..4] == 24
225+-}
185product : [number] -> number
226product : [number] -> number
186product = foldl (*) 1
227product = foldl (*) 1
187
228
188−{-| Find the maximum element in a non-empty list: `maximum [1,4,2] == 4` -}
229+{-| Find the maximum element in a non-empty list.
230+ maximum [1,4,2] == 4
231+-}
189maximum : [comparable] -> comparable
232maximum : [comparable] -> comparable
190maximum = foldl1 max
233maximum = foldl1 max
191
234
192−{-| Find the minimum element in a non-empty list: `minimum [3,2,1] == 1` -}
235+{-| Find the minimum element in a non-empty list.
236+ minimum [3,2,1] == 1
237+-}
193minimum : [comparable] -> comparable
238minimum : [comparable] -> comparable
194minimum = foldl1 min
239minimum = foldl1 min
195
240
@@ -242,7 +287,7 @@ zipWith4 = Native.List.zipWith4
242zipWith5 : (a -> b -> c -> d -> e -> x) -> [a] -> [b] -> [c] -> [d] -> [e] -> [x]
287zipWith5 : (a -> b -> c -> d -> e -> x) -> [a] -> [b] -> [c] -> [d] -> [e] -> [x]
243zipWith5 = Native.List.zipWith5
288zipWith5 = Native.List.zipWith5
244
289
245−{-| Decompose a list of tuples.
290+{-| Decompose a list of tuples into a tuple of lists.
246
291
247 unzip [(0, True), (17, False), (1337, True)] == ([0,17,1337], [True,False,True])
292 unzip [(0, True), (17, False), (1337, True)] == ([0,17,1337], [True,False,True])
248-}
293-}
@@ -251,8 +296,7 @@ unzip =
251 let step (x,y) (xs, ys) = (x::xs, y::ys)
296 let step (x,y) (xs, ys) = (x::xs, y::ys)
252 in foldr step ([], [])
297 in foldr step ([], [])
253
298
254−{-| Places the given value between all of the lists in the second
255−argument and concatenates the result.
299+{-| Place a value between all elements in a list and concatenates the result.
256
300
257 join "a" ["H","w","ii","n"] == "Hawaiian"
301 join "a" ["H","w","ii","n"] == "Hawaiian"
258-}
302-}
@@ -272,21 +316,30 @@ intersperse sep xs =
272 spersed = foldr step [] tl
316 spersed = foldr step [] tl
273 in hd :: spersed
317 in hd :: spersed
274
318
275−{-| Take the first n members of a list: `(take 2 [1,2,3,4] == [1,2])` -}
319+{-| Take the first *n* members of a list.
320+
321+ take 2 [1,2,3,4] == [1,2]
322+-}
276take : Int -> [a] -> [a]
323take : Int -> [a] -> [a]
277take = Native.List.take
324take = Native.List.take
278
325
279−{-| Drop the first n members of a list: `(drop 2 [1,2,3,4] == [3,4])` -}
326+{-| Drop the first *n* members of a list.
327+
328+ drop 2 [1,2,3,4] == [3,4]
329+-}
280drop : Int -> [a] -> [a]
330drop : Int -> [a] -> [a]
281drop = Native.List.drop
331drop = Native.List.drop
282
332
283−{-| Creates a list with *n* copies of a value:
333+{-| Create a list with *n* copies of a value:
334+
284−`(repeat 3 (0,0) == [(0,0),(0,0),(0,0)]`
335+ repeat 3 (0,0) == [(0,0),(0,0),(0,0)]
285-}
336-}
286repeat : Int -> a -> [a]
337repeat : Int -> a -> [a]
287repeat = Native.List.repeat
338repeat = Native.List.repeat
288
339
289−{-| Sort values from lowest to highest: `sort [3,1,5] == [1,3,5]`
340+{-| Sort values from lowest to highest
341+
342+ sort [3,1,5] == [1,3,5]
290-}
343-}
291sort : [comparable] -> [comparable]
344sort : [comparable] -> [comparable]
292sort = Native.List.sort
345sort = Native.List.sort
libraries/String.elm+12−12
@@ -32,7 +32,7 @@ import Native.Show
32import Native.String
32import Native.String
33import Maybe (Maybe)
33import Maybe (Maybe)
34
34
35−{-| Check if a string is empty.
35+{-| Determine if a string is empty.
36
36
37 isEmpty "" == True
37 isEmpty "" == True
38 isEmpty "the world" == False
38 isEmpty "the world" == False
@@ -40,7 +40,7 @@ import Maybe (Maybe)
40isEmpty : String -> Bool
40isEmpty : String -> Bool
41isEmpty = Native.String.isEmpty
41isEmpty = Native.String.isEmpty
42
42
43−{-| Add a character to the beginning of a string -}
43+{-| Add a character to the beginning of a string. -}
44cons : Char -> String -> String
44cons : Char -> String -> String
45cons = Native.String.cons
45cons = Native.String.cons
46
46
@@ -84,7 +84,7 @@ length = Native.String.length
84map : (Char -> Char) -> String -> String
84map : (Char -> Char) -> String -> String
85map = Native.String.map
85map = Native.String.map
86
86
87−{-| Keep only the characters that satisfy the predicate:
87+{-| Keep only the characters that satisfy the predicate.
88
88
89 filter isDigit "R2-D2" == "22"
89 filter isDigit "R2-D2" == "22"
90-}
90-}
@@ -98,14 +98,14 @@ filter = Native.String.filter
98reverse : String -> String
98reverse : String -> String
99reverse = Native.String.reverse
99reverse = Native.String.reverse
100
100
101−{-| Reduce a string from the left:
101+{-| Reduce a string from the left.
102
102
103 foldl cons "" "time" == "emit"
103 foldl cons "" "time" == "emit"
104-}
104-}
105foldl : (Char -> b -> b) -> b -> String -> b
105foldl : (Char -> b -> b) -> b -> String -> b
106foldl = Native.String.foldl
106foldl = Native.String.foldl
107
107
108−{-| Reduce a string from the right:
108+{-| Reduce a string from the right.
109
109
110 foldr cons "" "time" == "time"
110 foldr cons "" "time" == "time"
111-}
111-}
@@ -131,7 +131,7 @@ split = Native.String.split
131join : String -> [String] -> String
131join : String -> [String] -> String
132join = Native.String.join
132join = Native.String.join
133
133
134−{-| Repeat a string N times.
134+{-| Repeat a string *n* times.
135
135
136 repeat 3 "ha" == "hahaha"
136 repeat 3 "ha" == "hahaha"
137-}
137-}
@@ -149,19 +149,19 @@ are taken starting from the *end* of the list.
149slice : Int -> Int -> String -> String
149slice : Int -> Int -> String -> String
150slice = Native.String.slice
150slice = Native.String.slice
151
151
152−{-| Take N characters from the left side of a string. -}
152+{-| Take *n* characters from the left side of a string. -}
153left : Int -> String -> String
153left : Int -> String -> String
154left = Native.String.left
154left = Native.String.left
155
155
156−{-| Take N characters from the right side of a string. -}
156+{-| Take *n* characters from the right side of a string. -}
157right : Int -> String -> String
157right : Int -> String -> String
158right = Native.String.right
158right = Native.String.right
159
159
160−{-| Drop N characters from the left side of a string. -}
160+{-| Drop *n* characters from the left side of a string. -}
161dropLeft : Int -> String -> String
161dropLeft : Int -> String -> String
162dropLeft = Native.String.dropLeft
162dropLeft = Native.String.dropLeft
163
163
164−{-| Drop N characters from the right side of a string. -}
164+{-| Drop *n* characters from the right side of a string. -}
165dropRight : Int -> String -> String
165dropRight : Int -> String -> String
166dropRight = Native.String.dropRight
166dropRight = Native.String.dropRight
167
167
@@ -237,7 +237,7 @@ toUpper = Native.String.toUpper
237toLower : String -> String
237toLower : String -> String
238toLower = Native.String.toLower
238toLower = Native.String.toLower
239
239
240−{-| Check to see if *any* characters satisfy a predicate.
240+{-| Determine whether *any* characters satisfy a predicate.
241
241
242 any isDigit "90210" == True
242 any isDigit "90210" == True
243 any isDigit "R2-D2" == True
243 any isDigit "R2-D2" == True
@@ -246,7 +246,7 @@ toLower = Native.String.toLower
246any : (Char -> Bool) -> String -> Bool
246any : (Char -> Bool) -> String -> Bool
247any = Native.String.any
247any = Native.String.any
248
248
249−{-| Check to see if *all* characters satisfy a predicate.
249+{-| Determine whether *all* characters satisfy a predicate.
250
250
251 all isDigit "90210" == True
251 all isDigit "90210" == True
252 all isDigit "R2-D2" == False
252 all isDigit "R2-D2" == False
libraries/Text.elm+21−24
@@ -49,11 +49,10 @@ or a strike out text:
49-}
49-}
50data Line = Under | Over | Through
50data Line = Under | Over | Through
51
51
52−{-| Representation of all the ways you can style `Text`. If the `typeface` list
52+{-| Represents all the ways you can style `Text`. If the `typeface` list is
53−is empty or the `height` is `Nothing`, the users will fall back on their
53+empty or the `height` is `Nothing`, the users will fall back on their browser's
54−browser's default settings. The following `Style` is black, 16 pixel tall,
54+default settings. The following `Style` is black, 16 pixel tall, underlined, and
55−underlined, and Times New Roman (assuming that typeface is available on the
55+Times New Roman (assuming that typeface is available on the user's computer):
56−user's computer):
57
56
58 { typeface = [ "Times New Roman", "serif" ]
57 { typeface = [ "Times New Roman", "serif" ]
59 , height = Just 16
58 , height = Just 16
@@ -73,7 +72,7 @@ type Style =
73 }
72 }
74
73
75{-| Plain black text. It uses the browsers default typeface and text height.
74{-| Plain black text. It uses the browsers default typeface and text height.
76−No decorations are used:
75+No decorations are used.
77
76
78 { typeface = []
77 { typeface = []
79 , height = Nothing
78 , height = Nothing
@@ -129,42 +128,42 @@ typeface = Native.Text.typeface
129monospace : Text -> Text
128monospace : Text -> Text
130monospace = Native.Text.monospace
129monospace = Native.Text.monospace
131
130
132−{-| Create a link by providing a URL and the text of the link:
131+{-| Create a link by providing a URL and the text of the link.
133
132
134 link "http://elm-lang.org" (toText "Elm Website")
133 link "http://elm-lang.org" (toText "Elm Website")
135-}
134-}
136link : String -> Text -> Text
135link : String -> Text -> Text
137link = Native.Text.link
136link = Native.Text.link
138
137
139−{-| Set the height of some text:
138+{-| Set the height of some text.
140
139
141 height 40 (toText "Title")
140 height 40 (toText "Title")
142-}
141-}
143height : Float -> Text -> Text
142height : Float -> Text -> Text
144height = Native.Text.height
143height = Native.Text.height
145
144
146−{-| Set the color of some text:
145+{-| Set the color of some text.
147
146
148 color red (toText "Red")
147 color red (toText "Red")
149-}
148-}
150color : Color -> Text -> Text
149color : Color -> Text -> Text
151color = Native.Text.color
150color = Native.Text.color
152
151
153−{-| Make text bold:
152+{-| Make text bold.
154
153
155 toText "sometimes you want " ++ bold (toText "emphasis")
154 toText "sometimes you want " ++ bold (toText "emphasis")
156-}
155-}
157bold : Text -> Text
156bold : Text -> Text
158bold = Native.Text.bold
157bold = Native.Text.bold
159
158
160−{-| Make text italic:
159+{-| Make text italic.
161
160
162 toText "make it " ++ italic (toText "important")
161 toText "make it " ++ italic (toText "important")
163-}
162-}
164italic : Text -> Text
163italic : Text -> Text
165italic = Native.Text.italic
164italic = Native.Text.italic
166
165
167−{-| Put lines on text:
166+{-| Put lines on text.
168
167
169 line Under (toText "underlined")
168 line Under (toText "underlined")
170 line Over (toText "overlined")
169 line Over (toText "overlined")
@@ -173,31 +172,31 @@ italic = Native.Text.italic
173line : Line -> Text -> Text
172line : Line -> Text -> Text
174line = Native.Text.line
173line = Native.Text.line
175
174
176−{-| `Text` is aligned along the left side of the text block. This is sometimes
175+{-| Align text along the left side of the text block. This is sometimes known as
177−known as *ragged right*.
176+*ragged right*.
178-}
177-}
179leftAligned : Text -> Element
178leftAligned : Text -> Element
180leftAligned = Native.Text.leftAligned
179leftAligned = Native.Text.leftAligned
181
180
182−{-| `Text` is aligned along the right side of the text block. This is sometimes
181+{-| Align text along the right side of the text block. This is sometimes known
183−known as *ragged left*.
182+as *ragged left*.
184-}
183-}
185rightAligned : Text -> Element
184rightAligned : Text -> Element
186rightAligned = Native.Text.rightAligned
185rightAligned = Native.Text.rightAligned
187
186
188−{-| `Text` is centered in the text block. There is equal spacing on either side
187+{-| Center text in the text block. There is equal spacing on either side of a
189−of a line of text.
188+line of text.
190-}
189-}
191centered : Text -> Element
190centered : Text -> Element
192centered = Native.Text.centered
191centered = Native.Text.centered
193
192
194−{-| `Text` is aligned along the left and right sides of the text block. Word
193+{-| Align text along the left and right sides of the text block. Word spacing is
195−spacing is adjusted to make this possible.
194+adjusted to make this possible.
196-}
195-}
197justified : Text -> Element
196justified : Text -> Element
198justified = Native.Text.justified
197justified = Native.Text.justified
199
198
200−{-| Display a string with no styling:
199+{-| Display a string with no styling.
201
200
202 plainText string = leftAligned (toText string)
201 plainText string = leftAligned (toText string)
203-}
202-}
@@ -210,11 +209,9 @@ markdown : Element
210markdown = Native.Text.markdown
209markdown = Native.Text.markdown
211
210
212{-| Convert anything to its textual representation and make it displayable in
211{-| Convert anything to its textual representation and make it displayable in
213−the browser:
212+the browser. Excellent for debugging.
214
213
215 asText value = leftAligned (monospace (toText (show value)))
214 asText value = leftAligned (monospace (toText (show value)))
216−
217−Excellent for debugging.
218-}
215-}
219asText : a -> Element
216asText : a -> Element
220asText value =
217asText value =
libraries/Transform2D.elm+12−10
@@ -34,7 +34,7 @@ base case.
34identity : Transform2D
34identity : Transform2D
35identity = Native.Transform2D.identity
35identity = Native.Transform2D.identity
36
36
37−{-| Creates a transformation matrix. This lets you create transforms
37+{-| Create a transformation matrix. This lets you create transforms
38such as scales, shears, reflections, and translations.
38such as scales, shears, reflections, and translations.
39
39
40 matrix a b c d x y
40 matrix a b c d x y
@@ -47,18 +47,20 @@ Note that `x` and `y` are the translation values.
47matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
47matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
48matrix = Native.Transform2D.matrix
48matrix = Native.Transform2D.matrix
49
49
50−{-| Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
50+{-| Create a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
51Given an angle t, it creates a counterclockwise rotation matrix:
51Given an angle t, it creates a counterclockwise rotation matrix:
52
52
53+ rotation t
54+
53 / cos t -sin t 0 \
55 / cos t -sin t 0 \
54 \ sin t cos t 0 /
56 \ sin t cos t 0 /
55-}
57-}
56rotation : Float -> Transform2D
58rotation : Float -> Transform2D
57rotation = Native.Transform2D.rotation
59rotation = Native.Transform2D.rotation
58
60
59−{-| Creates a transformation matrix for translation:
61+{-| Create a transformation matrix for translation.
60
62
61− translation x y
63+ translation x y
62
64
63 / 1 0 x \
65 / 1 0 x \
64 \ 0 1 y /
66 \ 0 1 y /
@@ -66,9 +68,9 @@ rotation = Native.Transform2D.rotation
66translation : Float -> Float -> Transform2D
68translation : Float -> Float -> Transform2D
67translation x y = matrix 1 0 0 1 x y
69translation x y = matrix 1 0 0 1 x y
68
70
69−{-| Creates a transformation matrix for scaling by a all directions:
71+{-| Creates a transformation matrix for scaling by a all directions.
70
72
71− scale s
73+ scale s
72
74
73 / s 0 0 \
75 / s 0 0 \
74 \ 0 s 0 /
76 \ 0 s 0 /
@@ -76,17 +78,17 @@ translation x y = matrix 1 0 0 1 x y
76scale : Float -> Transform2D
78scale : Float -> Transform2D
77scale s = matrix s 0 0 s 0 0
79scale s = matrix s 0 0 s 0 0
78
80
79−{-| Creates a transformation for horizontal scaling -}
81+{-| Create a transformation for horizontal scaling. -}
80scaleX : Float -> Transform2D
82scaleX : Float -> Transform2D
81scaleX x = matrix x 0 0 1 0 0
83scaleX x = matrix x 0 0 1 0 0
82
84
83−{-| Creates a transformation for vertical scaling -}
85+{-| Create a transformation for vertical scaling. -}
84scaleY : Float -> Transform2D
86scaleY : Float -> Transform2D
85scaleY y = matrix 1 0 0 y 0 0
87scaleY y = matrix 1 0 0 y 0 0
86
88
87−{-| Multiplies two transforms together:
89+{-| Multiply two transforms together.
88
90
89− multiply m n
91+ multiply m n
90
92
91 / ma mb mx \ / na nb nx \
93 / ma mb mx \ / na nb nx \
92 | mc md my | . | nc nd ny |
94 | mc md my | . | nc nd ny |