3 ms·
Hey, you're talking about my library Renderable - and I'm totally up to finding a more idiomatic way to express the problem. It just so happened that type class
by efnx 11y ago
Hey, you're talking about my library Renderable - and I'm totally up to finding a more idiomatic way to express the problem. It just so happened that type classes were the easiest way to do that.
- tome 11y agoHa, sorry, didn't mean to make it sound like I was talking about anything in particular! I just made up that example on the spot. A "Renderable" thing fits into a common pattern where you see typeclasses used in this way. (Are you talking about this library? https://hackage.haskell.org/package/renderable-0.1.0.0/docs/Data-Renderable.html https://hackage.haskell.org/package/renderable-0.1.0.0/docs/... I don't actually see a Renderable class there anyway.)
- efnx 11y agoAhh - I thought you may have read my articles on HN or Reddit - how self centered of me :) Yes, there's no 'Renderable' typeclass but there are 'Primitive's. There are no laws that the 'Primitive' typeclass instances must obey but there are associated types that need to be satisfied. I tried to write this without a typeclass and I just couldn't get it to check, so I turned to TypeFamilies to encode the relation ship between types. I'd love to make it more idiomatic though! [I'd love some feedback if you're so inclined](https://github.com/schell/renderable/blob/master/src/Data/Renderable.hs https://github.com/schell/renderable/blob/master/src/Data/Re...)