Skip to content

Commit

Permalink
Sharing example
Browse files Browse the repository at this point in the history
  • Loading branch information
sudonatalie committed Jun 6, 2017
1 parent 64e5ef5 commit 5f98b32
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Presentation/Agda/Sharing.lagda
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
\begin{code}
module Sharing where

data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ

_+_ : ℕ → ℕ → ℕ
zero + n = n
suc m + n = suc (m + n)

one = suc zero

four = let two = one + one
in two + two
\end{code}
20 changes: 20 additions & 0 deletions Presentation/Figures/Sharing.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module MAlonzo.Code.Sharing where

import MAlonzo.RTE
import qualified MAlonzo.RTE
import qualified Data.Text

name2 = "Sharing.ℕ"
d2 = ()
data T2 a0 = C4 | C6 a0
name8 = "Sharing._+_"
d8 v0 v1
= case coe v0 of
C4 -> coe v1
C6 v2 -> coe C6 (coe d8 v2 v1)
_ ->
name16 = "Sharing.one"
d16 = coe C6 C4
name18 = "Sharing.four"
d18 = coe d8 (coe d8 d16 d16)
(coe d8 d16 d16)
18 changes: 17 additions & 1 deletion Presentation/Presentation.lhs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
}
\lstdefinestyle{haskell}{
language=Haskell,
basicstyle=\ttfamily\scriptsize
basicstyle=\ttfamily\scriptsize,
extendedchars=true,
literate={⊥}{{$\bot$}}1 {ℕ}{{$\mathbb{N}$}}1
}

\title{(Re-)Creating sharing in Agda's GHC backend}
Expand Down Expand Up @@ -99,6 +101,20 @@ Proof:\\
\input{Agda/latex/Proof}
\end{frame}

\begin{frame}{Sharing}
\begin{figure}[h]
\hspace{-1.5cm}
\begin{subfigure}{.45\textwidth}
\small
\input{Agda/latex/Sharing}
\end{subfigure}
\hspace{1cm}
\begin{subfigure}{.55\textwidth}
\lstinputlisting[style=haskell]{Figures/Sharing.hs}
\end{subfigure}
\end{figure}
\end{frame}

\section{Compiler}

\begin{frame}{Compiler}
Expand Down

0 comments on commit 5f98b32

Please sign in to comment.