You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/reference/match-types.md
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -182,3 +182,23 @@ A complete defininition of when two patterns or types overlap still needs to be
182
182
183
183
The last rule in particular is needed to detect non-overlaps for cases where the scrutinee and the patterns are tuples. I.e. `(Int, String)` does not overlap `(Int, Int)` since
184
184
`String` does not overlap `Int`.
185
+
186
+
## Related Work
187
+
188
+
Match types have similarities with [closed type families](https://wiki.haskell.org/GHC/Type_families) in Haskell. Some differences are:
189
+
190
+
- Subtyping instead of type equalities.
191
+
- Match type reduction does not tighten the underlying constraint, whereas type family reduction does unify. This difference in approach mirrors the difference between local type inference in Scala and global type inference in Haskell.
192
+
- No a-priory requirement that cases are non-overlapping. Uses parallel reduction
193
+
instead of always chosing a unique branch.
194
+
195
+
Match types are also similar to Typescript's [conditional types](https://github.com/Microsoft/TypeScript/pull/21316). The main differences here are:
196
+
197
+
- Conditional types only reduce if scrutinee and pattern are ground, whereas
198
+
match types also work for type parameters and abstract types.
199
+
- Match types can bind variables in type patterns.
200
+
- Match types support direct recursion.
201
+
202
+
Conditional types on Typescript distribute through union types. We should evaluate whether match types should support this as well.
0 commit comments