\documentclass[a4paper,answers]{exam}

%% handle Unicode support nicely, with lots of chars and auto font selection. Use ALWAYS :)
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage{autofe}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{hyperref}


%% imports, colors and other definitions for source code
\usepackage{listingsutf8}

\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{
    language=Haskell,
    extendedchars=\true,
    basicstyle=\footnotesize,
    numbers=left,
    numberstyle=\tiny\color{gray},
    stepnumber=1,
    numbersep=5pt,
    backgroundcolor=\color{white},
    showspaces=false,
    showtabs=false,
    tabsize=4,
    captionpos=b,
    breakatwhitespace=false,
    title=\lstname,
    keywordstyle=\color{blue},
    commentstyle=\color{dkgreen},
    stringstyle=\color{mauve},
    morekeywords={*,...}
}



\pagestyle{head}
\firstpageheader{}
    {\bf\large Exercises about the paper ``Generic Views on Data Types''\\
    \bf\small November 1\textsuperscript{st}, 2012}{}

%% The document itself
\begin{document}
    \begin{questions}

        \question[1]
        The main concept discussed in the paper ``Generic Views on Data Types'' is that of a \emph{generic
        view} (the paper has a very descriptive title, after all). What is then the \emph{informal} (using
        natural language) definition of a generic view? More specifically:

        \begin{parts}
            \part[0.5]
            What are the three components of a generic view?

            \part[0.5]
            What are the conditions that a generic view must satisfy in order to be said \emph{valid}? \\
            \emph{Tip: There are three conditions, one applies to one component of the definition and the
            other two condition apply to another component.}

        \end{parts}

        \begin{solution}
            \begin{parts}
                \part
                \begin{subparts}
                    \subpart
                    A set of datatypes, called ``view types'', ``representation types''
                    or ``structure types''.

                    \subpart
                    A mapping between the universe of user-defined datatypes and the view types.

                    \subpart
                    For each user-defined datatype, a pair of functions (to and from) witnessing the
                    isomorphism between the user-defined datatype and the corresponding view type.
                \end{subparts}

                \part
                \begin{subparts}
                    \subpart
                    The mapping from user-defined datatypes to view types needs to be \emph{kind-preserving}

                    \subpart
                    The conversion (isomorphism-witnessing) functions need to be well-typed

                    \subpart
                    The conversion (isomorphism-witnessing) functions need to be well-behaved, i.e, inverses
                    of each other
                \end{subparts}
            \end{parts}
        \end{solution}

    \end{questions}
\end{document}


