3 ms·
I'm happy to answer questions about the design decisions if anyone is curious.
by yawaramin 12y ago
I'm happy to answer questions about the design decisions if anyone is curious.
- gmartres 12y agoNice post! I think your encoding of functors could be replaced by: object Module { private class MyUnbalancedSet[A](O: Ordered[A]) extends MySet[A] { ... body as in your post } def UnbalancedSet[A](O: Ordered[A]): MySet[A] = new MyUnbalancedSet[A](0) } Which looks more like "normal" Scala but still offers the same amount of abstraction.
- yawaramin 12y agoThanks! Yes, you're right that we can use a class here and instantiate an object of the class. I thought I would skip the intermediate step because all I care about is the upcast type, MySet[A], and not the actual derived type. But it's very much a matter of preference!
- sirseal 12y agoAwesome work! Thank you for sharing.