Author: Eiko

Time: 2025-03-19 16:41:57 - 2025-03-19 16:41:57 (UTC)

Open and Closed Type Families

  • An open type family can be an associated type family, or a type family whose instances are scattered across modules.

  • A closed type family needs to have its definition in one place, like a pattern matching.


  • Open type families cannot have overlaps in its definition.

  • Closed type families can have overlaps.

  • You can use a closed type family instead of an open one in a class, by defining a closed type family outside the class, and add constraint to the class that passes the type into the multi-parameter class as a variable.