updates from Peter
[phd-thesis.git] / appx / c4hp.tex
index cfb27bc..5f8875c 100644 (file)
@@ -2,8 +2,11 @@
 
 \input{subfilepreamble}
 
 
 \input{subfilepreamble}
 
+\setcounter{chapter}{0}
+
 \begin{document}
 \input{subfileprefix}
 \begin{document}
 \input{subfileprefix}
+\ifSubfilesClassLoaded{\appendix}{}
 \chapter{\texorpdfstring{\glsentrytext{CLEAN}}{Clean} for \texorpdfstring{\glsentrytext{HASKELL}}{Haskell} Programmers}%
 \label{chp:clean_for_haskell_programmers}
 
 \chapter{\texorpdfstring{\glsentrytext{CLEAN}}{Clean} for \texorpdfstring{\glsentrytext{HASKELL}}{Haskell} Programmers}%
 \label{chp:clean_for_haskell_programmers}
 
@@ -18,15 +21,15 @@ While \gls{CLEAN} and \gls{HASKELL} were both conceived around 1987 and have sim
 This section describes some of the history of \gls{CLEAN} and provides a crash course in \gls{CLEAN} pecularities written for \gls{HASKELL} programmers.
 It is based on the 
 
 This section describes some of the history of \gls{CLEAN} and provides a crash course in \gls{CLEAN} pecularities written for \gls{HASKELL} programmers.
 It is based on the 
 
-\Gls{CLEAN}---acronym for Clean \glsxtrlong{LEAN}~\citep{barendregt_towards_1987}---, was originally designed as a \gls{GRS} core language but quickly served as an intermediate language for other functional languages~\citep{brus_clean_1987}.
-In the early days it has also been called \emph{Concurrent} \gls{CLEAN}~\citep{nocker_concurrent_1991} but these days the language has no support for this anymore.
-Fast forward thirty years, \gls{CLEAN} is now a robust language with state-of-the-art features and is actually used in industry as well as academia---albeit in select areas of the world~\citep{plasmeijer_clean_2021}.
+\Gls{CLEAN}---acronym for Clean \glsxtrlong{LEAN} \citep{barendregt_towards_1987}---, was originally designed as a \gls{GRS} core language but quickly served as an intermediate language for other functional languages \citep{brus_clean_1987}.
+In the early days it has also been called \emph{Concurrent} \gls{CLEAN} \citep{nocker_concurrent_1991} but these days the language has no support for this anymore.
+Fast forward thirty years, \gls{CLEAN} is now a robust language with state-of-the-art features and is actually used in industry as well as academia---albeit in select areas of the world \citep{plasmeijer_clean_2021}.
 
 Initially, when it was used mostly as an intermediate language, it had a fairly spartan syntax.
 However, over the years, the syntax got friendlier and it currently it looks a lot like \gls{HASKELL}.
 
 Initially, when it was used mostly as an intermediate language, it had a fairly spartan syntax.
 However, over the years, the syntax got friendlier and it currently it looks a lot like \gls{HASKELL}.
-In the past, a \emph{double-edged} fronted even existed that allowed \gls{CLEAN} to be extended with \gls{HASKELL98} syntax and vice versa, however this frontend is no longer maintained~\citep{groningen_exchanging_2010}.
-This chapter therefore gives a brief syntactical and functional comparison, a complete specification of the \gls{CLEAN} language can be found in the latest language report~\citep{plasmeijer_clean_2021}.
-Many of this is based on work by Achten although that was based on \gls{CLEAN} 2.1 and \gls{HASKELL98}~\citep{achten_clean_2007}.
+In the past, a \emph{double-edged} fronted even existed that allowed \gls{CLEAN} to be extended with \gls{HASKELL98} syntax and vice versa, however this frontend is no longer maintained \citep{van_groningen_exchanging_2010}.
+This chapter therefore gives a brief syntactical and functional comparison, a complete specification of the \gls{CLEAN} language can be found in the latest language report \citep{plasmeijer_clean_2021}.
+Many of this is based on work by Achten although that was based on \gls{CLEAN} 2.1 and \gls{HASKELL98} \citep{achten_clean_2007}.
 When \gls{HASKELL} is mentioned we actually mean \gls{GHC}'s \gls{HASKELL}\footnote{If an extension is enabled, a footnote is added stating that \GHCmod{SomeExtension} is required.} this is denoted and by \gls{CLEAN} we mean \gls{CLEAN} 3.1's compiler with the \gls{ITASK} extensions.
 
 \section{Features}
 When \gls{HASKELL} is mentioned we actually mean \gls{GHC}'s \gls{HASKELL}\footnote{If an extension is enabled, a footnote is added stating that \GHCmod{SomeExtension} is required.} this is denoted and by \gls{CLEAN} we mean \gls{CLEAN} 3.1's compiler with the \gls{ITASK} extensions.
 
 \section{Features}
