New PureScript Book: Functional Programming Made Easier

I’m excited to announce that I finished my book, Functional Programming Made Easier: A Step-by-Step Guide. By the end of this book, the reader will not only learn Functional Programming, but they will learn PureScript.

It would’ve come out sooner, but PureScript 14 was released right as I was finishing it. And unfortunately, I have the reader go to Pursuit many times to get them used to the process of looking up library functions and Pursuit has no way to show you only libraries from a single major release.

This book takes the reader from knowing zero about Functional Programming to writing a Full-Stack application using HTTPure on the backend and Halogen 6 on the front-end.

Below is a list of some of what’s covered (in no particular order):

  • Pure Functions
  • Immutability
  • Higher-order Functions
  • Currying
  • Partial Application
  • Recursion
  • Tail Recursion
  • Pattern Matching
  • Types
    Polymorphic
    Monomorphic
    Sum
    Product
  • Typeclasses
  • Multi-parametric Typeclasses
  • Overlapping Instances
  • Orphaned Instances
  • Functional Dependencies
  • Isomorphisms
  • Homomorphisms
  • Abstract Algebra
    Magma
    Semigroup
    Monoid
    Group
    Abelian Group (aka Commutative Group)
    Semiring
    Ring and Commutative Ring
    Euclidean Ring
  • Folds
  • Algebraic Data Types (ADT)
  • Functors (Covariant, Contravariant, Invariant)
  • Functors of Values vs Functions
  • Bifunctors
  • Profunctors
  • Applicative Functors
  • Traversables
  • Foldables
  • Applicative Parsers
  • Monads
  • Monadic Parsers
  • Monad Stacks (aka Monad Transformers)
  • Category Theory (superficially)
    Definition
    Hask Category
    Functors
    Applicative
    Kleisli Category

Some of the skills it’ll teach you along the way are:

  • Interpreting Compiler Errors
  • Type Holes
  • Effects (Synchronous and Asynchronous)
  • AVars and Refs (Managed Global State)
  • Data Bus
  • Ajax
  • JSON Decoding
  • Foreign Function Interface (FFI)

From the exercises and final project you will learn:

  • Hash Routing
  • Static File Servers
  • CORS
  • Salt Hashing Passwords
48 Likes

Just want to say congrats! I know it’s a lot of work to create something like this, so awesome job on actually finishing it!

Could this be described as PureScript’s version of the book most people go to when learning Haskell, Haskell Programming from First Principles? It seems to have a similar depth and length as well as having exercises.

6 Likes

Thanks. It was more work than anyone can imagine.

I’d say that it’s similar in scope to First Principles, but that’s where the similarities end. I read that book along with many others while I was learning Haskell but none of them went into the depth that I wanted.

Also, the exercises in the book are very unique as I explain in detail on the Leanpub page. I give you an exercise and then I code it with you, one line at a time as if I’m sitting there pair programming with you.

I explain what my strategy is before I write the next line. I may need to investigate some Types or library Functions before I code the next line and I detail out all of the steps to help the reader go from nothing to a working Function or Typeclass Instance or whatever.

Another thing I do is show every compiler error along the way. This is to simulate the real-world process of working in a Strictly Typed Functional Language.

Also, if I made a mistake while I was coding the book, I left it in. We find my mistakes (some of which were done on purpose) together and then I ask the reader to fix them followed immediately with a line by line pair-programming fix of my own.

I’ve been programming for 40 years and I’ve never had a programming book do all of that with me.

This book is both the programming book I always wanted and the Functional Programming book I always wanted. I wish I could go back in time and give it to myself and save me the hassle and frustration I felt learning Haskell.

19 Likes

Hey @cscalfani this is pretty awesome! Major congratulations!

As the author of HTTPure, I’d love to take a look at the backend section of the book and share feedback if you’d like to share it with me. It would also be helpful to me to know how folks are using it. Just DM if interested!

8 Likes

Loved your sample. Bought :] maybe this will be the way I actually learn Haskell/purescript.

I have light Rescript/Ocaml experience, and that’s still very different from the heavy handed parts of pure fp abstractions.

2 Likes

@cscalfani congratulations on your book being in the top 10 best-selling books on Leanpub in the last week!

8 Likes

So happy to hear you’re not giving up. I tried 4 times to learn Haskell before finally sticking the landing.
It shouldn’t be that hard, so I that’s why I spent the last 2 years writing this book and field testing it with developers who are now developing a front-end application in PureScript using Halogen.

3 Likes

Thanks Thomas… I had no idea it was top 10 LOL. I’m so happy with the overwhelming response I’m getting with the book. TBH I didn’t want to write it but I knew if I didn’t know one was going to and certainly not at the level I wanted.

7 Likes

This book is almost 2000 pages long
Which in my opinion is a red flag

It probably means the author wrote down, any idea that crossed his mind, and that the content
is not distilled

So is it a book worth reading , is the information in it accurate, correct?
The book does not seem to have been reviewed by peer programmers before it was published on leanpub

And the author does not seem to be a known contributor to purescript

