Index: doc/theses/jiada_liang_MMath/relatedwork.tex
===================================================================
--- doc/theses/jiada_liang_MMath/relatedwork.tex	(revision 5546f50bf35c5f4954710cc34931ca3a077bf641)
+++ doc/theses/jiada_liang_MMath/relatedwork.tex	(revision e048ece8ba334125dcccebb214f58a23f0e29d8a)
@@ -2454,3 +2454,70 @@
 
 
-\section{Algebraic Data Type}
+\section{OCamal}
+An enumerated data types is a list of named values.
+\begin{python}
+>>> type weekday =
+... | Monday
+... | Tuesday 
+... | Wednesday 
+... | Thursday 
+... | Friday 
+... | Saturday 
+... | Sunday
+\end{python}
+Enumerated data types are the simplest subset of Variants types. Because weekday is a summantion of values Monday to Sunday,
+enumerated data types are often call a sum type in turns of functional programming paradigm. 
+
+The values defined in an enumerated type are called data constructors. The data constructors of an enumerated data type 
+takes no value as parameter. They are known as 0-arity constructor.
+
+A more generic variant type has n-ary constructors. 
+\begin{python}
+>>> type color =
+... | Red
+... | Green of string
+... | Blue of int * bool
+\end{python}
+The color type can be constructed as a combination of a value from an int and a blue, using 
+the Blue data constructor. Mathematically, a Blue value is a Cartesian product of the int type and the bool. 
+Color type is a summation of a nullary type, an unary product type, and a cross product of int and bool. The 
+OCamal variant type can be create as a sum of product of different types.
+
+A variant type can have a recursively definition.
+\begin{python}
+>>> type stringList =
+... | Empty
+... | Pair of string  * list
+\end{python}
+
+OCaml's variant types are recusrive sum of product of types, which are known as Algebraic Data Types. Programming languages
+follows the functional programming paradigm often supports algebraic data types, and supports Pattern Matching against 
+algebraic data type.
+
+\begin{python}
+>>> let take_class = function
+... | Monday | Wednesday -> "CS442"
+... | Tuesday | Thursday -> "CS343"
+... | Friday -> "Tutorial"
+... | _ -> "Take a break"
+\end{python}
+
+The function a weekday as parameter, and returns "CS442" if the weekday value is Monday or Wednesday, "CS343"
+if the value is Tuesday or Thursday, "Tutorial" if it is Friday. The @_@ is wildcard, and it can match any weekday value.
+If the value is Saturday or Sunday, which are not matched by the previous cases, it will be matched by the @_@ and the 
+function returns "Take a break".
+
+Values of a product type can be named.
+\begin{python}
+>>> let check_color = match c with
+... | Red -> "Red"
+... | Green g -> g
+... | Blue i, _ -> int_of_string i
+\end{python}
+
+Recurisve function are often used to pattern match against a recurisve variant type.
+\begin{python}
+>>> let rec len_of_string_list = match l with
+... | Empty -> 0
+... | _ * r -> 1 + len_of_string_list r
+\end{python}
