|
16 | 16 | -- | makeAddressT = uncurry4 Address
|
17 | 17 | -- |
|
18 | 18 | -- | makeAddress :: String -> City -> (Maybe Province) -> Country -> Address
|
19 |
| --- | makeAddress = curry4 makeAddressT |
| 19 | +-- | makeAddress = curry4 unit makeAddressT |
20 | 20 | -- |
|
21 | 21 | -- | tupleAddress :: Address -> Tuple4 String City (Maybe Province) Country
|
22 | 22 | -- | tupleAddress (Address a b c d) = tuple4 a b c d
|
23 | 23 | -- | ```
|
24 | 24 | module Data.Tuple.Nested where
|
25 | 25 |
|
| 26 | +import Prelude |
26 | 27 | import Data.Tuple (Tuple(..))
|
27 | 28 |
|
28 | 29 | -- | Shorthand for constructing n-tuples as nested pairs.
|
29 |
| --- | `a /\ b /\ c /\ d` becomes `Tuple (Tuple (Tuple a b) c ) d` |
30 |
| -infixl 6 Tuple as /\ |
31 |
| - |
32 |
| -type Tuple2 = Tuple |
33 |
| -type Tuple3 a b c = Tuple a (Tuple2 b c) |
34 |
| -type Tuple4 a b c d = Tuple a (Tuple3 b c d) |
35 |
| -type Tuple5 a b c d e = Tuple a (Tuple4 b c d e) |
36 |
| -type Tuple6 a b c d e f = Tuple a (Tuple5 b c d e f) |
37 |
| -type Tuple7 a b c d e f g = Tuple a (Tuple6 b c d e f g) |
38 |
| -type Tuple8 a b c d e f g h = Tuple a (Tuple7 b c d e f g h) |
39 |
| -type Tuple9 a b c d e f g h i = Tuple a (Tuple8 b c d e f g h i) |
40 |
| -type Tuple10 a b c d e f g h i j = Tuple a (Tuple9 b c d e f g h i j) |
| 30 | +-- | `a /\ b /\ c /\ d /\ unit` becomes `Tuple a (Tuple b (Tuple c (Tuple d (Tuple unit))))` |
| 31 | +infixr 6 Tuple as /\ |
| 32 | + |
| 33 | +type Tuple1 a = T2 a Unit |
| 34 | +type Tuple2 a b = T3 a b Unit |
| 35 | +type Tuple3 a b c = T4 a b c Unit |
| 36 | +type Tuple4 a b c d = T5 a b c d Unit |
| 37 | +type Tuple5 a b c d e= T6 a b c d e Unit |
| 38 | +type Tuple6 a b c d e f = T7 a b c d e f Unit |
| 39 | +type Tuple7 a b c d e f g = T8 a b c d e f g Unit |
| 40 | +type Tuple8 a b c d e f g h = T9 a b c d e f g h Unit |
| 41 | +type Tuple9 a b c d e f g h i = T10 a b c d e f g h i Unit |
| 42 | +type Tuple10 a b c d e f g h i j = T11 a b c d e f g h i j Unit |
| 43 | + |
| 44 | +type T2 a z = Tuple a z |
| 45 | +type T3 a b z = Tuple a (T2 b z) |
| 46 | +type T4 a b c z = Tuple a (T3 b c z) |
| 47 | +type T5 a b c d z = Tuple a (T4 b c d z) |
| 48 | +type T6 a b c d e z = Tuple a (T5 b c d e z) |
| 49 | +type T7 a b c d e f z = Tuple a (T6 b c d e f z) |
| 50 | +type T8 a b c d e f g z = Tuple a (T7 b c d e f g z) |
| 51 | +type T9 a b c d e f g h z = Tuple a (T8 b c d e f g h z) |
| 52 | +type T10 a b c d e f g h i z = Tuple a (T9 b c d e f g h i z) |
| 53 | +type T11 a b c d e f g h i j z = Tuple a (T10 b c d e f g h i j z) |
| 54 | + |
| 55 | +-- | Creates a singleton tuple. |
| 56 | +tuple1 :: forall a. a -> Tuple1 a |
| 57 | +tuple1 a = a /\ unit |
41 | 58 |
|
42 | 59 | -- | Given 2 values, creates a 2-tuple.
|
43 | 60 | tuple2 :: forall a b. a -> b -> Tuple2 a b
|
44 |
| -tuple2 = Tuple |
| 61 | +tuple2 a b = a /\ b /\ unit |
45 | 62 |
|
46 | 63 | -- | Given 3 values, creates a nested 3-tuple.
|
47 | 64 | tuple3 :: forall a b c. a -> b -> c -> Tuple3 a b c
|
48 |
| -tuple3 a b c = Tuple a (Tuple b c) |
| 65 | +tuple3 a b c = a /\ b /\ c /\ unit |
49 | 66 |
|
50 | 67 | -- | Given 4 values, creates a nested 4-tuple.
|
51 | 68 | tuple4 :: forall a b c d. a -> b -> c -> d -> Tuple4 a b c d
|
52 |
| -tuple4 a b c d = Tuple a (Tuple b (Tuple c d)) |
| 69 | +tuple4 a b c d = a /\ b /\ c /\ d /\ unit |
53 | 70 |
|
54 | 71 | -- | Given 5 values, creates a nested 5-tuple.
|
55 | 72 | tuple5 :: forall a b c d e. a -> b -> c -> d -> e -> Tuple5 a b c d e
|
56 |
| -tuple5 a b c d e = Tuple a (Tuple b (Tuple c (Tuple d e))) |
| 73 | +tuple5 a b c d e = a /\ b /\ c /\ d /\ e /\ unit |
57 | 74 |
|
58 | 75 | -- | Given 6 values, creates a nested 6-tuple.
|
59 | 76 | tuple6 :: forall a b c d e f. a -> b -> c -> d -> e -> f -> Tuple6 a b c d e f
|
60 |
| -tuple6 a b c d e f = Tuple a (Tuple b (Tuple c (Tuple d (Tuple e f)))) |
| 77 | +tuple6 a b c d e f = a /\ b /\ c /\ d /\ e /\ f /\ unit |
61 | 78 |
|
62 | 79 | -- | Given 7 values, creates a nested 7-tuple.
|
63 | 80 | tuple7 :: forall a b c d e f g. a -> b -> c -> d -> e -> f -> g -> Tuple7 a b c d e f g
|
64 |
| -tuple7 a b c d e f g = Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f g))))) |
| 81 | +tuple7 a b c d e f g = a /\ b /\ c /\ d /\ e /\ f /\ g /\ unit |
65 | 82 |
|
66 | 83 | -- | Given 8 values, creates a nested 8-tuple.
|
67 | 84 | tuple8 :: forall a b c d e f g h. a -> b -> c -> d -> e -> f -> g -> h -> Tuple8 a b c d e f g h
|
68 |
| -tuple8 a b c d e f g h = Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g h)))))) |
| 85 | +tuple8 a b c d e f g h = a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ unit |
69 | 86 |
|
70 | 87 | -- | Given 9 values, creates a nested 9-tuple.
|
71 | 88 | tuple9 :: forall a b c d e f g h i. a -> b -> c -> d -> e -> f -> g -> h -> i -> Tuple9 a b c d e f g h i
|
72 |
| -tuple9 a b c d e f g h i = Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g (Tuple h i))))))) |
| 89 | +tuple9 a b c d e f g h i = a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ unit |
73 | 90 |
|
74 | 91 | -- | Given 10 values, creates a nested 10-tuple.
|
75 | 92 | tuple10 :: forall a b c d e f g h i j. a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> Tuple10 a b c d e f g h i j
|
76 |
| -tuple10 a b c d e f g h i j = Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g (Tuple h (Tuple i j)))))))) |
| 93 | +tuple10 a b c d e f g h i j = a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ j /\ unit |
77 | 94 |
|
78 |
| --- | Given a function of 2 arguments, return a function that accepts a 2-tuple. |
79 |
| -uncurry2 :: forall a b z. (a -> b -> z) -> Tuple2 a b -> z |
80 |
| -uncurry2 f (Tuple t z) = f t z |
| 95 | +-- | Given at least a singleton tuple, gets the first value. |
| 96 | +get1 :: forall a z. T2 a z -> a |
| 97 | +get1 (a /\ _) = a |
81 | 98 |
|
82 |
| --- | Given a function that accepts a 2-tuple, return a function of 2 arguments. |
83 |
| -curry2 :: forall a b z. (Tuple2 a b -> z) -> a -> b -> z |
84 |
| -curry2 f a b = f (Tuple a b) |
| 99 | +-- | Given at least a 2-tuple, gets the second value. |
| 100 | +get2 :: forall a b z. T3 a b z -> b |
| 101 | +get2 (_ /\ b /\ _) = b |
85 | 102 |
|
86 |
| --- | Given a function of 3 arguments, return a function that accepts a 3-tuple. |
87 |
| -uncurry3 :: forall a b c z. (a -> b -> c -> z) -> Tuple3 a b c -> z |
88 |
| -uncurry3 f (Tuple a (Tuple b c)) = f a b c |
| 103 | +-- | Given at least a 3-tuple, gets the third value. |
| 104 | +get3 :: forall a b c z. T4 a b c z -> c |
| 105 | +get3 (_ /\ _ /\ c /\ _) = c |
89 | 106 |
|
90 |
| --- | Given a function that accepts a 3-tuple, return a function of 3 arguments. |
91 |
| -curry3 :: forall a b c z. (Tuple3 a b c -> z) -> a -> b -> c -> z |
92 |
| -curry3 f a b c = f (Tuple a (Tuple b c)) |
| 107 | +-- | Given at least a 4-tuple, gets the fourth value. |
| 108 | +get4 :: forall a b c d z. T5 a b c d z -> d |
| 109 | +get4 (_ /\ _ /\ _ /\ d /\ _) = d |
93 | 110 |
|
94 |
| --- | Given a function of 4 arguments, return a function that accepts a 4-tuple. |
95 |
| -uncurry4 :: forall a b c d z. (a -> b -> c -> d -> z) -> Tuple4 a b c d -> z |
96 |
| -uncurry4 f (Tuple a (Tuple b (Tuple c d))) = f a b c d |
| 111 | +-- | Given at least a 5-tuple, gets the fifth value. |
| 112 | +get5 :: forall a b c d e z. T6 a b c d e z -> e |
| 113 | +get5 (_ /\ _ /\ _ /\ _ /\ e /\ _) = e |
97 | 114 |
|
98 |
| --- | Given a function that accepts a 4-tuple, return a function of 4 arguments. |
99 |
| -curry4 :: forall a b c d z. (Tuple4 a b c d -> z) -> a -> b -> c -> d -> z |
100 |
| -curry4 f a b c d = f (Tuple a (Tuple b (Tuple c d))) |
| 115 | +-- | Given at least a 6-tuple, gets the sixth value. |
| 116 | +get6 :: forall a b c d e f z. T7 a b c d e f z -> f |
| 117 | +get6 (_ /\ _ /\ _ /\ _ /\ _ /\ f /\ _) = f |
101 | 118 |
|
102 |
| --- | Given a function of 5 arguments, return a function that accepts a 5-tuple. |
103 |
| -uncurry5 :: forall a b c d e z. (a -> b -> c -> d -> e -> z) -> Tuple5 a b c d e -> z |
104 |
| -uncurry5 f (Tuple a (Tuple b (Tuple c (Tuple d e)))) = f a b c d e |
| 119 | +-- | Given at least a 7-tuple, gets the seventh value. |
| 120 | +get7 :: forall a b c d e f g z. T8 a b c d e f g z -> g |
| 121 | +get7 (_ /\ _ /\ _ /\ _ /\ _ /\ _ /\ g /\ _) = g |
105 | 122 |
|
106 |
| --- | Given a function that accepts a 5-tuple, return a function of 5 arguments. |
107 |
| -curry5 :: forall a b c d e z. (Tuple5 a b c d e -> z) -> a -> b -> c -> d -> e -> z |
108 |
| -curry5 f a b c d e = f (Tuple a (Tuple b (Tuple c (Tuple d e)))) |
| 123 | +-- | Given at least an 8-tuple, gets the eigth value. |
| 124 | +get8 :: forall a b c d e f g h z. T9 a b c d e f g h z -> h |
| 125 | +get8 (_ /\ _ /\ _ /\ _ /\ _ /\ _ /\ _ /\ h /\ _) = h |
109 | 126 |
|
110 |
| --- | Given a function of 6 arguments, return a function that accepts a 6-tuple. |
111 |
| -uncurry6 :: forall a b c d e f z. (a -> b -> c -> d -> e -> f -> z) -> Tuple6 a b c d e f -> z |
112 |
| -uncurry6 f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e f))))) = f' a b c d e f |
| 127 | +-- | Given at least a 9-tuple, gets the ninth value. |
| 128 | +get9 :: forall a b c d e f g h i z. T10 a b c d e f g h i z -> i |
| 129 | +get9 (_ /\ _ /\ _ /\ _ /\ _ /\ _ /\ _ /\ _ /\ i /\ _) = i |
113 | 130 |
|
114 |
| --- | Given a function that accepts a 6-tuple, return a function of 6 arguments. |
115 |
| -curry6 :: forall a b c d e f z. (Tuple6 a b c d e f -> z) -> a -> b -> c -> d -> e -> f -> z |
116 |
| -curry6 f' a b c d e f = f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e f))))) |
| 131 | +-- | Given at least a 10-tuple, gets the tenth value. |
| 132 | +get10 :: forall a b c d e f g h i j z. T11 a b c d e f g h i j z -> j |
| 133 | +get10 (_ /\ _ /\ _ /\ _ /\ _ /\ _ /\ _ /\ _ /\ _ /\ j /\ _) = j |
117 | 134 |
|
118 |
| --- | Given a function of 7 arguments, return a function that accepts a 7-tuple. |
119 |
| -uncurry7 :: forall a b c d e f g z. (a -> b -> c -> d -> e -> f -> g -> z) -> Tuple7 a b c d e f g -> z |
120 |
| -uncurry7 f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f g)))))) = f' a b c d e f g |
| 135 | +-- | Given at least a singleton tuple, modifies the first value. |
| 136 | +over1 :: forall a r z. (a -> r) -> T2 a z -> T2 r z |
| 137 | +over1 o (a /\ z) = o a /\ z |
121 | 138 |
|
122 |
| --- | Given a function that accepts a 7-tuple, return a function of 7 arguments. |
123 |
| -curry7 :: forall a b c d e f g z. (Tuple7 a b c d e f g -> z) -> a -> b -> c -> d -> e -> f -> g -> z |
124 |
| -curry7 f' a b c d e f g = f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f g)))))) |
| 139 | +-- | Given at least a 2-tuple, modifies the second value. |
| 140 | +over2 :: forall a b r z. (b -> r) -> T3 a b z -> T3 a r z |
| 141 | +over2 o (a /\ b /\ z) = a /\ o b /\ z |
125 | 142 |
|
126 |
| --- | Given a function of 8 arguments, return a function that accepts a 8-tuple. |
127 |
| -uncurry8 :: forall a b c d e f g h z. (a -> b -> c -> d -> e -> f -> g -> h -> z) -> Tuple8 a b c d e f g h -> z |
128 |
| -uncurry8 f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g h))))))) = f' a b c d e f g h |
| 143 | +-- | Given at least a 3-tuple, modifies the third value. |
| 144 | +over3 :: forall a b c r z. (c -> r) -> T4 a b c z -> T4 a b r z |
| 145 | +over3 o (a /\ b /\ c /\ z) = a /\ b /\ o c /\ z |
129 | 146 |
|
130 |
| --- | Given a function that accepts a 8-tuple, return a function of 8 arguments. |
131 |
| -curry8 :: forall a b c d e f g h z. (Tuple8 a b c d e f g h -> z) -> a -> b -> c -> d -> e -> f -> g -> h -> z |
132 |
| -curry8 f' a b c d e f g h = f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g h))))))) |
| 147 | +-- | Given at least a 4-tuple, modifies the fourth value. |
| 148 | +over4 :: forall a b c d r z. (d -> r) -> T5 a b c d z -> T5 a b c r z |
| 149 | +over4 o (a /\ b /\ c /\ d /\ z) = a /\ b /\ c /\ o d /\ z |
133 | 150 |
|
134 |
| --- | Given a function of 9 arguments, return a function that accepts a 9-tuple. |
135 |
| -uncurry9 :: forall a b c d e f g h i z. (a -> b -> c -> d -> e -> f -> g -> h -> i -> z) -> Tuple9 a b c d e f g h i -> z |
136 |
| -uncurry9 f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g (Tuple h i)))))))) = f' a b c d e f g h i |
| 151 | +-- | Given at least a 5-tuple, modifies the fifth value. |
| 152 | +over5 :: forall a b c d e r z. (e -> r) -> T6 a b c d e z -> T6 a b c d r z |
| 153 | +over5 o (a /\ b /\ c /\ d /\ e /\ z) = a /\ b /\ c /\ d /\ o e /\ z |
137 | 154 |
|
138 |
| --- | Given a function that accepts a 9-tuple, return a function of 9 arguments. |
139 |
| -curry9 :: forall a b c d e f g h i z. (Tuple9 a b c d e f g h i -> z) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> z |
140 |
| -curry9 f' a b c d e f g h i = f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g (Tuple h i)))))))) |
| 155 | +-- | Given at least a 6-tuple, modifies the sixth value. |
| 156 | +over6 :: forall a b c d e f r z. (f -> r) -> T7 a b c d e f z -> T7 a b c d e r z |
| 157 | +over6 o (a /\ b /\ c /\ d /\ e /\ f /\ z) = a /\ b /\ c /\ d /\ e /\ o f /\ z |
141 | 158 |
|
142 |
| --- | Given a function of 10 arguments, return a function that accepts a 10-tuple. |
143 |
| -uncurry10 :: forall a b c d e f g h i j z. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> z) -> Tuple10 a b c d e f g h i j -> z |
144 |
| -uncurry10 f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g (Tuple h (Tuple i j))))))))) = f' a b c d e f g h i j |
| 159 | +-- | Given at least a 7-tuple, modifies the seventh value. |
| 160 | +over7 :: forall a b c d e f g r z. (g -> r) -> T8 a b c d e f g z -> T8 a b c d e f r z |
| 161 | +over7 o (a /\ b /\ c /\ d /\ e /\ f /\ g /\ z) = a /\ b /\ c /\ d /\ e /\ f /\ o g /\ z |
145 | 162 |
|
146 |
| --- | Given a function that accepts a 10-tuple, return a function of 10 arguments. |
147 |
| -curry10 :: forall a b c d e f g h i j z. (Tuple10 a b c d e f g h i j -> z) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> z |
148 |
| -curry10 f' a b c d e f g h i j = f' (Tuple a (Tuple b (Tuple c (Tuple d (Tuple e (Tuple f (Tuple g (Tuple h (Tuple i j))))))))) |
| 163 | +-- | Given at least an 8-tuple, modifies the eighth value. |
| 164 | +over8 :: forall a b c d e f g h r z. (h -> r) -> T9 a b c d e f g h z -> T9 a b c d e f g r z |
| 165 | +over8 o (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ z) = a /\ b /\ c /\ d /\ e /\ f /\ g /\ o h /\ z |
| 166 | + |
| 167 | +-- | Given at least a 9-tuple, modifies the ninth value. |
| 168 | +over9 :: forall a b c d e f g h i r z. (i -> r) -> T10 a b c d e f g h i z -> T10 a b c d e f g h r z |
| 169 | +over9 o (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ z) = a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ o i /\ z |
| 170 | + |
| 171 | +-- | Given at least a 10-tuple, modifies the tenth value. |
| 172 | +over10 :: forall a b c d e f g h i j r z. (j -> r) -> T11 a b c d e f g h i j z -> T11 a b c d e f g h i r z |
| 173 | +over10 o (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ j /\ z) = a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ o j /\ z |
| 174 | + |
| 175 | +-- | Given a function of 1 argument, returns a function that accepts a singleton tuple. |
| 176 | +uncurry1 :: forall a r z. (a -> r) -> T2 a z -> r |
| 177 | +uncurry1 f (a /\ _) = f a |
| 178 | + |
| 179 | +-- | Given a function of 2 arguments, returns a function that accepts a 2-tuple. |
| 180 | +uncurry2 :: forall a b r z. (a -> b -> r) -> T3 a b z -> r |
| 181 | +uncurry2 f (a /\ b /\ _) = f a b |
| 182 | + |
| 183 | +-- | Given a function of 3 arguments, returns a function that accepts a 3-tuple. |
| 184 | +uncurry3 :: forall a b c r z. (a -> b -> c -> r) -> T4 a b c z -> r |
| 185 | +uncurry3 f (a /\ b /\ c /\ _) = f a b c |
| 186 | + |
| 187 | +-- | Given a function of 4 arguments, returns a function that accepts a 4-tuple. |
| 188 | +uncurry4 :: forall a b c d r z. (a -> b -> c -> d -> r) -> T5 a b c d z -> r |
| 189 | +uncurry4 f (a /\ b /\ c /\ d /\ _) = f a b c d |
| 190 | + |
| 191 | +-- | Given a function of 5 arguments, returns a function that accepts a 5-tuple. |
| 192 | +uncurry5 :: forall a b c d e r z. (a -> b -> c -> d -> e -> r) -> T6 a b c d e z -> r |
| 193 | +uncurry5 f (a /\ b /\ c /\ d /\ e /\ _) = f a b c d e |
| 194 | + |
| 195 | +-- | Given a function of 6 arguments, returns a function that accepts a 6-tuple. |
| 196 | +uncurry6 :: forall a b c d e f r z. (a -> b -> c -> d -> e -> f -> r) -> T7 a b c d e f z -> r |
| 197 | +uncurry6 f' (a /\ b /\ c /\ d /\ e /\ f /\ _) = f' a b c d e f |
| 198 | + |
| 199 | +-- | Given a function of 7 arguments, returns a function that accepts a 7-tuple. |
| 200 | +uncurry7 :: forall a b c d e f g r z. (a -> b -> c -> d -> e -> f -> g -> r) -> T8 a b c d e f g z -> r |
| 201 | +uncurry7 f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ _) = f' a b c d e f g |
| 202 | + |
| 203 | +-- | Given a function of 8 arguments, returns a function that accepts an 8-tuple. |
| 204 | +uncurry8 :: forall a b c d e f g h r z. (a -> b -> c -> d -> e -> f -> g -> h -> r) -> T9 a b c d e f g h z -> r |
| 205 | +uncurry8 f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ _) = f' a b c d e f g h |
| 206 | + |
| 207 | +-- | Given a function of 9 arguments, returns a function that accepts a 9-tuple. |
| 208 | +uncurry9 :: forall a b c d e f g h i r z. (a -> b -> c -> d -> e -> f -> g -> h -> i -> r) -> T10 a b c d e f g h i z -> r |
| 209 | +uncurry9 f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ _) = f' a b c d e f g h i |
| 210 | + |
| 211 | +-- | Given a function of 10 arguments, returns a function that accepts a 10-tuple. |
| 212 | +uncurry10 :: forall a b c d e f g h i j r z. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> r) -> T11 a b c d e f g h i j z -> r |
| 213 | +uncurry10 f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ j /\ _) = f' a b c d e f g h i j |
| 214 | + |
| 215 | +-- | Given a function that accepts at least a singleton tuple, returns a function of 1 argument. |
| 216 | +curry1 :: forall a r z. z -> (T2 a z -> r) -> a -> r |
| 217 | +curry1 z f a = f (a /\ z) |
| 218 | + |
| 219 | +-- | Given a function that accepts at least a 2-tuple, returns a function of 2 arguments. |
| 220 | +curry2 :: forall a b r z. z -> (T3 a b z -> r) -> a -> b -> r |
| 221 | +curry2 z f a b = f (a /\ b /\ z) |
| 222 | + |
| 223 | +-- | Given a function that accepts at least a 3-tuple, returns a function of 3 arguments. |
| 224 | +curry3 :: forall a b c r z. z -> (T4 a b c z -> r) -> a -> b -> c -> r |
| 225 | +curry3 z f a b c = f (a /\ b /\ c /\ z) |
| 226 | + |
| 227 | +-- | Given a function that accepts at least a 4-tuple, returns a function of 4 arguments. |
| 228 | +curry4 :: forall a b c d r z. z -> (T5 a b c d z -> r) -> a -> b -> c -> d -> r |
| 229 | +curry4 z f a b c d = f (a /\ b /\ c /\ d /\ z) |
| 230 | + |
| 231 | +-- | Given a function that accepts at least a 5-tuple, returns a function of 5 arguments. |
| 232 | +curry5 :: forall a b c d e r z. z -> (T6 a b c d e z -> r) -> a -> b -> c -> d -> e -> r |
| 233 | +curry5 z f a b c d e = f (a /\ b /\ c /\ d /\ e /\ z) |
| 234 | + |
| 235 | +-- | Given a function that accepts at least a 6-tuple, returns a function of 6 arguments. |
| 236 | +curry6 :: forall a b c d e f r z. z -> (T7 a b c d e f z -> r) -> a -> b -> c -> d -> e -> f -> r |
| 237 | +curry6 z f' a b c d e f = f' (a /\ b /\ c /\ d /\ e /\ f /\ z) |
| 238 | + |
| 239 | +-- | Given a function that accepts at least a 7-tuple, returns a function of 7 arguments. |
| 240 | +curry7 :: forall a b c d e f g r z. z -> (T8 a b c d e f g z -> r) -> a -> b -> c -> d -> e -> f -> g -> r |
| 241 | +curry7 z f' a b c d e f g = f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ z) |
| 242 | + |
| 243 | +-- | Given a function that accepts at least an 8-tuple, returns a function of 8 arguments. |
| 244 | +curry8 :: forall a b c d e f g h r z. z -> (T9 a b c d e f g h z -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> r |
| 245 | +curry8 z f' a b c d e f g h = f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ z) |
| 246 | + |
| 247 | +-- | Given a function that accepts at least a 9-tuple, returns a function of 9 arguments. |
| 248 | +curry9 :: forall a b c d e f g h i r z. z -> (T10 a b c d e f g h i z -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> r |
| 249 | +curry9 z f' a b c d e f g h i = f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ z) |
| 250 | + |
| 251 | +-- | Given a function that accepts at least a 10-tuple, returns a function of 10 arguments. |
| 252 | +curry10 :: forall a b c d e f g h i j r z. z -> (T11 a b c d e f g h i j z -> r) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> r |
| 253 | +curry10 z f' a b c d e f g h i j = f' (a /\ b /\ c /\ d /\ e /\ f /\ g /\ h /\ i /\ j /\ z) |
0 commit comments