Commit dceecc3
committed
Better type inference for V<n> pattern synonyms
Previously, the V<n> pattern synonyms (V2, V4, etc.) had suboptimal
typing in two different ways:
1. They did not force the type constructor of the constructed vector to
be `Vec`, hence the following type annotation was required absent
external type signatures:
> generate (I1 10000) (\(I1 idx) -> V2 idx (idx + 1) :: Exp (Vec _ _))
2. The IsVector instances required it to be known that the types of each
of the arguments of V<n> are equal before the instance could be
selected. This means that these type annotations were also required:
> fold1 (\(V2 a b) (V2 c d) -> V2 (a + c :: Exp Int) (b * d :: Exp Int)) $
> generate _ _
This commit fixes both issues, meaning that the following code is now
accepted in ghci:
> fold1 (\(V2 a b) (V2 c d) -> V2 (a + c) (b * d)) $
> generate (I1 10000) (\(I1 idx) -> V2 idx (idx + 1))1 parent 3f681a5 commit dceecc3
2 files changed
Lines changed: 27 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
192 | 197 | | |
| 198 | + | |
193 | 199 | | |
194 | | - | |
| 200 | + | |
195 | 201 | | |
196 | 202 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
204 | 216 | | |
205 | | - | |
206 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
207 | 220 | | |
208 | 221 | | |
209 | 222 | | |
| |||
273 | 286 | | |
274 | 287 | | |
275 | 288 | | |
| 289 | + | |
276 | 290 | | |
277 | 291 | | |
278 | 292 | | |
279 | 293 | | |
280 | 294 | | |
281 | | - | |
| 295 | + | |
282 | 296 | | |
283 | 297 | | |
284 | 298 | | |
| |||
0 commit comments