Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More work on slides.

  • Loading branch information...
commit 6035a55cf414c9edd43680f6cee4e692b2b29905 1 parent a6dd690
Tom Lokhorst authored
Showing with 247 additions and 34 deletions.
  1. +23 −0 presentation/BoolLike.lhs
  2. +224 −34 presentation/RealExpr.lhs
23 presentation/BoolLike.lhs
View
@@ -60,6 +60,7 @@
\end{frame}
+
\begin{frame}
%if style /= newcode
@@ -102,3 +103,25 @@
\end{frame}
+
+\begin{frame}
+
+%if style /= newcode
+
+\begin{verbatim}
+
+ghci> :t not
+not :: (BoolLike b) => b -> b
+
+ghci> not True
+False
+
+ghci> not ConTrue
+If ConTrue ConFalse ConTrue
+
+\end{verbatim}
+
+%endif
+
+\end{frame}
+
258 presentation/RealExpr.lhs
View
@@ -14,13 +14,20 @@
%if style /= newcode
-> if 2 + 3 == 5
-> then 1
-> else 0
-
-%endif
-
-\pause
+\begin{overlayarea}{\textwidth}{0.5\textheight}
+\only<1>{
+
+> data Expr where
+> Con :: Int -> Expr
+> Add :: Expr -> Expr -> Expr
+> Mul :: Expr -> Expr -> Expr
+> ConFalse :: Expr
+> ConTrue :: Expr
+> Eq :: Expr -> Expr -> Expr
+> If :: Expr -> Expr -> Expr -> Expr
+
+}
+\only<2>{
> data Expr a where
> Con :: Int -> Expr Int
@@ -30,22 +37,53 @@
> ConTrue :: Expr Bool
> Eq :: Expr Int -> Expr Int -> Expr Bool
> If :: Expr Bool -> Expr a -> Expr a -> Expr a
-
+
+}
+\end{overlayarea}
+
+%endif
+
\end{frame}
\begin{frame}
-> eval :: Expr a -> a
-> eval (Con x) = x
-> eval (Add x y) = eval x + eval y
-> eval (Mul x y) = eval x * eval y
-> eval (ConFalse) = False
-> eval (ConTrue) = True
-> eval (Eq x y) = eval x == eval y
-> eval (If p x y) = if eval p
-> then eval x
-> else eval y
+%if style /= newcode
+
+\begin{overlayarea}{\textwidth}{0.5\textheight}
+\only<1>{
+
+> WhiteSpace
+>
+> class BoolLike b where
+> false :: b
+> true :: b
+> bool :: a -> a -> b -> a
+
+> instance BoolLike Expr where
+> false = ConFalse
+> true = ConTrue
+> bool x y b = If b y x
+
+}
+\only<2>{
+
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j Bool -> j r
+
+> instance BoolC Expr where
+> false = ConFalse
+> true = ConTrue
+> bool x y b = If b y x
+
+}
+\end{overlayarea}
+
+%endif
\end{frame}
@@ -54,39 +92,191 @@
%if style /= newcode
-> if 2 + 3 == 5
-> then 1
-> else 0
+\begin{overlayarea}{\textwidth}{1.0\textheight}
+\only<1>{
-\pause
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
-\begin{overlayarea}{\textwidth}{0.2\textheight}
+}
\only<2>{
-> x :: Expr Int
-> x = If (Eq (Add (Con 2) (Con 3))
-> (Con 5))
-> (Con 1)
-> (Con 0)
-
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
}
\only<3>{
-> x :: Expr Int
-> x = If (Eq (2 + 3) 5) (1) (0)
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
+> nothing :: j (Maybe a)
}
-%format == = "=="
\only<4>{
-> x :: Expr Int
-> x = If (2 + 3 == 5) (1) (0)
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
+> nothing :: j (Maybe a)
+> just :: j a -> j (Maybe a)
+
+}
+\only<5>{
+
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
+> nothing :: j (Maybe a)
+> just :: j a -> j (Maybe a)
+> maybe :: j r -> (j a -> j r) -> j (Maybe a) -> j r
+
+}
+\only<6>{
+
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
+> nothing :: j (Maybe a)
+> just :: j a -> j (Maybe a)
+> maybe :: j r -> (j a -> j r) -> j (Maybe a) -> j r
+
+> class ListC j where
+
+}
+\only<7>{
+
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
+> nothing :: j (Maybe a)
+> just :: j a -> j (Maybe a)
+> maybe :: j r -> (j a -> j r) -> j (Maybe a) -> j r
+
+> class ListC j where
+> nil :: j [a]
+
+}
+\only<8>{
+
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
+> nothing :: j (Maybe a)
+> just :: j a -> j (Maybe a)
+> maybe :: j r -> (j a -> j r) -> j (Maybe a) -> j r
+
+> class ListC j where
+> nil :: j [a]
+> cons :: j a -> j [a] -> j [a]
+
+}
+\only<9>{
+
+> WhiteSpace
+> data Bool
+>
+> class BoolC j where
+> false :: j Bool
+> true :: j Bool
+> bool :: j r -> j r -> j BoolD -> j r
+
+> data Maybe a
+>
+> class MaybeC j where
+> nothing :: j (Maybe a)
+> just :: j a -> j (Maybe a)
+> maybe :: j r -> (j a -> j r) -> j (Maybe a) -> j r
+
+> class ListC j where
+> nil :: j [a]
+> cons :: j a -> j [a] -> j [a]
+> list :: j r -> (j a -> j [a] -> j r) -> j [a] -> j r
}
\end{overlayarea}
%endif
+\end{frame}
+
+
+\begin{frame}
+
+test
+
+%if style /= newcode
+
+> if 2 + 3 == 5
+> then 1
+> else 0
+
+\pause
+
+
+%endif
+
%if style == newcode
> instance Show (Expr a) where
Please sign in to comment.
Something went wrong with that request. Please try again.