3 ms·
So is it confusing or obvious? Pick one
by tantalor 9y ago
So is it confusing or obvious? Pick one
- marcosdumay 9y agoThe code behavior is obvious once you know Haskell. The code simplicity confuses people that don't know the language and think it is something much less powerful than it actually is.
- tantalor 9y agoIn that case, why not just write everything in perl?
- KirinDave 9y agoWe actually did for a long time. It wasn't so bad, I guess? Certainly not worse than Python, to me. But the value of writing this kind of code in Haskell is that Haskell makes code that couples very abstract interfaces VERY easily. This is really hard to explain without some examples, so I'm going to give you an example. Here, let me show you from real code. I'm going to tweak some endpoint names, but this is real code I'm going to ship next week: https://gist.github.com/KirinDave/9b4380376f9f748bcf0f8440decae517 https://gist.github.com/KirinDave/9b4380376f9f748bcf0f8440de... What's cool about this code is that I'm describing a "generic" radAPI service with a bunch of endpoints stripped out. Everything is parameterized around 3 generic ideas: "p", the Storage service. "Patchable", a strategy for applying patches to a storage service (exposing runPatch), and "CanValidate", a strategy for authenticating requests based on some sort of stored string, auth headers, and body contents. This is even better than mocking, because instead of deeply coupling the structure of my code to my tests, I only couple the capabilities.
- vgy7ujm 9y agoThe joy of Perl!