Live data from Hacker News

I learned Haskell in just 15 years

duckrabbit.tech

191–200 of 240 posts

Re: I learned Haskell in just 15 years

#191
post #189

Earlier quoted context omitted.

Run in backwards, so they say, but not really. Most things you'll write can't run backwards. You have to write them in a special way for that to be possible, and even then what it means is that you can do a depth first search to find the value. There are some useful extensions like clpfd and asp but really if what you're doing is solving a constraint programming problem, you're much better of with OR-tools or MiniZin…

I don't know, most things I've written in Prolog 'runs backwards'. Doesn't seem special to me, things like cut and whatnot that might interfere do. I kind of feel that clpfd, clpz and so on are just libraries, in what way do you consider them extensions to the language? For me it's a neat way to model problems, and when I have I've commonly learned something new about the problem domain. Performance might not be grea…

In SWI for example, clpfd and friends rely on attribute values and hook predicates to interject the backtracking process with their own thing. SWI provides those things so that it can be extended.

Non trivial Prolog programs which only use pure predicates and do not use cut are sparse. Yet those are also the only circumstances in which things like clpfd will work without special consideration.

Re: I learned Haskell in just 15 years

#192
post #186

Earlier quoted context omitted.

I gave it some more thought. I now believe that learning a language like Haskell (or Elm or PureScript) forces you to see your program as pipes that you fuse together. It's not just functions. Haskell has only expressions and declarations. That means, for example, that you are forced to provide an `else`, when you use `if`. The idea is that you have to keep the data flowing. If a function doesn't provide a meaningful…

I mean that the identity is unrelated. Yes, you can say they're the same type. But I'm actually passing the same object in. If f evaluated lazily, it could return 2 from both calls. Something like: define f(o): return o.x let a = {x=1} n = f(a) // n is not evaluated yet a.x = 2 m = f(a) return n + m // returns 4

Ok, you're probably proving the point that purity also requires immutability. I'm not sure, as I haven't considered all the implications of Haskell's design.

My two rules about inputs and outputs are more like heuristics. They can improve code organisation and probably also decrease the likelihood of some errors, but they don't guarantee correctness, as you're pointing out. They're shortcuts, so they're not perfect.

Edit: If I remember right, it's laziness that requires immutability. I think I read something about this in the Haskell subreddit as an explanation for Haskell's design.

Re: I learned Haskell in just 15 years

#193

Earlier 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.

What easy problems are tough in F#? I’ve been using it for writing random scripts and as a Python replacement.

It's an overgeneralisation.

If you try and turn F# into Haskell at home you may run into that problem.

F# is functional first language so if an object oriented or procedural solution is the right call the options right there when you need it.

Re: I learned Haskell in just 15 years

#194
post #3
post #2

Cute. 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…

Yes - the value of functional programming isn't that working in OCAML, or F#, or Haskell is 10x as productive as other languages. But that it can teach you worthwhile lessens about designing software that apply equally to imperative languages. Modelling the business domain, reasoning and managing side effects, avoiding common imperative bugs, these are all valuable skills to develop. F# is a great language to learn,…

I wouldn't even say antiquated, modern .Net APIs can suck to work with too, the entire ecosystem is written for C# ASP.Net core and everything else feels second class.

I love F#, the working with C# elements of the language drove me away.

Re: I learned Haskell in just 15 years

#195
post #166

Earlier quoted context omitted.

F# has "generics" just like Python and PHP now "have types". It's not a yes/no feature.

Give F# a try. It has, and always had, true generics. https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...

> It's not a yes/no feature.

FTFM: It's not a true/false feature.

Re: I learned Haskell in just 15 years

#196
post #3

Earlier 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. But that it can teach you worthwhile lessens about designing software that apply equally to imperative languages. Modelling the business domain, reasoning and managing side effects, avoiding common imperative bugs, these are all valuable skills to develop. F# is a great language to learn,…

I wouldn't even say antiquated, modern .Net APIs can suck to work with too, the entire ecosystem is written for C# ASP.Net core and everything else feels second class. I love F#, the working with C# elements of the language drove me away.

Which elements were the source of pain?

Writing web applications and back-ends in F#, as far as I'm aware, is straightforward and a joy because of integration with the rest of ecosystem.

Re: I learned Haskell in just 15 years

#197
post #195

Earlier quoted context omitted.

Give F# a try. It has, and always had, true generics. https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...

> It's not a yes/no feature. FTFM: It's not a true/false feature.

Alright. Humor me, what is the issue with F# generics as compared to other languages with generics? Which implementation (that is productively useful) is a "true" one?

Re: I learned Haskell in just 15 years

#198

Earlier quoted context omitted.

I am not a user of the language (although I learned it like you). I just came to chime in that (a) there is at least one very popular software written in Haskell and (b) Haskell seems to ship a good amount of software for its popularity. Haskell never got the “killer framework” like Rails or Spark that allowed to become more mainstream, even if it was teached in Universities all over the world.

Haskell has yesod, which is Haskell’s Rails. It’s a batteries included web app scaffold. You still need to understand monads, though. But any Haskell shop with web apps is using that. There’s also scotty and servant for web server stuff. There’s Esqueleto and Persistent for doing postgreSQL database queries. And so on.

Yesod seems interesting indeed.

Even though they are biased:

"From a purely technical point of view, Haskell seems to be the perfect web development tool."

But I skimmed the tutorials and can say, I am really not surprised, why it did not take off.

The perfect web developement tool is simple in my opinion. Yesod isn't.

Re: I learned Haskell in just 15 years

#199
post #180

Earlier quoted context omitted.

> I still don't understand Haskell It's not you. Haskell has very bad syntax. It's not hard to understand it, it you rewrite the same things in something saner. Haskell was developed by people who enjoy one-liners and don't really need to write practical programs. Another aspect of Haskell is that it was written by people who were so misguided as to think that mathematical formulas are somehow superior to typical imp…

Just to give a different pov I find Haskell very intuitive, and particularly I find that code written by other people is very easy to understand (compared to Java or TypeScript at least). And by the way x and x' are totally fine names for a value of a very generic type (or even a very specific type depending on the circumstances), as long as the types and the functions are decently named. I mean, how else would you c…

> I mean, how else would you call the arguments of > splitAt :: Eq a => a -> [a] -> [[a]]

Those don't seem to be names of parameters, but rather of types. It's missing parameter names entirely.

I spent a good 2 minutes looking at that signature trying to figure it out (and I've read some Haskell tutorials so I'm at least familiar with the syntax). This would've helped:

    def split_by(separator: T, list: List[T]) -> List[List[T]]
`sep`, `separator`, `delim`, `delimiter` would've been good names.

Re: I learned Haskell in just 15 years

#200

Earlier quoted context omitted.

I am not a user of the language (although I learned it like you). I just came to chime in that (a) there is at least one very popular software written in Haskell and (b) Haskell seems to ship a good amount of software for its popularity. Haskell never got the “killer framework” like Rails or Spark that allowed to become more mainstream, even if it was teached in Universities all over the world.

Haskell has yesod, which is Haskell’s Rails. It’s a batteries included web app scaffold. You still need to understand monads, though. But any Haskell shop with web apps is using that. There’s also scotty and servant for web server stuff. There’s Esqueleto and Persistent for doing postgreSQL database queries. And so on.

I took a look at Yesod and looks more like Haskell’s Sinatra and comes 6 years later than Rails, in 2010. By 2010 a simple web frameworm is table stakes, no huge differentiator.
Post reply on HN