DRAFT

These are concise, early learning functional programming notes from these sources:

- https://wiki.haskell.org/Typeclassopedia
- https://www.manning.com/books/concurrency-in-dotnet
- https://stackoverflow.com/a/4412319/1108891 talks about how C# interfaces/generics cannot express Functors, Monads, nor Applicatives.
- https://en.wikipedia.org/wiki/F
*Sharp*(programming_language) - https://en.wikipedia.org/wiki/Haskell
*%28programming*language%29 - https://en.wikipedia.org/wiki/Generational
*list*of*programming*languages

Each of my notes has the following structure, and points that are [in brackets are my own intuitions].

```
Heading that can turn in to a question.
1. A series of phrases,
2. each of which,
3. is about this long,
4. and that has,
5. about seven (plus minus two) points,
6. because that makes it,
7. easy to read and to rehearse.
```

### Psuedo Code

The some pseudo-code shows the signatures of fundamental functional programming concepts in C# syntax. The comments above each shows the Haskell syntax and names some similar methods from C#.NET.

https://wiki.haskell.org/Typeclassopedia#Definition

```
public class MyFunctor<T>
{
public T Inner { get; }
public MyFunctor(T inner) => Inner = inner;
}
public static class MyFunctorExtensions
{
// class Functor f where
// fmap :: (a -> b) -> f a -> f b
public static MyFunctor<TResult> Fmap<TSource, TResult>(
this MyFunctor<TSource> input,
Func<TSource, TResult> func) => new MyFunctor<TResult>(func(input.Inner));
}
```

### Programming Language Ancestry

```
ML
Standard ML
Caml
OCaml
Rust
F# <-----
SASL
Miranda
Haskell
Rust
Swift
Lisp
Clojure
Java
C#
Scala
```

### Map

- aka fmap, Select
`E<'T> -> ('T -> 'U) -> E<'U>`

- [projection]
- applies a specified function
- ... to the underlying value
- ... of an elevated type.
- the LINQ
`Select(...)`

method - ... is a map operation
- ... on
`IEnumerable`

types.

### Bind

- aka flapMap, SelectMany
`E<'T> -> ('T -> E<'U>) -> E<'U>`

- [projection to elevated]
- the LINQ `SelectMany(...) method
- ... is a bind operation
- ... on
`IEnumerable`

types.

### Apply

`E<'T> -> E<('T -> 'U)> -> E<'U>`

- [elevated projection]

### Pure

- aka return
`'T -> E<'T>`

### Elevated Type

- a container
- wraps an underlying value
- provides a context around that underlying value

### Functor

- a context around a value
- supports the map/fmap operation
- [an
`IEnumerable`

in C# is like a functor, - ...because
`IEnumerable`

supports`Select`

] - [A value in a computational context.]

### Applicative functor

- [A function in a computational context.]

### Monad

- a context around a value
- supports the bind and return operations

### Monoid

- TODO
- TODO

### Type Class

- [similar to C# interface but less powerful]