\input{haskpres.cfg} \documentstyle{fppres} \title{CCSC Haskell tutorial} \begin{document} \begin{presentation} {CCSC Haskell tutorial} {Fritz Ruehr}{1}{6 October 2001}{} \begin{slide}{Short Haskell applications: text, numbers, treesort and DFAs} \slideitem{Simple text processing} \begin{itemize} \item higher-order list functions and a few simple utilities can be combined to do \xlink{../code/short.html#textproc}{simple text processing} \end{itemize} \slideitem{ROT-13 transcoder} \begin{itemize} \item similar techniques allow us to define a basic \xlink{../code/short.html#rot13}{"ROT-13" text encryption utility} in about 5 lines \end{itemize} \slideitem{Command-line interaction} \begin{itemize} \item Haskell's pre-defined interaction process is based on whole inputs, but a few intervening functions allow us to easily define a \xlink{../code/short.html#rot13}{line-by-line user interaction program} \end{itemize} \slideitem{Palindrome checking} \begin{itemize} \item we can check whether a string is a palindrome by normalizing it and comparing it to its own reversal: \xlink{../code/short.html#palcheck}{the palindrome checker} \end{itemize} \slideitem{Numeral conversion in different bases} \begin{itemize} \item by spotting certain symmetries in base-radix notation, we can easily write "generator functions" for arbitrary number bases which \xlink{../code/short.html#numbase}{convert between strings and integers} \end{itemize} \slideitem{Binary trees and treesort} \begin{itemize} \item a data type for binary search trees, plus an appropriate fold function over those trees, makes \xlink{../code/short.html#treesort}{the definition of tree sort clear and compelling} \end{itemize} \slideitem{DFA simulation} \begin{itemize} \item we can transcribe a definition of \xlink{../code/short.html#treesort}{deterministic finite automata} almost verbatim from a theory text, and then experiment with automata and strings \end{itemize} \end{slide} \begin{slide}{Medium-sized application: generic sorting and a database} \slideitem{Simple insertion and quicksorts} \begin{itemize} \item standard sorting algorithms such as insertion sort or quicksort can be written in a few lines; \xlink{../code/gensort.html#sorts}{some trade-offs between abstraction and readability are demonstrated here for quicksort} \end{itemize} \slideitem{Generalizing to an arbitrary order relation} \begin{itemize} \item using higher-order functions we can easily \xlink{../code/gensort.html#absorder}{generalize our quicksort to work for arbitrary ordering relations} \end{itemize} \slideitem{Sorting on extracted "fields"} \begin{itemize} \item now, given some more structured data, we can \xlink{../code/gensort.html#fields}{succinctly express sorts by different criteria} \end{itemize} \slideitem{Simultaneous sorting} \begin{itemize} \item we can even extend our sorting function to use two relations on the same data, thus providing \xlink{../code/gensort.html#fields}{independent simultaneous sorts} \end{itemize} \slideitem{A simple academic course database} \begin{itemize} \item a type definition and a few utility functions provide us with \xlink{../code/gensort.html#courses}{a simple database of academic courses} \end{itemize} \slideitem{Derived lexicographic orderings} \begin{itemize} \item a little bit of logical manipulation allows us to extend any pair (or list) of ordering relations to \xlink{../code/gensort.html#lexi}{provide a lexicographic sort} \end{itemize} \end{slide} \begin{slide}{Medium-sized application: arithmetic expression processor} \slideitem{An arithmetic expression parser and processor} This example shows how a simple parser and evaluator can be defined for maximum flexibility using polymorphic types and higher-order functions. \slideitem{Token type and scanner} \begin{itemize} \item \xlink{../code/expr.html#scan}{a simple type of alternatives and a short recursive function} suffice to transform strings into lists of tokens \end{itemize} \slideitem{Tree type and parser (from concrete to abstract)} \begin{itemize} \item our parser is \xlink{../code/expr.html#parse}{parameterized with respect to functions} which might be semantic actions or just tree constructors \end{itemize} \slideitem{Operator semantics ("back-end")} \begin{itemize} \item \xlink{../code/expr.html#oper}{a simple database of operators and their meanings} takes advantage of Haskell's ability to store functions in lists \end{itemize} \slideitem{Evaluation (and deforestation with folds)} \begin{itemize} \item \xlink{../code/expr.html#tree}{a data type of abstract syntax trees} allows us to hold onto parse data ... but we can also choose to apply semantic actions immediately in order to evaluate an expression \end{itemize} \slideitem{Formatting/pretty-printing (in various forms)} \begin{itemize} \item expressions "frozen" in trees can be \xlink{../code/expr.html#print}{printed in different formats} just by varying a "fixity" parameter \end{itemize} \slideitem{Variations on multi-parsing (pair of parsers, parser of pairs)} \begin{itemize} \item we can simultaneously parse and evaluate by using \xlink{../code/expr.html#pair}{a pair of parsers or a parser on pairs} \end{itemize} \slideitem{Traced calculations} \begin{itemize} \item we can even extend our notion of output to include \xlink{../code/expr.html#trace}{a complete calculation history, annotated with intermediate terms} \end{itemize} \slideitem{Interactivity (at outer entry level)} \begin{itemize} \item all of these operations (evaluation, formatting, tracing) can be accommodated in \xlink{../code/expr.html#interact}{a single, generic command-line interface} \end{itemize} \end{slide} \begin{slide}{An overview of larger-scale projects} \slideitem{The Haskore music system (and other DSLs)} Paul Hudak at Yale has defined a powerful language for describing musical structures in abstract terms based on Haskell (see the \xlink{http://haskell.org/haskore/}{Haskore Project} website) \par In general, Haskell's abstraction features make it ideal for defining {\bf domain-specific languages} as Haskell libraries \slideitem{The Fran and Pan graphics projects} Conal Elliot at Microsoft Research has developed a couple of libraries, {\bf Fran} and {\bf Pan}, which allow a very high-level way to specify \xlink{../pics/}{complex graphics, animations and interactive animations} \par In Fran, for example, an interactive, single-player "Pong" game can be written in less than 20 lines, using concepts such as integration to express the relationship between velocity and position \slideitem{GUI projects} A number of graphical user interface libraries are listed on the Haskell home page, ranging from low-level interfaces to traditional C libraries, to high-level, purely-functional characterizations \par (see the \xlink{http://haskell.org/libraries/#guigs}{GUI library section of the Haskell homepage} for more details \slideitem{The Galois Connections ray-tracer} Every year the {\it International Conference on Functional Programming} holds a 72-hour "challenge problem" contest; last year's problem involved writing a 3-D ray-tracer which compiles a scene-description language into rendered output \par a local team from Galois Connections managed to achieve 2nd-place standing for their entry \end{slide} \begin{slide}{Haskell's place in Computer Science and CS education} \slideitem{Haskell at Willamette} All of Willamette's courses are taught in Java, with the exception of the FP course, which uses Haskell \slideitem{Haskell as a fresh perspective} Because of its non-standard model of computation and its powerful abstraction features, Haskell can serve to positively influence student's design skills, even in other languages \slideitem{Haskell for Discrete Mathematics} Rex Page has an \xlink{}{NSF project at U Oklahoma called Beseme} which seeks to provide runnable implementations on traditional discrete math topics \par Rex uses \xlink{http://www.amazon.com/exec/obidos/ASIN/1852330899/qid=1002009396/sr=1-1/ref=sr_1_4_1/102-7018854-4544137}{Hall and O'Donnel's "Discrete Mathematics Using a Computer"} as a textbook \slideitem{Haskell as "programming for mathematicians"} to turn the tables a bit, Haskell's mathematical flavor and high-level approach make it ideal for use as a first language for math students \end{slide}\nl \end{presentation} \end{document}