Earlier quoted context omitted.
Immutability is definitely first class in clojure, but you can work with mutable structures when you need to.
This is sounds like memory safety in C++. https://www.infoworld.com/article/3714401/c-plus-plus-creato...
I learned Haskell in just 15 years
81–90 of 240 posts
Re: I learned Haskell in just 15 years
#82Cute. All kidding aside, though, functional programming is worth the effort to learn, and it doesn't actually take 15 years. The payoff is at the end of the article: "It’s quite natural to program in Haskell by building a declarative model of your domain data, writing pure functions over that data, and interacting with the real world at the program’s boundaries. That’s my favorite way to work, Haskell or not." Haskel…
For the benefit(s) that you list, which are the best learning resources for F#?
Re: I learned Haskell in just 15 years
#83Earlier quoted context omitted.
Well, technically that isn't true if you use, for example, unsafePerfomIO in the defintion of x. Referential transparency is still a spectrum, just like purity. Haskell is much closer to purity than the vast majority of languages out there. Also, even if Haskell were perfectly pure, the fact that it uses lazy evaluation is far more important to actually being able to make use of referential transparency. In a strict…
> technically that isn't true if you use, for example, unsafePerfomIO in the defintion of x Ah, well, regardless of whether it holds in Haskell, referential transparency is a well-defined concept. Purity is not a well-defined concept (at least as far as I know. Please share a formal definition if you have one!). That's primarily what I'm trying to say. But I also disagree with your point about unsafePerformIO. In pra…
I should note that I agree that, in practice, Haskell is almost always pure and/or referentially transparent. I was just pointing out that technically the GP was correct that it's not perfectly 100% so.
[0] https://www.cambridge.org/core/journals/journal-of-functiona...
Re: I learned Haskell in just 15 years
#84Re: I learned Haskell in just 15 years
#85Earlier quoted context omitted.
So, another definition of a pure function is that, for a particular input it will always return the same output. Your example respects the rule: f({x=1}) == 1 f({x=2}) == 2 But it's true that the two rules I gave are not enough to make a function pure. Because I didn't say anything about I/O. So, a function that follows the rules about inputs and outputs, could still do I/O and change its outputs based on that. Start…
> Your example respects the rule: Every definition of purity I can find that talks about objects/references says that if you pass in the same object/reference with different contents then that's not pure. Your version differs from mine on that aspect. It passes two unrelated objects. > Starting from the question that gave birth to this whole thread: "What's the benefit of learning a PURE functional programming langua…
Re: I learned Haskell in just 15 years
#86Earlier quoted context omitted.
> Yes - the value of functional programming isn't that working in OCAML, or F#, or Haskell is 10x as productive as other languages. This is not true in my personal experience. As has been famously said (paraphrased): Functional programming makes tough problems easy and easy problems tough. In other words the value of functional programming depends on your domain.
> easy problems tough. That needs a qualifier: it can make easy problems tough if you're not familiar with how to solve them in a functional context. A big part of that is because smart people have already solved the tough problems and made them available as language features or libraries.
My favorite example of this is implementing quicksort. It's significantly easier in C than it is in Haskell.
Re: I learned Haskell in just 15 years
#87Earlier quoted context omitted.
> Given that you want write code that sees "real world" use, and is used to handle data and events from the real world. Real world? As opposed to what? Is there any benefit to answering such polemical questions as if they are not rhetorical?
As opposed to the abstract academic world? The only time I had contact with Haskell was in university and I did not see it appealing back then, nor now, nor have I ever seen a program that I use, written in it. So learning a bit of pure Haskell might have been beneficial for me to become a better programmer, but I still fail to see it being more than that - a academic language. Useful for didactic purposes. Less to a…
The only mass market Haskell software that I know of is Pandoc. Others like Shellcheck and Postgrest are popular in their niche.
I am not sure that Haskell is faring worse that other programming languages in its level of popularity, like Julia, Clojure or Erlang.
Re: I learned Haskell in just 15 years
#88Immutable functional programming is basically what 80% of your Prolog code will look like. The benefit is that you'll be able to understand how everything works from end-to-end.
Re: I learned Haskell in just 15 years
#89Earlier quoted context omitted.
> easy problems tough. That needs a qualifier: it can make easy problems tough if you're not familiar with how to solve them in a functional context. A big part of that is because smart people have already solved the tough problems and made them available as language features or libraries.
Not really, certain problems are just inherently harder to express in a purely functional way than they are in an imperative way (and the reverse is just as true). For example, computing a histogram is much simpler in imperative terms (keep an array of histogram values, go through the original list, add 1 to the array element corresponding to the current element in this list) than in a purely functional style, especi…
Oh please, what's so hard about
qsort :: Ord a => [a] -> [a]
qsort [] = []
qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater
where
lesser = filter (= p) xs
:)folks, take that with a big ol /s, you would never want to actually use that algorithm. But the real deal isn't all that awful: https://mmhaskell.com/blog/2019/5/13/quicksort-with-haskell
Re: I learned Haskell in just 15 years
#90Cute. All kidding aside, though, functional programming is worth the effort to learn, and it doesn't actually take 15 years. The payoff is at the end of the article: "It’s quite natural to program in Haskell by building a declarative model of your domain data, writing pure functions over that data, and interacting with the real world at the program’s boundaries. That’s my favorite way to work, Haskell or not." Haskel…
I still don't understand Haskell, but it did help me learn Rust when I decided to learn that. And I think I could explain what a monad is.
edit: It's a data structure that implements flat map. Hope this saves someone else a few years of their life.