X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=appx%2Fclean_for_haskell_programmers.tex;h=aeba2dcb03b455d28007a137f8b4e4a620dccd4a;hb=c45698c752780ef2bf45ae9f8085585e9eee1d18;hp=ff24c0e049220c45db133dcfbb20f6168a8b2f4f;hpb=0c4686b70dcb071a6537cdb52beb6bf4183334a1;p=phd-thesis.git diff --git a/appx/clean_for_haskell_programmers.tex b/appx/clean_for_haskell_programmers.tex index ff24c0e..aeba2dc 100644 --- a/appx/clean_for_haskell_programmers.tex +++ b/appx/clean_for_haskell_programmers.tex @@ -100,18 +100,18 @@ The implementation of generics in \gls{CLEAN} is very similar to that of Generic %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}. -\lstinputlisting[language=Clean,firstline=4,label={lst:generic_eq},caption={Generic equality function in \gls{CLEAN}.}.]{lst/generic_eq.icl} +\cleaninputlisting[firstline=4,label={lst:generic_eq},caption={Generic equality function in \gls{CLEAN}.}.]{lst/generic_eq.icl} Metadata about the types is available using the \cleaninline{of} syntax that gives the function access to metadata records, as can be seen in \cref{lst:generic_print} showing a generic print function. This abundance of metadata allows for very complex generic functions that near the expression level of template metaprogramming\ifSubfilesClassLoaded{}{ (See \cref{chp:first-class_datatypes})}. -\lstinputlisting[language=Clean,firstline=4,label={lst:generic_print},caption={Generic print function in \gls{CLEAN}.}]{lst/generic_print.icl} +\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}. 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,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} +\cleaninputlisting[firstline=4,lastline=24,label={lst:gadt_clean},caption={Expression \gls{GADT} using equivalence types.}]{lst/expr_gadt.icl} +\haskellinputlisting[firstline=4,label={lst:gadt_haskell},caption={Expression \gls{GADT}.}]{lst/expr_gadt.hs} \clearpage \section{Syntax}