Orphan Instances


#1

I remember seeing a discuss thread somewhere about this basic problem, and I’d like to see it resolved.

If a type provided by one library should implement a trait provided by another, whose responsibility is it to write the impl? I feel that there are cases where makes sense that neither library does. My example right now is cgmath::Vector3 and a custom Flatten trait I’ve written. There’s no real reason for cgmath to depend on my little library, and no real reason for my library to depend on cgmath (and every other package that provides a type anybody might ever want to flatten).

Haskell allows Orphan Instances (i.e. impls that aren’t defined in the same file as either the trait or the type). While this raises ambiguity concerns (different people can specify different impls), I don’t feel that this is a big issue in practice. I think a bigger issue is ad-hoc and unnecessarily noisey dependencies, and dependencies existing where they shouldn’t really exist.

Any thoughts?


#2

Are you looking for this thread?


#3

Oh that’s exactly it, thanks a lot. I don’t know how I couldn’t find that…

Is there a way for me to mark this thread solved/redundant?