# Record of Mar. 28th, 2018

## Facts about Bash/Dash/sh

- Arch Linux uses Bash(Bourne Again Shell) for POSIX shell (/bin/sh)
- When Bash is called with
`sh`

, it tries to emulate the POSIX shell - Dash is POSIX compatible, making it Bash incompatible.

## Facts about of V-Table

In C++, the virtual table pointer is located in the head of the class instance.

The virtual table is a table of pointer to virtual(overridden or not) functions.

Therefore, to invoked these virtual methods, a mechanism called thunk(a jocular form of think) is needed. It means doing something before the actual function is called. And functional language relies largely on this mechanism.

## Fact about Zeromq

- It is a distributed communication library.
- It sits on top of the TCP/IP layer, means the possibility is huge that it sends message by syscalls like
`send`

.

## Facts about lttng

- Means Linux Tracing Tool, next generation
- In Artful repo, for older Ubuntu versions, go to ppa:lttng
- Can be used to trace syscall, or even user application(need to write code into the program)
`babeltrace`

could be used to translate the file.

## Facts about Ubuntu

- The life span of Zesty(17.04) has ended in Jan. 2018. Artful will meets its end in Jul. 2018.
- The life span of non-LTS versions is 9 months.
- 18.04 is called Bionic, will upgrade later

## Facts about Opam

The package manager of OCaml. Not a kind of mineral.

## Facts about type algebra

Refer to this page.

The type could be expressed in an algebra-like manner:

0: None type, there is 0 way to construct an empty type object

1: Singleton

2: Two ways to construct the type, boolean type is an example

$+$: Sum type, the object of type $a+b$ could be either type a or type b, but not both, there are exactly $a+b$ ways to construct the object. Injection is used to construct an instance, if it is called an instance. $\times$: Product type, the object of type $a\times b$ is a combination of an object of type a and one of type b. OCaml adopts this notation, an constructor applied to type $a\times b$ is written as `Foo of a*b`.And as a surprising yet unsurprising coincidence, the sum and product obey the rules:

Communicative: $a+b=b+a$

Associative: $a+(b+c)=(a+b)+c$

Distributive: $a\times(b+c)=a\times b+a\times c$

For recursive types like the tree, which is

data Tree a = Leaf a | Branch (Tree a) (Tree a) |

The formula is:

$T = a + T^2$Therefore, we have:

$T^2-T+a=0$ $T = \frac{1-\sqrt{1-4a}}{2}$ (Why choose the minus sign?)Use Taylor series, we could obtain:

$T=1 + a + a^2 + 2 a^3 + 5 a^4 + 14 a^5 + 42 a^6 \cdots$And the coefficients of a are Catalan numbers.

Zippers means we could turn the pocket inside out and focus on one element in a data structure, in a way that updating the focused element , as well as moving the focus around, takes $O(1)$ time.

And we can focus on the holes of a type.

$a\times b$ has one hole of a $a+a$ has two holes of a, that is `data _, a` and `data a, _`It is likened to partial differentiation, for example:

$\frac{\partial (u \times v)}{\partial a} = \frac{\partial u}{\partial a} \times v + \frac{\partial v}{\partial a} \times u$If $\frac{\partial t}{\partial a}$ means the hole numbers of a in t, and let the g of constant be zero, and g of other variables be one, then magic!

It can be applied to the list type:

data List a = [] | Cons a (List a) |

Added 3/29:

But the same thing could not be perfectly applied to the binary tree type.

Recall, we have the binary tree type:

data Tree a = Leaf | Branch a (Tree a) (Tree a) |

Then the formula is:

$T=1+aT^2$The best I could get is about:

$\frac{\partial T}{\partial a}=T^2L$, and the $L$ is a list of type $2aT$.According to LYAHFGG, the zipper of a binary tree should be something like this:

data Crumbs a = LeftCrumb a (Tree a) | RightCrumb a (Tree a) |

It is easy to see that `Crumbs a`

has a type of $2aT$ and `BreadCrumbs a`

has a type of $\frac{1}{1-2aT}$.

But wait! That gives $T$ rather than a $T^2$ in the numerator.

Maybe we’ve just started wrong, like, we took the wrong differentiation.

That would be left for future investigation.

## Misc

**PEBKAC** (*Problem Exists Between Keyboard And Chair*) is the word that describes user error.