← Back to context

Comment by maximilianburke

9 months ago

Oh, 100%, I'd be happy with that too.

Is the orphan rule a result of some technical limitation? Or just the idea that it's "unclean" to implement someone elses traits for someone elses types?

Hi from Haskell land!

Haskell went through this as well. Orphans used to be allowed and I certainly saw their appeal.

The problem is that the compiler might see two different implementations of ToString for MyType in different source files. The compiler could probably make a check for that if it were compiling both files at once, but if you want to be able to compile source files separately and only recompile files which have changed, etc., I think it gets harder to spot.

> someone has to hack around that with a newtype wrapper

Don't think of it as hacking around it. It's the blessed approach. Newtype wrapping is giving a proper names to the behaviours, so that they don't get mixed up.