Post AZHiOy0E1vn2E7Z7cO by clementd@framapiaf.org
(DIR) More posts by clementd@framapiaf.org
(DIR) Post #AZHgV1GKciPuALrDvM by clementd@framapiaf.org
2023-08-31T08:19:31Z
1 likes, 0 repeats
Ah, rust discourse has reached the "reject polymorphism, embrace monomorphism" stage?Oh well. Waiting for this to blow over, as it did in Haskell
(DIR) Post #AZHgZHy4SGGh8SLski by alice@bidule.menf.in
2023-08-31T08:33:22.766148Z
0 likes, 0 repeats
@clementd There was such a stage in Haskell ? What form did it take ? What was the main point behind it ? Could you tell me more about it ?
(DIR) Post #AZHiOw1vMdxc6oLRzM by clementd@framapiaf.org
2023-08-31T08:47:12Z
2 likes, 0 repeats
@alice The peak was the "foldable-in-prelude" proposal (code name FTP). It moved a few functions (`length`, amongst others) that previously only worked on lists to work on everything that implemented foldable.This made these functions a lot more useful, at the cost of degrading the learning curve for basic operations, and introducing surprising behaviour, due to the Foldable instance for tuples (eg `length ('a', 12) == 1`).
(DIR) Post #AZHiOy0E1vn2E7Z7cO by clementd@framapiaf.org
2023-08-31T08:52:01Z
1 likes, 0 repeats
@alice The issue when things become heated like this is that people turn to absolutes instead of recognizing there are tradeoffs that allow using different styles in different contexts.A maximally generic implementation makes code analysis simpler by reducing the number of valid programs, but can also make code reading harder by removing clues provided by concrete types. It can also allow "spooky action at a distance" during refactorings when the concrete type that's inferred changes suddenly.
(DIR) Post #AZHjEF6WCsjK2DxXHc by clementd@framapiaf.org
2023-08-31T08:57:52Z
0 likes, 0 repeats
@alice Now we're in a healthier place, i think it's generally accepted that using type classes just for overloading / syntactic reasons is not a terribly good idea. The ideal is for typeclasses to have well-defined laws that one can reason about.Typeclass-based serialization is in a gray zone. Some people really dislike it. I do find them extremely convenient and not an issue, especially when using DTOs (which is good practice anyway for many reasons).
(DIR) Post #AZHjEFs1MGjAPYBTKC by alice@bidule.menf.in
2023-08-31T09:03:10.250326Z
0 likes, 0 repeats
@clementd «Type classes just for overloading» ? I’m afraid I might be doing just that. Any hint at what to look to find if this is the case ? What bad consequences can it have ? Is that a general a formulation of the example of potential confusion you gave for Foldable ? Because apart from overloading I totally see what abstraction Foldable captures and I think it makes great sense to have regrouped all those types with this type class.
(DIR) Post #AZHjtNtcQJAfAwXkqO by clementd@framapiaf.org
2023-08-31T09:09:33Z
1 likes, 0 repeats
@alice "just for overloading" = just to be able to reuse the function in several contexts, without a well-defined abstraction that gives meaning to the operation (more meaning than just a type signature). Sometimes we think "oh, these functions do more or less the same thing and their signatures are close, let's make it a typeclass" <- that's the part where it's good to think twice.As for Foldable, it's a proper abstraction, so i have no issues with it (and I absolutely adore `Traversable`).
(DIR) Post #AZHjziPl37naY8axMW by alice@bidule.menf.in
2023-08-31T08:58:18.124859Z
0 likes, 0 repeats
@clementd I see. That’s interesting, I had never considered this case of length with tuples, I can see why it could surprise a good many newcomers. I must have been too familiar with Haskell for too long because it wouldn’t even have crossed my mind to write this any more than to write for instance length $ Just 12 ^^’So I assume at some point people argued for less polymorphism to give both the poor compiler and user more clues ?
(DIR) Post #AZHk7N26Qg76YKBGwC by clementd@framapiaf.org
2023-08-31T09:12:02Z
0 likes, 0 repeats
@alice My beef is with absolutes like "only use boring haskell", "you should stick to Haskell98", "never use lens or servant". It all depends on the team anyway, and it can even depend on modules in projects based on what they're doing, and who's maintaining them.
(DIR) Post #AZHk7Nvl5kdJKwDigi by alice@bidule.menf.in
2023-08-31T09:13:08.023712Z
0 likes, 0 repeats
@clementd Thanks for the explanations ! Not sure whether I've fallen for this hasty typeclass design mistake, but I'll watch out for it.
(DIR) Post #AZI2k3ozaakJRDeBKC by clementd@framapiaf.org
2023-08-31T09:38:19Z
1 likes, 0 repeats
@alice The pushback was primarily aimed at helping people.