Choosing data representation based on type

To answer my own surprise: yes you can use DatatypeContexts with data familys/newtype instance. You do indeed get the warning I quoted, but it’s just a warning.

The reason for the Conflicting family instance declarations error is that the LHS heads of the decl are identical (modulo alpha renaming) – that is: MyArray u === MyArray b.

The DatatypeContext is not taken into account until after comparing the heads, just as an instance context is not taken into account. See my explanation above.

1 Like