4 ms·
> meaning I can make those literals evaluate to my own types by defining a few instances. If you're defining instances, you're already an "expert", so why are
by Quekid5 7y ago
> meaning I can make those literals evaluate to my own types by defining a few instances.
If you're defining instances, you're already an "expert", so why are you defining instances that are "hostile" to your beginner students?
If people in the ecosystem are defining hostile instances, you should probably just ask them to stop it...?
EDIT: Also, isn't failing to compile the almost-optimal case? It certainly doesn't fail at runtime.
- momentoftop 7y agoThe beginner isn't defining the instances. But the experts want the flexibility to define such instances, and that means even beginner code can involve an unhelpful amount of polymorphism. This isn't the case in Rust, where literals are near enough monomorphic. There's a similar situation with the now classic: Prelude> length ['a','b'] 2 Prelude> length ('a','b') 1 Here, beginners are potentially being burned by the fact that "length" is polymorphic with the type: length :: Foldable f => f a -> Int which is not a type I want to explain to beginners. At the same time, as an expert, I want length to be polymorphic and don't want to sacrifice its polymorphism for the sake of beginners.
- Quekid5 7y agoI don't think that's an example of what was being talked about, but... I appreciate the issue. I think I've even been bitten by this once! I think the problem there is really calling it 'length'.