# HG changeset patch # User Yasutaka Higa # Date 1429496002 -32400 # Node ID 7b22ac1b6a2cd7d5cf9a6f831ae00e716da96b2a # Parent 75e49a25e9616e00d2c5d8e688a95c85fae347d8 Add description to example diff -r 75e49a25e961 -r 7b22ac1b6a2c cfopm.pdf Binary file cfopm.pdf has changed diff -r 75e49a25e961 -r 7b22ac1b6a2c cfopm.tex --- a/cfopm.tex Mon Apr 20 10:31:10 2015 +0900 +++ b/cfopm.tex Mon Apr 20 11:13:22 2015 +0900 @@ -161,21 +161,21 @@ \begin{align*} f :: A \rightarrow B \\ g :: B \rightarrow C \\ - g \circ f :: A \rightarrow C \\ + g . f :: A \rightarrow C \\ \\ h :: C \rightarrow D \\ (h . g) . f = h . (g . f) :: A \rightarrow D \end{align*} -Sum type is introduced using Haskel syntax(Table\ref{src:delta_data_definition}). +Sum type is introduced using Haskel syntax(Table \ref{src:delta_data_definition}). \begin{table}[html] \begin{lstlisting} data Delta a = Mono a | Delta a (Delta a) \end{lstlisting} +\caption{Definition of data type ``Delta`` in Haskell} \label{src:delta_data_definition} -\caption{Definition of data type ``Delta`` in Haskell} \end{table} This is data type definition of sum type delta which has type variable {\tt a}. @@ -188,12 +188,12 @@ deltaFmap f (Mono x) = Mono (f x) deltaFmap f (Delta x d) = Delta (f x) (deltaFmap f d) \end{lstlisting} +\caption{Arrow mapping for data type ``Delta``} \label{src:delta_fmap} -\caption{Arrow mapping for data type ``Delta``} \end{table} Arrow mapping in a functor satisfies identity law and distribution law. -Data type can be accessed by pattern matching(Table\ref{src:head_delta}). +Data type can be accessed by pattern matching(Table \ref{src:head_delta}). \begin{table}[html] \begin{lstlisting} @@ -201,8 +201,8 @@ headDelta (Mono x) = x headDelta (Delta x d) = x \end{lstlisting} +\caption{Define function to Delta using pattern matching} \label{src:head_delta} -\caption{Define function to Delta using pattern matching} \end{table} This is a natural transformation from functor Delta to identity functor. @@ -211,8 +211,8 @@ Monad in category A is $ triple (T, \eta, \mu) $. T is a functor from A to A. -eta is a natural transformation from identity functor to T. -mu is a natural transformation from TT to T. +$ \eta $ is a natural transformation from identity functor to T. +$ \mu $ is a natural transformation from TT to T. TT is a nested data structure of T. Monad also satisfies to laws below: @@ -224,14 +224,14 @@ Various meta computations represents by definition of triple. For each function $ f :: A \rightarrow B $ , there is a meta computation $ f^* :: A \rightarrow T B $. -Combination of $ f^* $ $ g^*$ is defined as follows: +Combination of $ f^* $ $ g^* $ $ h^* $ is defined as follows: \begin{align*} - f^* . g^* = \mu (deltaFmap f^* (\mu (deltaFmap g^*))) + (h^* . g^*) . f^* = h^* . (g^* . f^*) \end{align*} Association law of $ f^* $ is derived from Monad laws. -In this way, for each Monad there is a new category of $ f^* $which is a well known Kleisli Category. +In this way, for each Monad there is a new category of $ f^* $ which is a well known Kleisli Category. Normal function f has a meta function $ f^* $ which returns Monad T. @@ -312,8 +312,8 @@ (Delta x d) >>= f = Delta (headDelta (f x)) (d >>= (tailDelta . f)) \end{lstlisting} + \caption{Definition of Delta Monad in Haskell} \label{src:delta_monad} - \caption{Definition of Delta Monad in Haskell} \end{table} Modifications of values are stored as a list like structure. @@ -325,6 +325,12 @@ % FIXME: please check added an example \section{Example} +We show an example using Delta Monad(Table \ref{src:example_of_delta}). +A program contains only a function which calculate integer. +In first version, function f is adding 2 to argument. +In second version, modified function f multiplying 3 to argument. +We can define {\tt f'} as a meta function contains both version. +Meta function {\tt f'} outputs two results for value 100. \begin{table}[html] \begin{lstlisting} @@ -344,8 +350,8 @@ -- *Main> Mono 100 >>= f' -- Delta 102 (Mono 300) \end{lstlisting} -\label{src:example_delta} \caption{An Example using Delta} +\label{src:example_of_delta} \end{table} \section{Conclusion and Future Works}