Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Mark Cohen
/
thesis
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Merge Requests
0
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8018eb24
authored
May 28, 2019
by
Mark Cohen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More presentation progress
parent
7d3f4f9c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
5 deletions
presentation/main.tex
presentation/main.tex
View file @
8018eb24
\documentclass
{
beamer
}
\documentclass
[10pt]
{
beamer
}
\usetheme
{
default
}
\usepackage
{
amssymb, amsmath, amsthm, amsrefs
}
\usepackage
{
amssymb, amsmath, amsthm, amsrefs
, mathtools
}
\usepackage
[english = american]
{
csquotes
}
\MakeOuterQuote
{
"
}
...
...
@@ -32,6 +32,9 @@
% backslash alias
\newcommand
{
\bs
}{
\,
\backslash
\,
}
% teletype alias
\renewcommand
{
\tt
}{
\texttt
}
\title
{
Typeclasses with Associated Types for ML Languages
}
\subtitle
{
Bachelors' Thesis
}
...
...
@@ -88,8 +91,8 @@ impl Iterator for Fibonacci {
\begin{frame}
{
Motivations
}
\begin{itemize}
\item
<1-> But there are drawbacks to each of these schemes.
\item
<2-> Python: not type-sound
\item
<2-> Rust: trait-based
% can only impl traits for types you "own"
\item
<2-> Python:
impure,
not type-sound
\item
<2-> Rust:
impure,
trait-based
% can only impl traits for types you "own"
\end{itemize}
\end{frame}
...
...
@@ -99,7 +102,79 @@ impl Iterator for Fibonacci {
\end{frame}
\begin{frame}
{
Beginnings: polymorphic type inference
}
\begin{frame}
[fragile]
{
Beginnings: polymorphic type inference
}
\begin{onlyenv}
<1->
\begin{lstlisting}
let
id = fn x => x
in
(id 4, id true)
\end{lstlisting}
\end{onlyenv}
\begin{onlyenv}
<2->
\begin{itemize}
\item
Need to be able to assign type
$
\forall
\alpha
.
\alpha
\arrow
\alpha
$
to
\tt
{
id
}
\item
Need to be able to instantiate
\tt
{
id
}
twice
\end{itemize}
\end{onlyenv}
\end{frame}
\begin{frame}
[fragile]
{
Adding in typeclasses
}
\begin{itemize}
\item
<1-> Work at the level of
\tt
{
over
}
and
\tt
{
inst
}
declarations
\item
<2->
{
Example:
\begin{align*}
\tt
{
over eq?
}
&
::
\forall
\alpha
.
\alpha
\arrow
\alpha
\arrow
\tt
{
bool in
}
\\
\tt
{
inst eq?
}
&
::
\tt
{
int
}
\arrow
\tt
{
int
}
\arrow
\tt
{
bool
}
\tt
{
=
}
\lambda
\tt
{
x
}
.
\lambda
\tt
{
y
}
\ldots
\tt
{
in
}
\\
\tt
{
inst eq?
}
&
::
\tt
{
char
}
\arrow
\tt
{
char
}
\arrow
\tt
{
bool
}
\tt
{
=
}
\lambda
\tt
{
x
}
.
\lambda
\tt
{
y
}
\ldots
\tt
{
in
}
\\
&
\tt
{
((eq? 5 10), (eq?
\#
"a"
\#
"a"))
}
\\
\end{align*}
}
\end{itemize}
\end{frame}
\begin{frame}
{
Typeclasses: translation to Hindley-Milner
}
% Inference and translation rules from Wadler and Blott
\end{frame}
\begin{frame}
[fragile]
{
Correcting a translation error
}
Consider the following program:
\begin{lstlisting}
[mathescape=true]
over eq? ::
$
\forall
\alpha
.
$
$
\alpha
$
$
\arrow
$
$
\alpha
$
$
\arrow
$
bool in
inst eq? :: int
$
\arrow
$
int
$
\arrow
$
bool =
$
\lambda
$
x.
$
\lambda
$
y.
$
\ldots
$
in
inst eq? :: char
$
\arrow
$
char
$
\arrow
$
bool =
$
\lambda
$
x.
$
\lambda
$
y.
$
\ldots
$
in
inst eq? ::
$
\forall
\alpha
.
\forall
\beta
.
$
(eq? ::
$
\alpha
$
$
\arrow
$
$
\alpha
$
$
\arrow
$
bool).
(eq? ::
$
\beta
$
$
\arrow
$
$
\beta
$
$
\arrow
$
bool).
(
$
\alpha
$
*
$
\beta
$
$
\arrow
$
$
\alpha
$
*
$
\beta
$
$
\arrow
$
bool)
=
$
\lambda
$
x.
$
\lambda
$
y.
$
\ldots
$
in
eq? (1, #"a") (2, #"b")
\end{lstlisting}
\end{frame}
\begin{frame}
[fragile]
{
Correcting a translation error
}
Per Wadler and Blott, the translation should be:
\begin{lstlisting}
[mathescape=true]
let eq?
$_
\tt
{
int
}$
=
$
\lambda
$
x.
$
\lambda
$
y.
$
\ldots
$
in
let eq?
$_
\tt
{
char
}$
=
$
\lambda
$
x.
$
\lambda
$
y.
$
\ldots
$
in
let eq?
$_{
\alpha
*
\beta
}$
=
$
\lambda
$
eq?
$_
\alpha
$
.
$
\lambda
$
eq?
$_
\beta
$
.
$
\lambda
$
x.
$
\lambda
$
y.
$
\ldots
$
in
eq?
$_{
\alpha
*
\beta
}$
eq?
$_
\tt
{
int
}$
eq?
$_
\tt
{
char
}$
(1, #"a") (2, #"b")
\end{lstlisting}
\end{frame}
\begin{frame}
{
Associated types
}
\begin{itemize}
\item
New
\tt
{
assoc
}
declaration
\end{itemize}
\end{frame}
% TODO: why not Haskell?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment