\documentclass[10pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage{listings} \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small}}{} \author{Alexander Schaap} \title{Word} \begin{document} \maketitle Word must be printable, be sortable so that lines containing these words may be sorted, and represent part of the input. It is assumed that the input consists of printable characters, and that a default String is sufficient to represent possible inputs. Words require something like storage to group them into lines consisting of multiple words in a specified (and variable) order. The change anticipated or secret here is the way individual words are stored - what a word ultimately really is. Parnas' smallest unit was a character. This would primarily add complexity and perhaps expose more internals that we prefer to hide. \begin{code} {-#LANGUAGE TypeSynonymInstances, FlexibleInstances #-} module Word where type WordString = String class Word w where create :: String -> w compareTo :: (Ord w) => w -> w -> Ordering toString :: w -> String instance Word WordString where create s = s :: WordString compareTo w1 w2 | w1 < w2 = LT | w1 > w2 = GT | otherwise = EQ toString w = w :: String \end{code} \end{document}