r/purescript • • Jun 15 '21

PureScript Book: Functional Programming Made Easier: A Step-by-Step Guide

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.

https://leanpub.com/fp-made-easier

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

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

  1. Pure Functions

  2. Immutability

  3. Higher-order Functions

  4. Currying

  5. Partial Application

  6. Recursion

  7. Tail Recursion

  8. Pattern Matching

  9. Types

    1. Polymorphic

    2. Monomorphic

    3. Sum

    4. Product

  10. Typeclasses

  11. Multi-parametric Typeclasses

  12. Overlapping Instances

  13. Orphaned Instances

  14. Functional Dependencies

  15. Isomorphisms

  16. Homomorphisms

  17. Abstract Algebra

  18. Magma

  19. Semigroup

    1. Monoid

    2. Group

    3. Abelian Group (aka Commutative Group)

    4. Semiring

    5. Ring and Commutative RingEuclidean Ring

  20. Folds

  21. Algebraic Data Types (ADT)

  22. Functors (Covariant, Contravariant, Invariant)

  23. Functors of Values vs Functions

  24. Bifunctors

  25. Profunctors

  26. Applicative Functors

  27. Traversables

  28. Foldables

  29. Applicative Parsers

  30. Monads

  31. Monadic Parsers

  32. Monad Stacks (aka Monad Transformers)

  33. Category Theory (superficially)

    1. Definition

    2. Hask Category

    3. Functors

    4. Applicative

    5. Kleisli Category

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

  1. Interpreting Compiler Errors

  2. Type Holes

  3. Effects (Synchronous and Asynchronous)

  4. AVars and Refs (Managed Global State)

  5. Data Bus

  6. Ajax

  7. JSON Decoding

  8. Foreign Function Interface (FFI)

From the exercises and final project you will learn:

  1. Hash Routing

  2. Static File Servers

  3. CORS

  4. Salt Hashing Passwords

91 Upvotes

30 comments sorted by

View all comments

1

u/janat087 Aug 15 '21

You explain the difference between sum and product types without pointing to the fact that if you were to count the permutations those hold you’d sum or multiply. It got theoretical and meaningless in your description of reasoning. Otherwise I like the rest of segways into theory.

2

u/imright_anduknowit Aug 16 '21

Thanks. I’m glad you’re enjoying the book.

I do talk about calculating the number of inhabitants in a Type. Maybe you haven’t gotten to it yet. It’s in a later section in Chapter 3.

1

u/janat087 Aug 29 '21

Takewhile evaluation isn't explained while annotated, wrong evaluation, and was probable meant to be earlier in the book.

1

u/imright_anduknowit Aug 30 '21

If you're talking about `takeWhile` in Chapter 3, then yes, it's not explained here because it's only used as an example. In Chapter 5, you will write this function where it is explained.

1

u/janat087 Aug 30 '21

The reduction of function is wrong. You actually did explain naming for sum and product methodology, I reread that section. 1 : (2 : (if (_ <= 2) 3 then 3 : takeWhile (_ <= 2) Nil else Nil)) -- evaluating we get 1 : (2 : takeWhile (_ <= 2) Nil else Nil). Shouldn't it evaluate to just nill?

1

u/imright_anduknowit Aug 31 '21

1 : (2 : takeWhile

You're right. Thanks for this. The last 3 steps should look like:

-- substituting into <2>
1 : (2 : (if (_ <= 2) 3 then 3 : takeWhile (_ <= 2) Nil else Nil))
-- evaluating we get
1 : (2 : Nil)
-- removing Parentheses
1 : 2 : Nil

1

u/backtickbot Aug 31 '21

Fixed formatting.

Hello, imright_anduknowit: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.