Looking for a newbie Haskell book

I’m looking for a good book to learn Haskell. One without all the sales hype about Haskell. I have already decided to learn Haskell. The sales hype just wastes my time.

I do not need to lead how to feed Lisp code into a Haskell compiler. Just talk about Haskell, not Lisp.

I am an expert programmer with 30 years of experience with the Smalltalk IDE. The lack of a good IDE for Haskell is a definite negative. EclipseFP does not work. Atom does not work for Haskell. Stack and the other are building tools, but moronic compared with the Smalltalk IDE. The Smalltalk System Browser allows me to view everything on my computer. The Package Manager allows me to see what packages I can download and install on my computer. Both Managers are over 40 years old and still better than anything I have seen for Python, Lisp, APL, Prolog, Snobol, or Haskell.

Most books and tutorials talk as if their IDE would actually work on my machine. When it does not, their “help” is useless. All I see are versions of the C make utility.

I need a book for experienced programmers (with a degree in Mathematics) with examples which will work on my machine.

Robert Pearson

1 Like

Haskell is dramatically different from Lisp. I don’t think any Haskell intro text would be somehow teaching a newbie to ‘translate’ Lisp to Haskell, or aimed at ‘migrating’ someone from Lisp.

If your head is full of Lisp, I suggest the first thing you do is wash the Lisp out of it and start with a blank slate. I also suggest you wash your head of Smalltalk pre-conceptions. Functional Programming is dramatically different from OOP, and needs a different way of thinking/different abstractions. In particular beware that Haskell has artefacts called ‘classes’, ‘instances’ and ‘methods’, which share some superficial similarities but need a whole other mindset vs. OOP classes/methods.

There’s a modern IDE specifically aimed for Haskell/GHC. That is VS Code with HLS (Haskell Language Server) plugin.

Haskell programmers are smart, but not so smart they could guess which machine you’re talking about. If you mean your machine is “over 40 years old” I fear you might be out of luck.

So is it a tutorial on Haskell that you want? Or a tutorial on an IDE? Those are different questions, with different answers.

1 Like

The classic text is Learn You a Haskell For Great Good. It is available as a reasonably priced paperback, and is also available online for free. One problem that Haskell has is that many well-defined terms like functor, monad and class are colourfully and creatively repurposed, and understanding that makes Haskell much easier to understand as a whole.

The classic IDE is Visual Studio Code + HLS, although there is also an Emacs mode for Haskell. Haskell is mathematical in nature. With Lisp, you can iteratively hack something into existence within the current image, but with Haskell you are supposed to figure it out before you code it.

I used Chocolatey to install the Haskell software, although there are also online services like Haskell Online Compiler & Interpreter - Replit

Enjoy!

PS: Please dial back on the “Smalltalk is wonderful, but your language is stupid” - for your sanity as much as ours.

3 Likes

If you are looking for a more serious textbook on Haskell, then I would highly recommend Graham Hutton’s Programming in Haskell. He also posted his lectures on YouTube: FP and the follow-up AFP.

If you want a book about a mathematical approach to programming then I’d recommend the draft of Program Design by Calculation by José Nuno Oliveira (but, beware, you won’t learn how to setup a web server or command line application here).

As for installing the toolchain, the recommended option on all platforms is GHCup.

8 Likes
  1. Install Nix
  2. Install VSCode
  3. Open this template in VSCode
  4. Read through Graham Hutton’s or Richard Bird’s book
1 Like

“Good” is a bit of a subjective metric… so you might get lots of suggestions, none of which are “good” for you, or only good for a little bit of what you want to do.

For years I struggled, wanting to get more done than my ability to navigate and understand all the related topics. I would recommend spending a little bit of time defining what you want to do, and then map that to a set of topics you should learn more about to accomplish that. For example, if you want to interact with JSON vs interact with AWS APIs vs run a mathematical model vs process text… these will also require a different set of topics, and you won’t get far without understanding those topics.

Here are some thoughts which might help sort through the options:

  • Do you want a free book/tutorial, or are you willing to pay a few bucks?
  • Do you want thorough explanation of details, or a quick introduction to general possibilities?
  • Do you want to understand haskell the language, or how to build quality software with haskell? There are a few “Production Haskell” type books and tutorials. There are also people/blogs you can scour to better understand these topics.
  • Do you want to focus first on writing some haskell as quickly as possible, or do you care about knowing how to build and run that haskell code in the real-world? You’ll need to understand a fair bit about stack and/or cabal to be able to build and run your code, an alternative is to restrict yourself to ghci/etc to start and ignore stack/cabal.
  • Are you willing to restrict yourself to the base/prelude (standard lib) included with GHC, or how quickly will you need/want to start using packages with other people’s code? You’ll need to understand more about hackage and stack/cabal. There is also stackage, which is related and very useful, but could be skipped (or not) depending on your requirements.

Skipping the other resources that have been mentioned, I’ll add to the list:

Chris and Julie’s Haskell Programming from First Principals

As well as the old haskell-lang site, which was moved to Applied Haskell Syllabus.

1 Like

Haskellbook (Haskell Programming from First Principles) is a good reference tome (our The C++ Programming Language), and you can learn from it, but it’s long.

For something more practical and interesting, I’d suggest working through Get Programming with Haskell by Will Kurt and published by Manning.

Here is a Jupyter adaptation of the book Learn you a Haskell for Great Good!. You can edit and execute all the examples and you literally don’t have to “install” a single thing, it just runs in your browser.

3 Likes

