In this case, I would suggest moving Transformable
into its own module, then importing it into the modules which define Sequence
and Pattern
:
-
As more methods are added to
Transformable
, it may be possible to make some methods into top-level definitions, which are defined using otherTransformable
methods - in time, you’ll (ideally) end up with a small set ofTransformable
methods, and a library’s worth of dependent definitions (the classic example of this approach being theMonad
type class - only two basic methods, and yet so many ways they can be used). -
If that many methods really are needed, having each
Transformable
instance co-located with its type means any changes to just one type are unlikely to require recompiling the instances for both types (if there were no changes toTransformable
).