# Work In Progress

### Hello TypeScript, Language Introduction and Cheat Sheet

TypeScript is a superset of JavaScript, that means valid JavaScript code is valid TypeScript code, thus JavaScript libraries can be used in TypeScript. TypeScript introduces optional static typing which makes much easier to scale with larger development teams. TypeScript compiles to JavaScript for it to be executed/interpreted. We focus here only on TypeScript, not on using it on web development. We are trying to focus on one challenge only at a time. Here we are focusing on TypeScript only. This also means that we will not talk about alternative ways to do the same thing that are coming from JavaScript.

### Creating pipelines using channels in Go

### A Simple Pipeline

### Scala: Types and Type Composition

We need to think of our types bottom-up. We need to thoughtfully and purposefully design our types to mirror our business domain. Types should only allow correct values. This of course comes at a cost, and we need to decide consciously where and how are we willing to pay that cost, if we want to.

### Scala: SemiGroup

- A SemiGroup is a type class with a single operation append.
- If we throw away the right side of the SemiGroup, we get a first SemiGroup and if we through away the left side we get a second SemiGroup
- Don’t think of SemiGroup as a summation/addition (regardless of append)
- A good example ofa SemiGroup is a string, int, option…
- Law: Must be associative (but not necessarily commutative, string is not commutative, yet it is associative)

### Scala: Monoid

- Every monoid is a semiGroup but not the other way around. It has all characteristics of a semigroup + more
- Laws:
- Left Identity
`append(a, 0) == a`

- Right Identity
`append(0, a) == a`

- Left Identity
`NotEmpty`

is not a monoid since it has no zero value.- Permission systems should be implemented as monoidal systems.

### Scala: Functor

- Functors can only be defined over types that are
`[*] => *`

- Laws:
- Identity law (identity function):
`map(fa, identity) = fa`

- Composition:
`map(map(fa,g), f) = map(fa, g andThen f)`

or`fa.map(g andThen f) = fa.map(g).map(f)`

- Identity law (identity function):
- Functors compose very well
- product of two functors is a functor
- Sum of two functors is a functor
- Nested functors is a functor

- Functor preserves the structure (container type). For an example a list order can’t change.
- Functor doesn’t need to be a data structure, it could be a function. Lots of data structures are functors but not all functors are data structures.
- Functors doesn’t allow you to combine programs but only to change the return type.

- Functors can only be defined over types that are