Closed Type Families: separate instance groups?
AntC
anthony_clayden at clear.net.nz
Wed Jun 3 23:09:39 UTC 2015
Currently (GHC 7.8.3) the only form for Closed Type Families is:
type family F a where ...
-- list your instances here
(This was considered a common use case
-- for example in HList to put the type-matching instance
with the non-matching, and that would be total coverage;
rather than needing a type family decl and an instance decl
with the instance head same as family.
That was an optimisation over ...)
Way back the design was more like this:
type family F a
type instance F (Foo b c) where
F (Foo Int c) = ...
F (Foo b Char) = ...
type instance F (Bar e f g) where
F (Bar Int f g) = ...
The idea was that the separate instance groups must have non-overlapping heads.
This is handy if Foo, Bar, etc are declared in separate places/modules.
You can put the instances with the data decl.
And quite possibly the family decl is in an imported/library module
you don't want to touch.
Is this separate instance group idea still a gleam in someone's eye?
If not, is there some deep theoretical reason against?
AntC
More information about the Glasgow-haskell-users
mailing list