Live data from Hacker News

What I Wish I Knew When Learning Haskell

dev.stephendiehl.com

31–40 of 149 posts

Re: What I Wish I Knew When Learning Haskell

#31
post #24

Earlier quoted context omitted.

I'd say start with some eager functional language such as OCaml without the "object" part. Haskell code is hard to debug cuz you can't rely on good old print. Monad itself is never a silver bullet. Type systems and Composability are the true power of FP IMO.

Debugging declarative code is always hard, whatever the language. Haskell does allow you to use trace expressions which will output values to standard out, see Debug.Trace. This is no reason to avoid arguably the most popular (and state-of-the-art) function language and implementation out there.

Debug.Trace won't solve the space leaks lurking around every corner of your program, and won't shave the hundreds of megabytes to gigabytes of RAM the compiler needs for compiling a non trivial program with dependencies.

Re: What I Wish I Knew When Learning Haskell

#32

I feel this might have grown beyond its title. Picking the point where I gave up, giving me a list of 7 vscode plugins, without any guidance as to which are more mature, doesnt feel like a thing anyone would wish to know before they start.

No one said it's what they would wish to know before they start.

Take it from someone who spent 10 years on and off learning Haskell: It's a guide to navigating the boobytrapped minefield of the Haskell ecosystem, from the difficulties of installing it for the first time, to the confusing type theory.

Those aren't 7 plugins to choose from. Those are 7 plugins you should use all 7 of because there is no unified coherent Haskell IDE or plugin, but there are a dozen other broken ones that look good in the catalog.

Much the same with libraries. You need a guide to tell you which ones are usable and which are abandoned experiments, since both live side by side in the main repos.

Re: What I Wish I Knew When Learning Haskell

#33
post #4

Earlier quoted context omitted.

I'm pretty sure this (evolving) article has been around well before VSCode's initial release.

I'm sure you are right. That is just picking at one thing I will admit, but I do use vscode, so when I saw a section about how to best use haskell in vscode i was interested. I'm not interested enough, or as a beginner qualified, to evaluate 7 options.

You need all of them, not to pick one of them.

Re: What I Wish I Knew When Learning Haskell

#34
post #25

Earlier quoted context omitted.

Haskell has a huge catalog of libraries you can reach for, so you don’t have to reinvent the wheel. That said, the Haskell way can seem very different than what you see in most languages. As an example, IO—or anything causing a side effect—has to happen in the IO Monad. There are good reasons for this, but it takes some getting used to.

The parent poster is not lamenting that Haskell lacks a trivial sorting function. They are lamenting that implementing a trivial sorting function in Haskell is difficult.

I disagree.

  quicksort [] = []  
  quicksort (x:xs) =   
      let smallerSorted = quicksort [a | a  x]  
      in  smallerSorted ++ [x] ++ biggerSorted

Re: What I Wish I Knew When Learning Haskell

#35

What's up with the formatting on this page? In Firefox for iOS (same rendering engine as mobile Safari), all lines but the first one in code listings have 4-character indents, and lines use a larger-than-normal font size seemingly at random.

That's what mobile Firefox does to most of the web.

Re: What I Wish I Knew When Learning Haskell

#36

Earlier quoted context omitted.

I imagined it was more in the sense of the 'Have fun implementing Quicksort!' variety, where you're fighting the language constructs, basically, to do what you want.

Haskell has a huge catalog of libraries you can reach for, so you don’t have to reinvent the wheel. That said, the Haskell way can seem very different than what you see in most languages. As an example, IO—or anything causing a side effect—has to happen in the IO Monad. There are good reasons for this, but it takes some getting used to.

But let's say I want to print something in a deeply nested function which isn't of the return-IO-Monad-type. Now I have to convert the entire call-chain of functions into Monad style. Is there some tool to do this automatically?

Re: What I Wish I Knew When Learning Haskell

#37
post #24

Earlier quoted context omitted.

I'd say start with some eager functional language such as OCaml without the "object" part. Haskell code is hard to debug cuz you can't rely on good old print. Monad itself is never a silver bullet. Type systems and Composability are the true power of FP IMO.

Debugging declarative code is always hard, whatever the language. Haskell does allow you to use trace expressions which will output values to standard out, see Debug.Trace. This is no reason to avoid arguably the most popular (and state-of-the-art) function language and implementation out there.

It took me way too long to come across Trace, if it was more widely known I don't think we'd see so many "impossible to debug" related issues. It's great.

Re: What I Wish I Knew When Learning Haskell

#38
post #25

Earlier quoted context omitted.

The parent poster is not lamenting that Haskell lacks a trivial sorting function. They are lamenting that implementing a trivial sorting function in Haskell is difficult.

I disagree. quicksort [] = [] quicksort (x:xs) = let smallerSorted = quicksort [a | a x] in smallerSorted ++ [x] ++ biggerSorted

Not that I know any Haskell, but wouldn't smallerSorted already include x due to edit: also, how is the pivot element selected there?

Re: What I Wish I Knew When Learning Haskell

#39
post #25

Earlier quoted context omitted.

The parent poster is not lamenting that Haskell lacks a trivial sorting function. They are lamenting that implementing a trivial sorting function in Haskell is difficult.

I disagree. quicksort [] = [] quicksort (x:xs) = let smallerSorted = quicksort [a | a x] in smallerSorted ++ [x] ++ biggerSorted

[deleted]

Re: What I Wish I Knew When Learning Haskell

#40
post #25

Earlier quoted context omitted.

The parent poster is not lamenting that Haskell lacks a trivial sorting function. They are lamenting that implementing a trivial sorting function in Haskell is difficult.

I disagree. quicksort [] = [] quicksort (x:xs) = let smallerSorted = quicksort [a | a x] in smallerSorted ++ [x] ++ biggerSorted

That is (infamously) not quicksort.
Post reply on HN