}{
}
-\myappendix{chp:clean_for_haskell_programmers}{\texorpdfstring{\glsentrytext{CLEAN}}{Clean} for \texorpdfstring{\glsentrytext{HASKELL}}{Haskell} Programmers}%
+\chapter{\texorpdfstring{\glsentrytext{CLEAN}}{Clean} for \texorpdfstring{\glsentrytext{HASKELL}}{Haskell} Programmers}%
+\label{chp:clean_for_haskell_programmers}
This note is meant to give people who are familiar with the functional programming language \gls{HASKELL} a consise overview of \gls{CLEAN} language elements and how they differ from \gls{HASKELL}.
The goal is to support the reader when reading \gls{CLEAN} code.
%:: 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~\cite[Chp.~3.4.3]{plasmeijer_clean_2021}.
+Patterns in \gls{CLEAN} can be used as predicates as well~\citep[Chp.~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.
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~\cite[Chp.~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[Chp.~3.5.4]{plasmeijer_clean_2021}).
\begin{lstClean}[label={lst:let_before},caption={Let before expression example.}]
readChars :: *File -> ([Char], *File)
\end{lstClean}
\subsection{Generics}
-Polytypic functions~\citep{jeuring_polytypic_1996}---also known as generic or kind-indexed fuctions---are built into \gls{CLEAN}~\cite[Chp.~7.1]{plasmeijer_clean_2021}\citep{alimarine_generic_2005} whereas in \gls{HASKELL} they are implemented as a library~\cite[Chp.~6.19.1]{ghc_team_ghc_2021}.
+Polytypic functions~\citep{jeuring_polytypic_1996}---also known as generic or kind-indexed fuctions---are built into \gls{CLEAN}~\citep[Chp.~7.1]{plasmeijer_clean_2021}\citep{alimarine_generic_2005} whereas in \gls{HASKELL} they are implemented as a library~\citep[Chp.~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.
\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~\cite[Sec.~2.2]{cheney_lightweight_2002}.
+While \glspl{GADT} are not natively supported in \gls{CLEAN}, they can be simulated using embedding-projection pairs or equivalence types~\citep[Sec.~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}.
-\lstinputlisting[language=Clean,firstline=4,label={lst:gadt_clean},caption={Expression \gls{GADT} using equivalence types in \gls{CLEAN}.}]{lst/expr_gadt.icl}
-\lstinputlisting[language=Haskell,style=haskell,firstline=4,label={lst:gadt_haskell},caption={Expression \gls{GADT} in \gls{HASKELL}.}]{lst/expr_gadt.hs}
+\lstinputlisting[language=Clean,firstline=4,lastline=24,label={lst:gadt_clean},caption={Expression \gls{GADT} using equivalence types in \gls{CLEAN}.}]{lst/expr_gadt.icl}
+\lstinputlisting[language={[Regular]Haskell},firstline=4,label={lst:gadt_haskell},caption={Expression \gls{GADT} in \gls{HASKELL}.}]{lst/expr_gadt.hs}
+\clearpage
\section{Syntax}
\begin{longtable}{p{.45\linewidth}p{.5\linewidth}}
\caption[]{Syntactical differences between \gls{CLEAN} and \gls{HASKELL}.}%
\cleaninline{:: R = \{ f :: t \}} & \haskellinline{data R = R \{ f :: t \}}\\
\cleaninline{r = \{ f = e \}} & \haskellinline{r = R \{e\}}\\
\cleaninline{r.f} & \haskellinline{f r}\\
+ & \haskellinline{r.f}\requiresGHCmod{Requires \gls{GHC} version 9.2.0 or higher}{OverloadedRecordDot}\\
\cleaninline{r!f}\footnote{This operator allows for field selection from unique records.} & \haskellinline{(\\v->(f v, v)) r}\\
\cleaninline{\{r \& f = e \}} & \haskellinline{r \{ f = e \}}\\
\cleaninline{a = \{e \\\\ p <-: a\}} & \haskellinline{a = array (0, length a-1)}\\
& \quad\haskellinline{[e \| (i, a) <- [0..] `zip` a]}\\
\cleaninline{a.[i]} & \haskellinline{a!i}\\
- \cleaninline{a![i]}\footnote{This operator allows for field selection from unique arrays.} & \haskellinline{(\v->(v!i, v)) a}\\
+ \cleaninline{a![i]}\footnote{This operator allows for field selection from unique arrays.} & \haskellinline{(\\v->(v!i, v)) a}\\
\cleaninline{\{ a \& [i] = e\}} & \haskellinline{a//[(i, e)]}\\
\midrule