You should probably at least read the free PDF sample before jumping to conclusions you know?!

3 Likes

Consider keeping your unfounded opinions to yourself if you don’t have anything nice to say.

@cscalfani has been active in various community channels for a long time, and I have no doubt he has plenty of interesting stories to tell about using PureScript to solve real problems in the industry.

15 Likes

If I could restate your above comments/questions, I think you’re saying something like this

While I would really like to grow in my understanding and abilities, is it worth it to read the book?

This book is 2,000 pages long; that’s a huge commitment to make. I don’t believe I’ve seen the author contribute in other significant ways in the community, so I’m hesitant to believe the book’s claims that it really does make learning FP easier. I’m not trying to offend the author, but there have been many people who have tried writing such a work. Many such works also claim to be “the” book you need to read to finally unlock FP.

So, should I read this book? Or should I continue using other resources (e.g. the PS by Example book)?

Given the Table of Contents of the book and his response to my original question above, I’d already recommend this book over my own work (GitHub - JordanMartinez/purescript-jordans-reference: Learn PureScript with this "clone and play" repository) for those who want a deeper understanding of PureScript and how to use it to solve real world problems. I don’t think the goal of this book is to enable you to write “Hello world” immediately. Rather, I think it will likely make you a competent FP programmer.

I’ve been thinking of buying and reading it myself to just see what I could learn.

Obviously, the page length means you can’t just pick up the book and know PureScript in a few hours. But most people who try to do that anyway often get stuck by all sorts of things. There’s a reason so many monad tutorials exist. If anything, the length is necessary because how else could you accomplish the goal of guiding someone through every nook and cranny of a problem they could experience when learning PureScript and how to use it to build a web app?

12 Likes

Seems the free PDF sample (which is btw currently not available for download, S3 error) mostly covers topics which can be found in this nice document: GitHub - mjepronk/wiwinwl-purescript: What I Wish I Knew When Learning PureScript

I believe it would be useful to see there some more advanced topics disclosed.

3 Likes

What section in particular would you like to see?

1 Like

This is just a proposal to make the content more open, maybe: Monad Stacks/Transformers.

1 Like

I’ll take this into consideration the next time I release a sample, which I’m going to do to capture some of the typos readers have informed me of.

4 Likes

I’m currently studying Haskell From First Principles and intend improve my FP skills through PureScript afterwards.

That being said, I wanted to point out that the book is expensive depending where one lives, like in my case (Brazil) and the price converted to BRL is a small fortune for most of us underpaid developers around here. Bear in mind I think the book and your work is worth every single cent. Just saying that it is harder for people in some places to be able to purchase it.

Took a look at the sample. Looks awesome! I was impressed with the sheer amount of snippets of code and examples. The font, colors and overall look and feel of the book is very pleasant and easy to read.

I especially loved the callouts. They just make it so natural and easy to read the explanation of each specific piece of code under scrutiny. By the way, did you use Asciidoctor?

All in all, amazing job! Congrats are in order!! λ

4 Likes

Originally, I thought setting the lowest price to $39.99 would allow people in other countries purchase the book. But a few people have reached out to me and when I asked them what they can afford, I was shocked. I’m not surprised at my ignorance about how much more expensive things are here and how we’re lucky to be able to easily afford $40 for a book since I’ve really haven’t been outside of the US except for a few exceptions.

In every case someone has reached out to me, I’ve given them a coupon for whatever they said they could afford. But that doesn’t scale well and it leaves out everyone who isn’t persistent enough to reach out.

I’ve been struggling with a solution short of lowering the price which will devalue the book for a lot people. I really think people need to have some skin in the game. If you don’t pay for something, you don’t value it when compared to things you do pay for.

I recently spoke to Leanpub and they suggested that I put a message for anyone who cannot afford it, to reach out to me via the Email the Author link and then I could send them a coupon.

This solves only half of the problem, i.e. it doesn’t leave anyone out who feels that emailing me is imposing. But it still doesn’t scale well. But it’s all I’ve got at my disposal ATM. So, I plan to add that to the book’s page soon.

Please let me know if it’s too expensive for you and let me know what you can afford and I’ll gladly send you a coupon link.

Thanks for educating me. And thanks for the kind words. And yes I used AsciiDoctor for the CALLOUTS. I think they’re an amazing tool for teaching/learning code. I’m so happy to hear you appreciate the layout and look of the book. I spent the first month working on getting that right. For me, aesthetics are critical. If a book is unapproachable, you won’t learn as well. But if it pleases the eye, you will enjoy every minute you spend with it.

Take care.

5 Likes

Maybe you can set discount on specials days, or occasions
People who bought the book at a higher price, should not feel bad
Almost all book publishers, offer limited time coupons or limited time discounts

Kudos

1 Like

Thanks for the suggestion. But I think having a way to ALWAYS get it at a reasonable price for your country might be better. I could be completely wrong. I’ve never done this before. So I’m going to try the coupon notice on the page and if it fails, I’m going to try your suggestion.

I really want to make sure that someone’s inability to pay US prices never holds them back.

4 Likes