% Copyright 2013 Frederic Bour, all rights reserved
\documentclass{beamer}

\usepackage[french]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{default}
\usepackage{tikz}

\newcommand{\sectitle}{\frametitle{\insertsection}}

\title{Merlin, an OCaml assistant}
\author{Frédéric \bsc{Bour}}
\date{May 21, 2013}

\usetheme{Warsaw}

\AtBeginSection[] {
  \begin{frame}[plain]
    \frametitle{Plan}
    \tableofcontents[currentsection]
  \end{frame}
  \addtocounter{framenumber}{-1}
}

\newcommand{\Simley}[1]{%
\begin{tikzpicture}[scale=0.11]
    \newcommand*{\SmileyRadius}{1.0}%
    \draw [fill=brown!10] (0,0) circle (\SmileyRadius)% outside circle
        %node [yshift=-0.22*\SmileyRadius cm] {\tiny #1}% uncomment this to see the smile factor
        ;  

    \pgfmathsetmacro{\eyeX}{0.5*\SmileyRadius*cos(30)}
    \pgfmathsetmacro{\eyeY}{0.5*\SmileyRadius*sin(30)}
    \draw [fill=cyan,draw=none] (\eyeX,\eyeY) circle (0.15cm);
    \draw [fill=cyan,draw=none] (-\eyeX,\eyeY) circle (0.15cm);

    \pgfmathsetmacro{\xScale}{2*\eyeX/180}
    \pgfmathsetmacro{\yScale}{1.0*\eyeY}
    \draw[color=red, domain=-\eyeX:\eyeX]   
        plot ({\x},{
            -0.1+#1*0.15 % shift the smiley as smile decreases
            -#1*1.75*\yScale*(sin((\x+\eyeX)/\xScale))-\eyeY});
\end{tikzpicture}%
}%
\newcommand{\smiley}{\Simley{0.5}}

\begin{document}

\begin{frame}
  \titlepage
\end{frame}

% \begin{frame}{Table des matières}
%   \tableofcontents
% \end{frame}

\section{An assistant in your editor}

\subsection{The usual toplevel}

\begin{frame}
  \sectitle

  The toplevel as a tool to interact with OCaml during edition.

  \pause

  \begin{itemize}
    \item Side-effects when evaluating phrases
      \pause
    \item Phrases evaluated in arbitrary order
      \pause \\
      (name shadowing, arbitrary scoping...)
  \end{itemize}
\end{frame}

\subsection{Merlin}

\begin{frame}
  \sectitle

  Merlin improves on this situation.
  \pause

  \begin{itemize}
    \item Checks syntax and typing, but doesn't evaluate.
      \pause
    \item Works incrementally, in document order
      (if you know Coq, think of ``Proof-General for OCaml'').
      \pause
    \item Resilient to syntax and typing errors (experimental).
  \end{itemize}
\end{frame}

\section{In practice}

\subsection{Upsides}

\begin{frame}
  \frametitle{Upsides}

  \begin{block}{Typing information}
    \begin{itemize}
      \item completion at point, sensitive to the current typing environment
        \pause
      \item type of (sub)expressions at point
        \pause
      \item foundations are there for all kind of type-directed
        feedback and analyses
        \pause
    \end{itemize}
  \end{block}

  \begin{block}{Instant feedback}
    \begin{itemize}
      \item Direct error feedback in the editor
        \pause
      \item can be a distraction \smiley
        \pause
    \end{itemize}
  \end{block}

  No surprise: the scoping, typing rules are exactly those of the
  compiler.
\end{frame}

\subsection{(Current) Limitations}

\begin{frame}
  \frametitle{(Current) Limitations}
  \begin{block}{Syntax extensions}
    \begin{itemize}
      \item No support for camlp4 planned
        \pause
      \item but we hard-code quotations and specific extensions \\
        (\texttt{lwt}, \texttt{type-conv}, ...)
        \pause
    \end{itemize}
  \end{block}

  \begin{block}{Hard language constructs}
    \begin{itemize}
      \item recursive definitions
        \pause
      \item first-class modules, OOP, etc.
        \pause
      \item[$\Rightarrow$] hard to provide feedback on those when code
        is not valid
    \end{itemize}
  \end{block}
\end{frame}

\subsection{Features}

\begin{frame}
  \sectitle

  From both Vim and Emacs :

  \begin{itemize}
    \item identifier completion,
    \item type feedback,
    \item integrated error messages,
    \item \texttt{ocamlfind} integration \\
      {\small {\tt .merlin} file for projects},
    \item a few syntax extensions.
  \end{itemize}

\end{frame}

\subsection{The future}

\begin{frame}
  \frametitle{The future}

  Short- to long-term.

  \begin{itemize}
    \item work on handling of syntax errors
      \pause
    \item coordination with other tools (\texttt{spotter}, \texttt{ocamldoc}),
      \pause
    \item more extensions. \\
      {\small \texttt{js\_of\_ocaml} in experimental branch}
  \end{itemize}

\end{frame}

\section*{Demo}

\begin{frame}
 \sectitle
 
 Thanks for your attention.

 \vfill

 For more information : {\tt http://github.com/def-lkb/merlin} 

 \vfill

 And now for a small demo...
 
\end{frame}

\end{document}
