4 ms·
Do you frequently find yourself having to redefine cons when programming?
by mcphage 7y ago
Do you frequently find yourself having to redefine cons when programming?
- posco 7y agoNo, but surprisingly frequently this property holds: if your function is generic enough, there is only one (or a small number) of possible implementations that type check. Leveraging this rules out bugs.
- danharaj 7y agoIf you define a custom generic data type, for example if you need a special kind of tree for a particular algorithm, then you're going to be writing a lot of generic functions like cons for that data type.
- EdwardDiego 7y agoIn what language? I thought Haskell and OCaml for example, had generics.
- mrkeen 7y agoThe situation is a bit better than just generics (as they are in Java). For instance, if I had a List<Int>, I can treat it like a List<I>, but why can't I treat it like an <L>Int? Or an <L><I>?