git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
made some corrections
91f7221JP Smith
prelude/README.md+24−23
@@ -12,10 +12,11 @@ otherwise :: Boolean
12
12
13An alias for `true`, which can be useful in guard clauses:
13An alias for `true`, which can be useful in guard clauses:
14
14
15−E.g.
15+```purescript
16−
17 max x y | x >= y = x
16 max x y | x >= y = x
18 | otherwise = y
17 | otherwise = y
18+```
19+
19
20
20#### `flip`
21#### `flip`
21
22
@@ -25,9 +26,9 @@ flip :: forall a b c. (a -> b -> c) -> b -> a -> c
25
26
26Flips the order of the arguments to a function of two arguments.
27Flips the order of the arguments to a function of two arguments.
27
28
28−E.g.
29+```purescript
29−
30 flip const 1 2 = const 2 1 = 2
30 flip const 1 2 = const 2 1 = 2
31+```
31
32
32
33
33#### `const`
34#### `const`
@@ -38,9 +39,9 @@ const :: forall a b. a -> b -> a
38
39
39Returns its first argument and ignores its second.
40Returns its first argument and ignores its second.
40
41
41−E.g.
42+```purescript
42−
43− const 1 2 = 1
43+ const 1 "hello" = 1
44+```
44
45
45
46
46#### `asTypeOf`
47#### `asTypeOf`
@@ -52,9 +53,9 @@ asTypeOf :: forall a. a -> a -> a
52This function returns its first argument, and can be used to assert type equalities.
53This function returns its first argument, and can be used to assert type equalities.
53This can be useful when types are otherwise ambiguous.
54This can be useful when types are otherwise ambiguous.
54
55
55−E.g.
56+```purescript
56−
57 main = print $ [] `asTypeOf` [0]
57 main = print $ [] `asTypeOf` [0]
58+```
58
59
59If instead, we had written `main = print []`, the type of the argument `[]` would have
60If instead, we had written `main = print []`, the type of the argument `[]` would have
60been ambiguous, resulting in a compile-time error.
61been ambiguous, resulting in a compile-time error.
@@ -123,13 +124,13 @@ instance categoryArr :: Category Prim.Function
123
124
124Applies a function to its argument
125Applies a function to its argument
125
126
126−E.g.
127+```purescript
127−
128+ (+) 1 ((*) 2 (const 1 2)) = (+) 1 $ (*) 2 $ const 1 2
128− const $ 1 2 = const 1 2 = 1
129+```
129
130
130−`($)` is different from [`(#)`](#-2) because it is right-infix instance instead of left.
131+`($)` is different from [`(#)`](#-2) because it is right-infix instead of left. Right-infix
131−Right-infix operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse
132+operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse like
132−like (((a # b) # c) # d ...).
133+`(((a # b) # c) # d ...)`.
133
134
134
135
135#### `(#)`
136#### `(#)`
@@ -140,13 +141,13 @@ like (((a # b) # c) # d ...).
140
141
141Applies a function to its argument
142Applies a function to its argument
142
143
143−E.g.
144+```purescript
144−
145− 3 # ((+) 1) = 3 + 1 = 4
145+ (((3 + 1) * 2) + 4) = 3 # ((+) 1) # ((*) 2) # ((+) 4)
146+```
146
147
147−`(#)` is different from [`($)`](#-1) because it is left-infix instance instead of right.
148+`(#)` is different from [`($)`](#-1) because it is left-infix instead of right. Right-infix
148−Right-infix operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse
149+operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse like
149−like (((a # b) # c) # d ...).
150+`(((a # b) # c) # d ...)`.
150
151
151
152
152#### `(:)`
153#### `(:)`
@@ -157,9 +158,9 @@ like (((a # b) # c) # d ...).
157
158
158Attaches an element to the front of a list.
159Attaches an element to the front of a list.
159
160
160−E.g.
161+```purescript
161−
162 1 : [2, 3, 4] = [1, 2, 3, 4]
162 1 : [2, 3, 4] = [1, 2, 3, 4]
163+```
163
164
164
165
165#### `cons`
166#### `cons`
prelude/prelude.purs+24−23
@@ -31,27 +31,28 @@ module Prelude
31
31
32 -- | An alias for `true`, which can be useful in guard clauses:
32 -- | An alias for `true`, which can be useful in guard clauses:
33 -- |
33 -- |
34− -- | E.g.
34+ -- | ```purescript
35− -- |
36 -- | max x y | x >= y = x
35 -- | max x y | x >= y = x
37 -- | | otherwise = y
36 -- | | otherwise = y
37+ -- | ```
38+ -- |
38 otherwise :: Boolean
39 otherwise :: Boolean
39 otherwise = true
40 otherwise = true
40
41
41 -- | Flips the order of the arguments to a function of two arguments.
42 -- | Flips the order of the arguments to a function of two arguments.
42 -- |
43 -- |
43− -- | E.g.
44+ -- | ```purescript
44− -- |
45 -- | flip const 1 2 = const 2 1 = 2
45 -- | flip const 1 2 = const 2 1 = 2
46+ -- | ```
46 -- |
47 -- |
47 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
48 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
48 flip f b a = f a b
49 flip f b a = f a b
49
50
50 -- | Returns its first argument and ignores its second.
51 -- | Returns its first argument and ignores its second.
51 -- |
52 -- |
52− -- | E.g.
53+ -- | ```purescript
53− -- |
54− -- | const 1 2 = 1
54+ -- | const 1 "hello" = 1
55+ -- | ```
55 -- |
56 -- |
56 const :: forall a b. a -> b -> a
57 const :: forall a b. a -> b -> a
57 const a _ = a
58 const a _ = a
@@ -59,9 +60,9 @@ module Prelude
59 -- | This function returns its first argument, and can be used to assert type equalities.
60 -- | This function returns its first argument, and can be used to assert type equalities.
60 -- | This can be useful when types are otherwise ambiguous.
61 -- | This can be useful when types are otherwise ambiguous.
61 -- |
62 -- |
62− -- | E.g.
63+ -- | ```purescript
63− -- |
64 -- | main = print $ [] `asTypeOf` [0]
64 -- | main = print $ [] `asTypeOf` [0]
65+ -- | ```
65 -- |
66 -- |
66 -- | If instead, we had written `main = print []`, the type of the argument `[]` would have
67 -- | If instead, we had written `main = print []`, the type of the argument `[]` would have
67 -- | been ambiguous, resulting in a compile-time error.
68 -- | been ambiguous, resulting in a compile-time error.
@@ -110,26 +111,26 @@ module Prelude
110
111
111 -- | Applies a function to its argument
112 -- | Applies a function to its argument
112 -- |
113 -- |
113− -- | E.g.
114+ -- | ```purescript
114− -- |
115− -- | const $ 1 2 = const 1 2 = 1
115+ -- | (+) 1 ((*) 2 (const 1 2)) = (+) 1 $ (*) 2 $ const 1 2
116+ -- | ```
116 -- |
117 -- |
117− -- | `($)` is different from [`(#)`](#-2) because it is right-infix instance instead of left.
118+ -- | `($)` is different from [`(#)`](#-2) because it is right-infix instead of left. Right-infix
118− -- | Right-infix operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse
119+ -- | operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse like
119− -- | like (((a # b) # c) # d ...).
120+ -- | `(((a # b) # c) # d ...)`.
120 -- |
121 -- |
121 ($) :: forall a b. (a -> b) -> a -> b
122 ($) :: forall a b. (a -> b) -> a -> b
122 ($) f x = f x
123 ($) f x = f x
123
124
124 -- | Applies a function to its argument
125 -- | Applies a function to its argument
125 -- |
126 -- |
126− -- | E.g.
127+ -- | ```purescript
128+ -- | (((3 + 1) * 2) + 4) = 3 # ((+) 1) # ((*) 2) # ((+) 4)
129+ -- | ```
127 -- |
130 -- |
128− -- | 3 # ((+) 1) = 3 + 1 = 4
129− -- |
130− -- | `(#)` is different from [`($)`](#-1) because it is left-infix instance instead of right.
131+ -- | `(#)` is different from [`($)`](#-1) because it is left-infix instead of right. Right-infix
131− -- | Right-infix operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse
132+ -- | operators parse like (a $ (b $ (c $ (d ...)))) whereas left-infix operators parse like
132− -- | like (((a # b) # c) # d ...).
133+ -- | `(((a # b) # c) # d ...)`.
133 -- |
134 -- |
134 (#) :: forall a b. a -> (a -> b) -> b
135 (#) :: forall a b. a -> (a -> b) -> b
135 (#) x f = f x
136 (#) x f = f x
@@ -138,9 +139,9 @@ module Prelude
138
139
139 -- | Attaches an element to the front of a list.
140 -- | Attaches an element to the front of a list.
140 -- |
141 -- |
141− -- | E.g.
142+ -- | ```purescript
142− -- |
143 -- | 1 : [2, 3, 4] = [1, 2, 3, 4]
143 -- | 1 : [2, 3, 4] = [1, 2, 3, 4]
144+ -- | ```
144 -- |
145 -- |
145 (:) :: forall a. a -> [a] -> [a]
146 (:) :: forall a. a -> [a] -> [a]
146 (:) = cons
147 (:) = cons