From 9da3745a02e1760c1360a3e5d64090ab68374d99 Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Fri, 27 Oct 2017 19:31:03 +0200
Subject: First rough version of full presentation

---
 cloogle.tex | 412 +++++++++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 298 insertions(+), 114 deletions(-)

(limited to 'cloogle.tex')

diff --git a/cloogle.tex b/cloogle.tex
index 7d5023d..a45822c 100644
--- a/cloogle.tex
+++ b/cloogle.tex
@@ -1,161 +1,345 @@
 \documentclass{beamer}
 
+\let\oldhref\href
+\def\href#1#2{\oldhref{#1}{\color{cloogledark!50!clooglemain} #2}}
+\def\https#1{\href{https://#1}{#1}}
+\def\mailto#1{\href{mailto:#1}{#1}}
+
 \title{Cloogle}
 \subtitle{A programming language search engine and its applications}
-\author{Camil Staps}
+\author[Camil Staps]{\texorpdfstring{Camil Staps\\[1em]\footnotesize\mailto{camil@cloogle.org}}{Camil Staps}}
 \date{January 5\textsuperscript{th}, 2018}
 
-\usetheme{Szeged}
+\usetheme{CambridgeUS}
 \usecolortheme{cloogle}
+\useinnertheme{circles}
+\setbeamertemplate{itemize item}[triangle]
+\setbeamertemplate{itemize subitem}[circle]
 
 \usepackage[british]{babel}
 \usepackage{csquotes}
 
 \usepackage{tikz}
