From: Mart Lubbers Date: Tue, 22 Mar 2016 21:12:29 +0000 (+0100) Subject: up X-Git-Tag: first_presentation X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=1f7b5674918153e05aae50332338eaeff4ad0dcc;p=rsss1516.git up --- diff --git a/long/long.tex b/long/long.tex index b6c20fc..1c35411 100644 --- a/long/long.tex +++ b/long/long.tex @@ -117,16 +117,16 @@ eval (Div t u) \begin{CleanCode} :: M a = ... unit :: a -> M a -((#$\star$#)) :: (M a) (a -> M b) -> M b +((#$\star$#)) infixl 1 :: (M a) (a -> M b) -> M b \end{CleanCode} \end{block} \pause% \begin{block}{Evaluator (Identity monad)} \begin{CleanCode} :: M a :== a -unit :: a -> I a +unit :: a -> a unit a = a -((#$\star$#)) :: (M a) (a -> M b) -> M b +((#$\star$#)) infixl 1 :: (M a) (a -> M b) -> M b ((#$\star$#)) a k = k a \end{CleanCode} \end{block} @@ -145,7 +145,7 @@ unit a = a unit :: a -> M a unit a = Return a -((#$\star$#)) :: (M a) (a -> M b) -> M b +((#$\star$#)) infixl 1 :: (M a) (a -> M b) -> M b ((#$\star$#)) m k = case m of Raise e = Raise e Return a = k a @@ -170,7 +170,7 @@ raise e = Raise e unit :: a -> M a unit a = \x.(a, x) -((#$\star$#)) :: (M a) (a -> M b) -> M b +((#$\star$#)) infixl 1 :: (M a) (a -> M b) -> M b ((#$\star$#)) m k = \x.let (a, y) = m x in let (b, z) = k a y in (b, z) @@ -214,7 +214,7 @@ m (#$\star$#) (\a.n (#$\star$#) \b.o) = (m (#$\star$#) \a.n) (#$\star$#) \b.o unit :: a -> M a unit a = \x.[(a, x)] -((#$\star$#)) :: (M a) (a -> M b) -> M b +((#$\star$#)) infixl 1 :: (M a) (a -> M b) -> M b ((#$\star$#)) m k = \x.[(b, z) \\ (a, y) <- m x, (b, z) <- k a y] \end{CleanCode} \end{frame} @@ -226,15 +226,16 @@ unit a = \x.[(a, x)] zero :: M a zero = \x.[] -((#$\oplus$#)) :: (M a) (M a) -> M a +((#$\oplus$#)) infixl 4 :: (M a) (M a) -> M a ((#$\oplus$#)) m n = \x.m x ++ n x -((#$\triangleright$#)) :: (M a) (a -> Bool) -> M a +((#$\triangleright$#)) infixl 4 :: (M a) (a -> Bool) -> M a ((#$\triangleright$#)) m p = m (#$\star$#) \a.if (p a) (unit a) zero item :: M Char -item [] = [] -item [a:x] = [(a, x)] +item = \x.case x of + [] = [] + [a:x] = [(a, x)] \end{CleanCode} \end{frame} @@ -250,7 +251,7 @@ iterate (item (#$\triangleright$#) isDigit) "23 and more" \end{CleanCode} \pause \begin{CleanCode} -((#$\oslash$#)) :: (M a) (M a) -> M a +((#$\oslash$#)) infixl 4 :: (M a) (M a) -> M a ((#$\oslash$#)) m n = \x.if (m x <> []) (m x) (n x) \end{CleanCode} \end{frame}