\documentclass[preprint]{sigplanconf}
\usepackage{version}
\usepackage[pdftex]{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts,amssymb}
\usepackage{style/utils}
\usepackage{style/code}
\usepackage{style/names}

% -- Utils ----------------------------------------------------------------------------------------
\newcommand{\TODO}[1]	{\emph{\textbf{TODO:} #1}}
\newcommand{\CITE}	{\textbf{CITE} }
\newcommand{\REF}	{\textbf{REF }}

% -------------------------------------------------------------------------------------------------
\begin{document}
\preprintfooter{\textbf{--- DRAFT --- DRAFT --- DRAFT --- DRAFT ---}}

\title	{Head Lazy but Shapely, and Deeply Mutable}
\authorinfo
	{Ben Lippmeier}
	{School of Computer Science and Engineering \\
	 University of New South Wales, Australia}
	{\texttt{benl@ouroborus.net}}
\maketitle

\makeatactive

\begin{abstract}
We discuss the utility of applying Haskell-style type class constraints to region, effect and closure types in our own language, Disciple. We use mutability and constancy constraints on region types to encode mutability polymorphism; purity constraints on effects to introduce laziness in a safe way, and emptiness constraints on closure types to enforce that functions do not share data with their environment. Besides these new constraints, we also support traditional Haskell-style ad-hoc overloading using (value) type classes. An important aspect of this is the introduction of the Shape constraint, that requires the value portion of a type to match another, but allows the region, effect and closure information to differ. \TODO{closing sentence}

\end{abstract}
\input{section/1-Introduction}
\input{section/2-Regions}
\input{section/3-EffectClosure}
\input{section/4-DeepMutable}
\input{section/5-Shape}
\input{section/6-Material}


\clearpage{}
% -------------------------------------------------------------------------------------------------
\section{Laziness and Purity}
$$
	suspend :: \forall a~ b~ e.~ Pure~ e \To (a \toa{e} b) \to a \to b
$$



% -------------------------------------------------------------------------------------------------
\subsection{Lazy and Direct}


\clearpage{}
% -------------------------------------------------------------------------------------------------
\section{Future Work}

\subsection{Emptiness}
\begin{itemize}
\item	For doing fast RPC in the presence of partial application.
\item	Use a spawn function that requires the closure to be empty
\end{itemize}

\begin{code}
spawn :: forall a b c
      .  ( Serialisable a, Serialisable b
         , Pure e, Empty c) 
      => (a -(e c)> b) -> a -> b
\end{code}

Emptiness of closures. For doing RPC in the presence of curried functions. Say what fns needed to build a user-space RPC mechanism. Compare with GUM that had to walk over the graph of the program.


\subsection{Disjoint Effects}
\begin{itemize}
\item	To run two functions in parallel, it's ok if they have effects so long
	as those effects do not interfere.
\end{itemize}

\begin{code}
  fork :: forall a b e1 e2. NonInterfering e1 e2
       => (a -(e1)> b) -> (a -(e2)> b) -> a -(e3)> b
       :- e3 = e1 + e2

  Disjoint 0  e1
  Disjoint e1 0

  Distinct r1 r2 => Disjoint (Read  r1) (Read  r2)
  Distinct r1 r2 => Disjoint (Read  r1) (Write r2)
  Distinct r1 r2 => Disjoint (Write r1) (Read  r2)
  Distinct r1 r2 => Disjoint (Write r1) (Write r2)
 \end{code}


% -------------------------------------------------------------------------------------------------
\section{Related Work}

\begin{flushleft}
Mention Gifford and Lucassen when we first introduce effects. Mention that we use @:>@ constraints so we can instantiate the function at a larger type. 

{\bf Laura Korte}

{\bf Type Qualifiers}

{\bf Phantom Types and GADTs}

{\bf Daan Leijen's language}

{\bf Benton, Kennedy, Tolmach}

{\bf Deterministic Parallel Java}

{\bf Cyclone}

{\bf BitC}
\end{flushleft}

% -------------------------------------------------------------------------------------------------
\paragraph{Acknowledgements}
\bibliographystyle{abbrvnat}
\bibliography{Main}

\end{document}