Skip to content

Commit 0ca095f

Browse files
committed
Add related work section to match-types.md
1 parent 7a0c31f commit 0ca095f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/docs/reference/match-types.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,23 @@ A complete defininition of when two patterns or types overlap still needs to be
182182

183183
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
184184
`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.
203+
204+

0 commit comments

Comments
 (0)