Type Families with Class, Type Classes with Family
Alejandro Serrano1 Jurriaan Hage1 Patrick Bahr2
1Utrecht University 2IT University of Copenhagen
Type Families with Class, Type Classes with Family Alejandro Serrano - - PowerPoint PPT Presentation
Type Families with Class, Type Classes with Family Alejandro Serrano 1 Jurriaan Hage 1 Patrick Bahr 2 1 Utrecht University 2 IT University of Copenhagen Haskell Symposium 2015 Motivation Type-level programming in Haskell/GHC functional
1Utrecht University 2IT University of Copenhagen
◮ functional dependencies ◮ type families ◮ data type promotion, kind polymorphism ◮ closed type families
2 / 18
◮ functional dependencies ◮ type families ◮ data type promotion, kind polymorphism ◮ closed type families
◮ use type families to simulate type classes ◮ gain flexibility and expressiveness
2 / 18
◮ Simulate type classes using type families
◮ What can we do with this encoding? ◮ Proposal: type families with elaboration
3 / 18
4 / 18
4 / 18
4 / 18
4 / 18
4 / 18
5 / 18
5 / 18
5 / 18
5 / 18
5 / 18
5 / 18
5 / 18
6 / 18
6 / 18
6 / 18
◮ super classes ◮ limited forms functional dependencies
◮ not supported: overlapping instances
7 / 18
8 / 18
◮ type class directives ◮ custom error messages ◮ instance chains
8 / 18
9 / 18
9 / 18
10 / 18
11 / 18
11 / 18
11 / 18
12 / 18
12 / 18
12 / 18
12 / 18
◮ explicit failure ◮ provide alternatives (else clause)
13 / 18
◮ explicit failure ◮ provide alternatives (else clause)
13 / 18
◮ explicit failure ◮ provide alternatives (else clause)
13 / 18
14 / 18
◮ Use type classes ◮ Extend type families with elaboration
14 / 18
◮ Use type classes ◮ Extend type families with elaboration
14 / 18
◮ Use type classes ◮ Extend type families with elaboration
14 / 18
◮ Use type classes ◮ Extend type families with elaboration
14 / 18
◮ Use type classes ◮ Extend type families with elaboration
14 / 18
15 / 18
15 / 18
15 / 18
15 / 18
16 / 18
◮ study elaboration further ◮ use encoding as implementation of type classes?
17 / 18
◮ study elaboration further ◮ use encoding as implementation of type classes?
◮ encoding of functional dependencies ◮ encoding of superclasses ◮ more examples ◮ proof of soundness & completeness (using OutsideIn(X))
17 / 18
1Utrecht University 2IT University of Copenhagen