3 ms·
I’m curious if there are any that were especially uncomfortable to implement in Haskell. I’m a very very novice “functional programmer” but on occasion I find
by Waterluvian 2y ago
I’m curious if there are any that were especially uncomfortable to implement in Haskell.
I’m a very very novice “functional programmer” but on occasion I find problems that feel just ridiculous to implement FP style.
- sfn42 2y agoI'm not much of a functional programmer either, but generally in the beginning you'll feel this way because you're not used to thinking about problems in a functional way. You're used to solving problems with imperative structures. So you try to implement that in a functional language and it turns out completely stupid because the language isn't made to solve problems that way. But it usually has good ways to solve things.
- galangalalgol 2y agoI got stuck trying to have an intuition about what would explode my memory usage due to lazy eval, I never got a grip on the transition from pseudofunctional at the io boundaries into real functional internally either.
- anonzzzies 2y agoI like fp and array programming and logic programming (and the overlap) to solve problems that are (considered or for real; I don't usually know going in) really a bad fit for those and then implement them shorter and faster than in their imperative implementation. For some things it does not work obviously, but it's a really nice exercise for when in the gym, walking, cooking, driving and such; the performant or LoC optimising parts fit in my head so I can do the rewrites there and find ways to make them fit. For instance; going from an imperative piece of code to array programming (k/j), you have to find a way to translate the problem to a vector/matrix manipulation problem and that you can do while doing something else entirely. When you find a good one fit, it can be many, many times faster than the original just like that.
- anardil 2y agoDefinitely. Depending on how long you've spent staring at the contents of /bin/ and /usr/bin/ you'll notice there are definitely some array or matrix oriented utils (or options) missing like column. cut comes to mind as a difficult one. In C, you can just hop around the char buffer[] and drop nulls in place for fields, etc before printing. You could go that way a Data.Array Char, but that's hard to justify as functional.
- Muromec 2y agoShouldn't cut but the easiest one to do in functional style? You basicaly map one line of a stream to another with some filtering and joining. Do I miss the part where it's terribly slow and/or not doable in Haskell or something?