There are type classes that control the flow of the program (e.g. whether the program should do X and then Y or should do X and Y at the same time).
We've linked to an article below that explains these abstract notions in a clear manner using pictures and the
Maybe a data structure. However, since these concepts are explained in Haskell, which uses different terminology than Purescript, use the following table to
map Haskell terminology to Purescript terminology:
|Haskell Terminology||Purescript Terminology|
|see the implementation in Purescript|
Here's the link: Functors, Applicatives, and Monads in Pictures
map List function implemented in Purescript:
data List a = Nil | Cons a (List a) instance Functor List where map :: forall a b. (a -> b) -> List a -> List b map f Nil = Nil map f (Cons head tail) = Cons (f head) (map f tail)
|Concept||Argument is NOT inside a Box / context||Argument is inside a Box / context||Name|
|1-arg function application|
|2+-arg function application|
These will be covered at a slower and clearer pace in the upcoming files. This is just an overview of them.
|Change a value, |
|Same as |
|Put a value into a box |
Run code in parallel
|Associativity: ||Given an value of a box-like type, |
|Monad||FP Program||The data structure used to run FP programs by executing code line-by-line, function-by-function, etc.|
data Box a = Box a instance Functor Box where map f (Box a) = Box (f a) instance Apply Box where apply (Box f) (Box a) = Box (f a) instance Bind Box where bind (Box a) f = f a instance Applicative Box where pure a = Box a instance Monad Box
In these files, we will "evaluate" functions by using graph reductions: replacing the left-hand side (LHS) of the
= sign (the function's call signature) with the right-hand side (RHS) of the
= sign (the function's implementation / body). In other words...
someFunction arg1 arg2 arg3 = bodyOfFunction | call signature (LHS) | = | body (RHS) |