@@ -45,12 +48,12 @@ In \gls{HASKELL}, in patterns, strictness can be enforced using \haskellinline{!
 Within functions the strict let (\cleaninline{#!}) can be used to force evaluate an expression, in \gls{HASKELL} \haskellinline{seq} or \haskellinline{\$!} is used for this.
 
 \subsection{Uniqueness typing}
 Within functions the strict let (\cleaninline{#!}) can be used to force evaluate an expression, in \gls{HASKELL} \haskellinline{seq} or \haskellinline{\$!} is used for this.
 
 \subsection{Uniqueness typing}
-Types in \gls{CLEAN} may be \emph{unique}, which means that they may not be shared~\citep{barendsen_uniqueness_1996}.
+Types in \gls{CLEAN} may be \emph{unique}, which means that they may not be shared \citep{barendsen_uniqueness_1996}.
 The uniqueness type system allows the compiler to generate efficient code because unique data structures can be destructively updated.
 The uniqueness type system allows the compiler to generate efficient code because unique data structures can be destructively updated.
-Furthermore, uniqueness typing serves as a model for side effects as well~\citep{achten_high_1993,achten_ins_1995}.
-\Gls{CLEAN} uses the \emph{world-as-value} paradigm where \cleaninline{World} represents the external environment and is always unique~\citep{backus_introduction_1990}.
+Furthermore, uniqueness typing serves as a model for side effects as well \citep{achten_high_1993,achten_ins_1995}.
+\Gls{CLEAN} uses the \emph{world-as-value} paradigm where \cleaninline{World} represents the external environment and is always unique \citep{backus_introduction_1990}.
 A program with side effects is characterised by a \cleaninline{Start :: *World -> *World} start function.
 A program with side effects is characterised by a \cleaninline{Start :: *World -> *World} start function.
-In \gls{HASKELL}, interaction with the world is done using the \haskellinline{IO} monad~\citep{peyton_jones_imperative_1993}.
+In \gls{HASKELL}, interaction with the world is done using the \haskellinline{IO} monad \citep{peyton_jones_imperative_1993}.
 The \haskellinline{IO} monad could very well be---and actually is---implemented in \gls{CLEAN} using a state monad with the \cleaninline{World} as a state.
 Besides marking types as unique, it is also possible to mark them with uniqueness attributes variables \cleaninline{u:} and define constraints on them.
 For example, to make sure that an argument of a function is at least as unique as another argument.
 The \haskellinline{IO} monad could very well be---and actually is---implemented in \gls{CLEAN} using a state monad with the \cleaninline{World} as a state.
 Besides marking types as unique, it is also possible to mark them with uniqueness attributes variables \cleaninline{u:} and define constraints on them.
 For example, to make sure that an argument of a function is at least as unique as another argument.
@@ -68,7 +71,7 @@ f :: v:a u:b -> u:b, [v<=u]  // f works when a is less unique than b
 %:: T = T (Int -> *(*World -> *World)) // Writing :: T = T (Int *World -> *World) won't work
 
 \subsection{Expressions}
 %:: T = T (Int -> *(*World -> *World)) // Writing :: T = T (Int *World -> *World) won't work
 
 \subsection{Expressions}
-Patterns in \gls{CLEAN} can be used as predicates as well~\citep[\citesection{3.4.3}]{plasmeijer_clean_2021}.
+Patterns in \gls{CLEAN} can be used as predicates as well \citep[\citesection{3.4.3}]{plasmeijer_clean_2021}.
 Using the \cleaninline{=:} operator, a value can be tested against a pattern.
 Variable names are not allowed but wildcard patterns \cleaninline{\_} are.
 
 Using the \cleaninline{=:} operator, a value can be tested against a pattern.
 Variable names are not allowed but wildcard patterns \cleaninline{\_} are.
 
@@ -84,7 +87,7 @@ ifAB x ifa ifb = if (x =: (A _)) ifa ifb
 
 Due to the nature of uniqueness typing, many functions in \gls{CLEAN} are state transition functions with possibly unique states.
 The \emph{let before} construct allows the programmer to specify sequential actions without having to invent unique names for the different versions of the state.
 
 Due to the nature of uniqueness typing, many functions in \gls{CLEAN} are state transition functions with possibly unique states.
 The \emph{let before} construct allows the programmer to specify sequential actions without having to invent unique names for the different versions of the state.
-\Cref{lst:let_before} shows an example of the usage of the \emph{let before} construct (adapted from~\citep[\citesection{3.5.4}]{plasmeijer_clean_2021}).
+\Cref{lst:let_before} shows an example of the usage of the \emph{let before} construct (adapted from \citep[\citesection{3.5.4}]{plasmeijer_clean_2021}).
 
 \begin{lstClean}[label={lst:let_before},caption={Let before expression example.}]
 readChars :: *File -> ([Char], *File)
 
 \begin{lstClean}[label={lst:let_before},caption={Let before expression example.}]
 readChars :: *File -> ([Char], *File)
@@ -96,8 +99,8 @@ readChars file
 \end{lstClean}
 
 \subsection{Generics}
 \end{lstClean}
 
 \subsection{Generics}
-Polytypic functions~\citep{jeuring_polytypic_1996}---also known as generic or kind-indexed fuctions---are built into \gls{CLEAN}~\citep[\citesection{7.1}]{plasmeijer_clean_2021}\citep{alimarine_generic_2005} whereas in \gls{HASKELL} they are implemented as a library~\citep[\citesection{6.19.1}]{ghc_team_ghc_2021}.
-The implementation of generics in \gls{CLEAN} is very similar to that of Generic H$\forall$skell~\citep{hinze_generic_2003}.
+Polytypic functions \citep{jeuring_polytypic_1996}---also known as generic or kind-indexed fuctions---are built into \gls{CLEAN} \citep[\citesection{7.1}]{plasmeijer_clean_2021}\citep{alimarine_generic_2005} whereas in \gls{HASKELL} they are implemented as a library \citep[\citesection{6.19.1}]{ghc_team_ghc_2021}.
+The implementation of generics in \gls{CLEAN} is very similar to that of Generic H$\forall$skell \citep{hinze_generic_2003}.
 %When calling a generic function, the kind must always be specified and depending on the kind, the function may require more arguments.
 
 For example, defining a generic equality is done as in \cref{lst:generic_eq}.
 %When calling a generic function, the kind must always be specified and depending on the kind, the function may require more arguments.
 
 For example, defining a generic equality is done as in \cref{lst:generic_eq}.
@@ -107,8 +110,8 @@ Metadata about the types is available using the \cleaninline{of} syntax that giv
 \cleaninputlisting[language=Clean,firstline=4,label={lst:generic_print},caption={Generic print function in \gls{CLEAN}.}]{lst/generic_print.icl}
 
 \subsection{\texorpdfstring{\glsentrytext{GADT}}{GADT}s}
 \cleaninputlisting[language=Clean,firstline=4,label={lst:generic_print},caption={Generic print function in \gls{CLEAN}.}]{lst/generic_print.icl}
 
 \subsection{\texorpdfstring{\glsentrytext{GADT}}{GADT}s}
-\Glspl{GADT} are enriched data types that allow the type instantiation of the constructor to be explicitly defined~\citep{cheney_first-class_2003,hinze_fun_2003}.
-While \glspl{GADT} are not natively supported in \gls{CLEAN}, they can be simulated using embedding-projection pairs or equivalence types~\citep[\citesection{2.2}]{cheney_lightweight_2002}.
+\Glspl{GADT} are enriched data types that allow the type instantiation of the constructor to be explicitly defined \citep{cheney_first-class_2003,hinze_fun_2003}.
+While \glspl{GADT} are not natively supported in \gls{CLEAN}, they can be simulated using embedding-projection pairs or equivalence types \citep[\citesection{2.2}]{cheney_lightweight_2002}.
 To illustrate this, \cref{lst:gadt_clean} shows an example \gls{GADT} that would be implemented in \gls{HASKELL} as done in \cref{lst:gadt_haskell}\requiresGHCmod{GADTs}.
 
 \cleaninputlisting[firstline=4,lastline=24,label={lst:gadt_clean},caption={Expression \gls{GADT} using equivalence types.}]{lst/expr_gadt.icl}
 To illustrate this, \cref{lst:gadt_clean} shows an example \gls{GADT} that would be implemented in \gls{HASKELL} as done in \cref{lst:gadt_haskell}\requiresGHCmod{GADTs}.
 
 \cleaninputlisting[firstline=4,lastline=24,label={lst:gadt_clean},caption={Expression \gls{GADT} using equivalence types.}]{lst/expr_gadt.icl}