Re:Haskell tutorial for C programmers
by chongli on Friday May 09, 2014 @07:24PM
(#7723812)
Yeah, though you will want to be the owner of either the type class or the type itself. Instances which are neither are called orphan instances and they are generally frowned upon. Luckily, it's trivial to create a newtype wrapper which gives you a whole new set of hooks for writing instances of a type.
[ Parent
| on HN ]
Orphan instances in libraries are frowned upon. In an application they are more palatable, though a newtype might still be a better choice, depending.
Re:Haskell tutorial for C programmers
by GeneralMayhem on Friday May 09, 2014 @09:10PM
(#7724101)
That makes sense, but again, in Java you can't do it if you're just the owner of the typeclass, and in order to make a wrapper you'd have to make a subclass, which mucks with all kinds of other things.