\documentclass[10pt,letterpaper]{article} \usepackage[utf8]{inputenc} \usepackage{listings} \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small}}{} \author{Alexander Schaap} \title{Output Module} \begin{document} \maketitle Output needs to pretty-print sorted shifts. It will need to 'connect' to a storage with shifts in a certain order. Incrementality is probably an issue - this module could output whatever is in the storage and do so again when that changes, but this might not be desirable. The data will pass through this module since it will need to be changed and put onto the output medium. The secret here is the way the storage is pretty-printed. \begin{code} {-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances #-} module Output where import LineStorage import Word import qualified Data.IntMap as IntMap class Output s t r where print_ :: (Word e) => (s (t (r e))) -> IO () showLS (ListStorage e) = map toString e s2 (ListStorage s) = unlines $ map unwords $ map showLS s instance Output StorageList StorageList StorageList where print_ (ListStorage s) = print $ unlines $ map s2 s instance Output StorageMap StorageMap StorageMap where print_ m = print $ unlines $ IntMap.elems $ IntMap.map (unlines . IntMap.elems . IntMap.map (unwords . IntMap.elems . IntMap.map toString)) m \end{code} \end{document}