Not a book, but a video course; IOHK / Well-Typed Haskell course is pretty good, from basics to Haskell’s core with interesting exercises. I helped to teach it once, that’s how I stumbled upon it :slight_smile: I think it’s also available on coursera.

Learn You a Haskell is the one that I used, but there are a variety of books, depending on your needs.

Why have you decided to learn Haskell? What are you trying to get out of it?

I love Haskell, and I found it to be superior (at least in a great many ways) to languages I already knew. But if you feel that Smalltalk is better than any other language out there, I suspect that learning a new language will be frustrating.

For Haskell, we have the Hackage website for that.

I recommend against writing Makefiles to build Haskell code. The idiomatic way is to write Cabal files.

Check out the platforms that GHC supports. If you are not on a Tier 1 or Tier 2 platform, Haskell probably won’t work for you. Even among Tier 2 platforms, you will be much happier if your platform supports GHCi. Not only is GHCi support necessary to run GHCi itself, but GHCi support is also necessary to use Template Haskell. (There are a number of packages on Hackage that use Template Haskell, so those packages won’t be usable on a platform without GHCi support.)

1 Like

Awesome! The book you recommended is by Jose Nuno Oliveira is like none other. Thanks so much.

I’m going through Effective Haskell, Effective Haskell: Solving Real-World Problems with Strongly Typed Functional Programming by Rebecca Skinner

1 Like

I never claimed Haskell was stupid. I just said that your IDEs eight do not work on Ubuntu MATÉ or are 40 years out of date. The lack of a functioning IDE makes designing programming difficult.

If Haskell was stupid, I would not invest time in trying to learn it.

The books that I have read believe that if you know Haskell syntax, then the design of your program will magically appear. I saw the same magical thinking when I learned OOP.

In my graduate Software Engineering course, the professor actually believed that if you specified a problem in enough detail, a solution would magically appear. I would like to see him produce a SLR0 parser for C. Or produce a program to compare two programs and decide if they do the same thing.

I have Graham Hutton’s book Programming in Haskell.
I am only to page 106. There is nothing on actually designing a program. Just some Haskell syntax.

His concept of a “parser” dates back to 1968. Since 1972 parsers are a composition of a lexical analyzer and a parser.

That’s about the end of “Part I: Basic Concepts” isn’t it? Sounds about right that you’ve mostly seen syntax (and semantics) of some very simple programs.

It sounds great to me that Hutton uses a simplification in an introductory programming book that is otherwise unrelated to parsing.

1 Like

You can try Haskell Bookcamp on Manning, which is a project-based approach.

The important thing to remember is that Haskell can’t be learned from books alone; you should get hacking and make simple Haskell programs as you learn the language. Haskell is becoming comparable to C++ in terms of learnability, unfortunately, so you should expect to be limited to some productive dialect for an extended period of time.

Most serious applications of parser combinators will often build up parsers for lexemes and then combine those to build parsers for syntax productions. Because of (I guess?) laziness and a much more compositional abstraction, the difference between scanner and parser can appear blurry at first glance, but most well-factored applications using parser combinators will still have that separation as a matter of software design.

Ironically, this is the precept of Type Driven Development; i.e, specify the problem well enough in types and the types of functions, use undefined or error “Todo” to get the compiler to accept partial programs, then the rest of your program will write itself as you remove the undefineds, possibly through the typed-hole feature (stand-ins where the compiler will suggest possible solutions).

Of course, this is an ideal; the type system isn’t powerful enough or ergonomic enough for this to work, so you still need to work out the details, and there are people who feel TyDD is too constraining, just as there’s people who dislike Test Driven Development.

Every Haskeller is using TyDD to some extent; even if you reject it and try to program based on pure type inference (which is not 100% reliable), you still have traces of TyDD via the “build outline, fill in outline” schema.

It’s also amusing that Rustacaeans seem to be adopting TyDD, but don’t call it such; Rust community is hilarious in that way.

For Bookcamp:

Haskell blog generator newbie introduction:

Here’s graninas’ book on how he thinks Haskell programs should be structured, but be aware that Haskell program design has multiple, clashing philosophies, and the only real constant is the separation of the side-effecting layer from the calculation layer. Hence, graninas is controversial.

I’m surprised it was only mentioned once but I highly recommend Will Kurt’s Get Programming with Haskell. I don’t necessarily think that it’s actually a bad thing, but I would agree with criticism of Hutton’s book that the end of chapter exercises are more akin to homework problem sets than actually writing a full program. Kurt’s book isn’t like that, it has a lot of projects that require you to create something bigger than just a few functions that solve exercise problems.

Additionally, I also fully recommend Finding Success (and Failure) in Haskell. It’s specifically aimed at people who have gotten the Haskell basics down (e.g., having worked through most of Hutton’s book) but haven’t ever made a full project. You may or may not be ready for it right now (I don’t know where you are on your Haskell journey), but I think it’s a great project-oriented book once you’re comfortable with typeclasses. Small quote from the preface: “This book is for people who have just started getting into Haskell but would like to move quickly and understand by doing.”

1 Like

Thanks for mentioning my book, I appreciate this.

Your comment makes me think that my points in the book are very convincing and you’re afraid a reader will stop learning and questioning after reading the book. I hope the reader will continue learning the subject after my book, and certainly, they will have a lot of ideas I haven’t touched.

P.S. I wouldn’t call it “controversial”. My book is not controversial, it’s opinionated at most. I myself don’t think I’m “controversial”, but rather consistent in my views for a decade, and not afraid of sharing them.