3 ms·
Oh, well then you are talking perhaps using a newtype to wrap another type and perhaps use deriving to get behaviors from underlying type automatically. Or wit
by JoelMcCracken 4y ago
Oh, well then you are talking perhaps using a newtype to wrap another type and perhaps use deriving to get behaviors from underlying type automatically.
Or with a record you just explicitly implement typeclass methods in reference to the contained data.
If you mean doing it without doing a typeclass, well the functions need to have different names. If that’s exactly what you want. In order to have the same function name you need a typeclass.
- lmm 4y ago> Oh, well then you are talking perhaps using a newtype to wrap another type and perhaps use deriving to get behaviors from underlying type automatically. Deriving sort of does what delegation does, but in a very limited way, and even when it does work you can't use it for user-defined typeclasses, so it's not a solution to the problem except in a handful of special cases. > Or with a record you just explicitly implement typeclass methods in reference to the contained data. The whole point of a delegation feature is that you don't have to do this explicitly for each method.