-\usetikzlibrary{calc,positioning}
-\newcommand{\module}[2]{#2\\[-4pt]\color{gray}{\tiny(#1)}}
-\tikzstyle{block}=[rectangle,align=center]
-\tikzset{
-	doc/.pic={
-		\coordinate (-east)  at (0.309,0);
-		\coordinate (-south) at (0,-0.4);
-		\draw[pic actions] (-0.309,-0.4) -- ++(0,0.8) -- ++(0.518,0) -- ++(0,-0.1) -- ++(0.1,0) -- ++(0,-0.7) -- cycle;
-		\draw[pic actions] (0.209,0.4) -- ++(0.1,-0.1);
-		\draw[pic actions] (-0.209,-0.1) -- ++(0.418,0);
-		\draw[pic actions] (-0.209, 0)   -- ++(0.418,0);
-		\draw[pic actions] (-0.209, 0.1) -- ++(0.418,0);
-	},
-	db/.pic={
-		% https://tex.stackexchange.com/a/397862/23992
-		\coordinate (-west)  at (-0.3,0);
-		\coordinate (-east)  at ( 0.3,0);
-		\coordinate (-south) at (0,-0.42);
-		\foreach \y in {-0.33,-0.1,0.13} {
-			\draw[fill=white] (-0.3,\y) to [looseness=0.5,bend right=90] ++(0.6,0)
-				-- ++(0,0.2) to [looseness=0.5,bend left=90] ++(-0.6,0)
-				-- ++(0,-0.2);
-			\draw (-0.3,\y+0.2) edge[looseness=0.5,bend left=90] ++(0.6,0);
-		}
-	}
-}
+\usepackage{clooglearch}
 
 \usepackage{minted}
 \setminted{fontsize=\small}
 
+% https://tex.stackexchange.com/a/23522/23992
+\def\imagetop#1{\vtop{\null\hbox{#1}}}
+
 \begin{document}
 
 \maketitle
 
 \section{Background}
+\subsection{Why build a search engine?}
 \begin{frame}[fragile]{Background}
-	 What is wrong with this code?
-
-	\begin{minted}[gobble=2]{clean}
-		incAll :: [Int] -> [Int]
-		incAll []     = []
-		incAll [x:xs] = [x+1:incAll xs]
+	\begin{itemize}[<+->]
+		\item
+			What is wrong with this code?
 
-		sortByKey :: [(a,b)] -> [(a,b)] | < a
-		sortByKey []         = []
-		sortByKey [(k,v):xs] = sortByKey ls ++ [(k,v):sortByKey hs]
-		where (ls,hs) = partition (\(k`,_) -> k > k`) xs
-	\end{minted}
+			\begin{minted}[gobble=4]{clean}
+				incAll :: [Int] -> [Int]
+				incAll []     = []
+				incAll [x:xs] = [x+1:incAll xs]
+			\end{minted}
 
-	\pause
-	Better:
-	\begin{minted}[gobble=2]{clean}
-		incAll    :== map ((+) 1)
-		sortByKey :== sortBy (on (<) fst)
-	\end{minted}
+		\item
+			Better:
+			\begin{minted}[gobble=4]{clean}
+				incAll = map ((+) 1)
+			\end{minted}
+	\end{itemize}
 \end{frame}
 \begin{frame}{Background}
 	Lack of abstraction due to...
 
 	\begin{itemize}
 		\item Poor conceptualisation of the programmer?
+		\pause
 		\item Poor knowledge of the standard libraries?
-			\begin{itemize}
-				\item \enquote{There is this function \texttt{map}, but where is it defined?}
-			\end{itemize}
+
+			\medskip
+			\quad\enquote{There is this function \texttt{map}, but where is it defined?}
 	\end{itemize}
 
+	\pause
 	Solution: build a search engine!
 \end{frame}
-\begin{frame}{History}
-	\begin{itemize}
-		\item February 2016: PHP regex search
-		\pause
-		\item April: function type search; moved to Clean
-		\pause
-		\item June: type definition search; included classes and generics
-		\pause
-		\item August: included macros
-		\pause
-		\item October: moved to Docker containers; caching
-		\pause
-		\item November: unify with type synonyms
-	\end{itemize}
+
+\subsection{Functionality}
+\begin{frame}{Functionality}
+	\centering
+	\begin{tabular}{l l}
+		\imagetop{\includegraphics[width=.45\textwidth]{scrot-search-name}} & \pause
+		\imagetop{\includegraphics[width=.45\textwidth]{scrot-search-unify}} \pause\\
+		\imagetop{\includegraphics[width=.45\textwidth]{scrot-search-typedef}} \pause&
+		\imagetop{\includegraphics[width=.45\textwidth]{scrot-search-class}}
+	\end{tabular}
 \end{frame}
+
+\subsection{Architecture}
 \begin{frame}{Architecture}
 	\centering
 	\footnotesize
-	\def\tikzsource{%
-		\pic (src)  at (-5,3) {doc};
-	}
-	\def\tikzbuilddb{%
-		\node (cocl) at (-2.5, 3.5 ) {\module{Clean}{Clean compiler}};
-		\node (ppr)  at (-2.5, 2.5 ) {\module{Clean}{Pretty printer}};
-		\pic  (db)   at ( 0,   2.98) {db};
-		\node[right=5pt of db-east,draw=none] {\module{\tiny JSON}{\scriptsize Database}};
-		\draw[->] ($(src-east)+(0,0.18)$) -- (cocl.west);
-		\draw[->] ($(src-east)-(0,0.18)$) -- (ppr.west);
-		\draw[->] (cocl.east) -- ($(db-west)+(0,0.18)$);
-		\draw[->] (ppr.east)  -- ($(db-west)-(0,0.18)$);
-	}
-	\def\tikzbackend{%
-		\node (web) at (0, 1) {\module{Clean, PHP, JS}{\textbf{cloogle.org}}};
-		\node (uni) at (2, 2) {\module{Clean}{Type unifier}};
-		\draw (uni) -- (web);
-		\draw[->] (db-south) -- (web);
-	}
-	\def\tikzfrontend{%
-		\node (hljs) at (-2,    0.5) {\module{JS}{clean.js}};
-		\draw (hljs) -- (web);
-	}
-	\def\tikzfrontendsrc{%
-		\node (pygm) at (-2.25, 1.5) {\module{Python}{pygments}};
-		\draw[->] (src-south) -- (pygm);
-		\draw (pygm) -- (web);
-	}
-	\def\tikzstats{%
-		\node (stats) at (3, 1) {\module{Bash, JS, PHP, SQL}{Log \& Statistics}};
-		\draw (web) -- (stats);
-	}
-	\def\tikzclientA{%
-		\node (cli) at (-2,-2) {\module{Python}{CLI app}};
-		\draw[->] (web) -- (cli);
-	}
-	\def\tikzclientB{%
-		\node (tgm) at (0,-2) {\module{Python}{Telegram bot}}; % TODO more frontends?
-		\draw[->] (web) -- (tgm);
-	}
-	\def\tikzclientC{%
-		\node (vim) at (2,-2) {\module{Vim}{vim-clean}};
-		\draw[->] (web) -- (vim);
-	}
 	\begin{tikzpicture}[every node/.style={draw,block}]
-		\useasboundingbox (-5,-4) rectangle (5,4);
+		\useasboundingbox (-5,-4) rectangle (3.5,4);
 		\only<1->\tikzsource
-		\only<1-4>{\node[below=5pt of src-south,draw=none] {\scriptsize Source code};}
+		\only<1-5>{\node[below=5pt of src-south,draw=none] {\scriptsize Source code};}
 		\only<2->{\tikzbuilddb}
 		\only<3->{\tikzbackend}
-		\only<4->{\tikzfrontend}
-		\only<5->{\tikzfrontendsrc}
-		\only<6->{\tikzstats}
-		\only<7->{\tikzclientA}
-		\only<8->{\tikzclientB}
-		\only<9->{\tikzclientC}
+		\only<4->{\tikzcache}
+		\only<5->{\tikzfrontend}
+		\only<6->{\tikzfrontendsrc}
+		\only<7->{\tikzstats}
+		\only<8->{\tikzclientA}
+		\only<9->{\tikzclientB}
+		\only<10->{\tikzclientC}
+		\only<11->{\tikzclientD}
+		\only<12->{\tikzclientE}
 	\end{tikzpicture}
 \end{frame}
 
+\section{Recent developments}
+
+\subsection{Efficient unification search}
+\begin{frame}{Efficient unification search}
+	\begin{itemize}[<+->]
+		\item With $\pm15,000$ functions, brute force unification search takes too long
+		\item Grouping types together still gives $\pm13,000$ unique types
+		\item If type $t$ generalises $u$, any $v$ that unifies with $u$ will also unify with $t$
+		\item This gives a partial ordering on types:
+
+			\begin{center}
+				\begin{tikzpicture}[level distance=2em]
+					\tikzstyle{level 1}=[sibling distance=14em]
+					\tikzstyle{level 2}=[sibling distance=7em]
+					\tikzstyle{level 3}=[sibling distance=2em]
+					\node {$a$}
+						child {node {$a \rightarrow b$}
+							child {node {$Int \rightarrow Int$} child {node {\vdots}} child {node {\vdots}}}
+							child {node {$a~a \rightarrow a$} child {node {\vdots}}}}
+						child {node {$f~Real$}
+							child {node {$Maybe~Real$}}
+							child {node {$Either~a~Real$} child {node {\vdots}}}};
+				\end{tikzpicture}
+			\end{center}
+
+		\item Early pruning speeds up unification search with a factor of $2-3$!
+	\end{itemize}
+\end{frame}
+
+\subsection{Running locally: cloogle-tags}
+\begin{frame}[fragile]{What if we want to run Cloogle locally?}
+	\begin{itemize}
+		\item Most common use case: finding definitions in personal libraries
+		\pause
+		\item Many editors support \emph{tagfiles}:
+
+			\begin{minted}[gobble=4]{text}
+				drop    StdList.dcl    46
+				fopen   StdFile.dcl    27
+				...
+			\end{minted}
+	\end{itemize}
+\end{frame}
+\begin{frame}{Running locally: old architecture}
+	\centering
+	\footnotesize
+	\begin{tikzpicture}[every node/.style={draw,block}]
+		\useasboundingbox (-5,-4) rectangle (3.5,4);
+		\tikzsource
+		\tikzbuilddb
+		\tikzbackend
+		\tikzcache
+		\tikzfrontend
+		\tikzfrontendsrc
+		\tikzstats
+		\tikzclientA
+		\tikzclientB
+		\tikzclientC
+		\tikzclientD
+		\tikzclientE
+	\end{tikzpicture}
+\end{frame}
+\begin{frame}{Running locally: new architecture}
+	\centering
+	\footnotesize
+	\begin{tikzpicture}[every node/.style={draw,block}]
+		\useasboundingbox (-5,-4) rectangle (3.5,4);
+		\tikzsource
+		\tikzbuilddb
+		\only<1>{%
+			\tikzbackend[1]
+			\tikzcache[1]
+			\tikzfrontend[1]
+			\tikzfrontendsrc[1]
+			\tikzstats[1]
+			\tikzclientA
+			\tikzclientB
+			\tikzclientC
+			\tikzclientD
+			\tikzclientE}
+		\only<2->{%
+			\tikzbackend[2]
+			\tikzcache[2]
+			\tikzfrontend[2]
+			\tikzfrontendsrc[2]
+			\tikzstats[2]
+			\tikzclientB[2]
+			\tikzclientC[2]
+			\tikzclientD[2]
+			\tikzclientE[2]
+			\tikzcloogletags}
+		\only<2>{\tikzclientA[2]}
+		\only<3>{\tikzclientA[3]}
+		\only<4>{\tikzclientA[4]}
+	\end{tikzpicture}
+\end{frame}
+
+\section{The end}
+
+\subsection{Acknowledgements}
+\begin{frame}[shrink]{Acknowledgements}
+	Cloogle was conceived and built by:
+
+	\begin{itemize}
+		\item Camil Staps
+		\item Mart Lubbers
+	\end{itemize}
+
+	With contributions by:
+
+	\begin{itemize}
+		\item Erin van der Veen
+		\item Koen Dercksen
+	\end{itemize}
+
+	Using:
+
+	\begin{itemize}
+		\item The Clean compiler (the Clean team)
+	\end{itemize}
+
+	With thanks to:
+
+	\begin{itemize}
+		\item All users, for new ideas and bug reports (explicitly or in the query log)
+	\end{itemize}
+
+	Authors of clients:
+
+	\begin{itemize}
+		\item CLI app: Koen Dercksen
+		\item IRC bot: Mart Lubbers
+		\item vim-clean, Telegram bot, email client: Camil Staps
+		\item Visual Studio Code plugin: Lucas Franceschino
+	\end{itemize}
+\end{frame}
+
+\appendix
+\newcounter{finalframe}
+\setcounter{finalframe}{\value{framenumber}}
+
+\section{Appendices}
+
+\subsection{Can I use Cloogle for language X?}
+\begin{frame}{Can I use Cloogle for language X?}
+	\begin{itemize}
+		\item It will work best on a language with the Hindley-Milner type system
+			\begin{itemize}
+				\item It can still be useful to less strongly typed languages
+				\item It would be interesting to develop a search engine for dependent types
+			\end{itemize}
+		\item The search system is language-agnostic, but you need a tool to index source code into our JSON format
+		\item Also see: \https{neilmitchell.blogspot.nl/2011/03/hoogle-for-your-language-ie-f-scala-ml.html}
+		\item Contact me!
+	\end{itemize}
+\end{frame}
+
+\subsection{Numbers}
+\begin{frame}{Numbers\setcounter{footnote}{0}\footnotemark}
+	\setcounter{footnote}{1}
+	\begin{columns}[t]
+		\begin{column}{.5\textwidth}
+			\begin{itemize}
+				\item Database
+
+					\begin{description}[Syntax constructs]
+						\small
+						\item[Modules] 750
+						\item[Functions] 15,296
+						\item[Unique types] 13,570
+						\item[Type tree depth] 8
+						\item[Type definitions] 2,195
+						\item[Classes] 262
+						\item[Derivations] 1,182
+						\item[Syntax constructs] 35
+					\end{description}
+			\end{itemize}
+		\end{column}
+		\begin{column}{.5\textwidth}
+			\begin{itemize}
+				\item Lines of code\footnotemark
+					% cloc --exclude-dir=clean-compiler,CleanRep.2.2_files,CleanRep.2.2.css,storage,cache,Clean\ System\ Files,types.json,typetree.dot,cloogle.log,tags .
+
+					\begin{description}[Bourne Shell]
+						\small
+						\item[Clean] 4,739
+						\item[JavaScript] 1,657
+						\item[PHP] 831
+						\item[HTML] 569
+						\item[CSS] 406
+						\item[Python] 110
+						\item[Bourne Shell] 71
+					\end{description}
+			\end{itemize}
+		\end{column}
+	\end{columns}
+
+	\medskip
+	\begin{itemize}
+		\item Visitor statistics: \https{cloogle.org/stats/longterm.html}
+	\end{itemize}
+
+	\setcounter{footnote}{1}
+	\footnotetext{2017-10-27}
+	\setcounter{footnote}{2}
+	\footnotetext{On the web frontend and submodules, excluding the Clean compiler}
+\end{frame}
+
+\subsection{Links}
+\begin{frame}[shrink]{Links}
+	\footnotesize
+	\textbf{Core system:}
+	\begin{description}[VS Code plugin]
+		\item[API] \https{github.com/clean-cloogle/libcloogle}
+		\item[Core] \https{github.com/clean-cloogle/Cloogle}
+		\item[Web] \https{github.com/clean-cloogle/cloogle.org}
+		\item[JS highlighter] \https{github.com/clean-cloogle/clean.js}
+		\item[Pygments lexer] \https{github.com/clean-cloogle/pygments-lexer-clean}
+		\item[Pretty printer] \https{github.com/clean-cloogle/CleanPrettyPrint}
+		\item[Type unifier] \https{github.com/clean-cloogle/CleanTypeUnifier}
+	\end{description}
+
+	\textbf{Clients:}
+	\begin{description}[VS Code plugin]
+		\item[vim-clean] \https{github.com/camilstaps/vim-clean}
+		\item[CLI app] \https{github.com/clean-cloogle/cloogle-cli}
+		\item[Telegram bot] \https{telegram.me/CloogleBot}; \https{github.com/clean-cloogle/CloogleBot}
+		\item[IRC bot] \#cloogle on \https{freenode.net}; \https{github.com/clean-cloogle/clean-irc}
+		\item[Email client] \mailto{query@cloogle.org}; \https{github.com/clean-cloogle/cloogle-mail}
+		\item[VS Code plugin] \https{github.com/W95Psp/CleanForVSCode}
+	\end{description}
+
+	\textbf{Miscellaneous:}
+	\begin{description}[Pygments lexer]
+		\item[cloogle-tags] \https{github.com/clean-cloogle/cloogle-tags}
+		\item[These slides] \https{github.com/clean-cloogle/presentation-NL-FP-2018}
+	\end{description}
+\end{frame}
+
+\setcounter{framenumber}{\value{finalframe}}
+
 \end{document}
-- 
cgit v1.2.3

