-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfp2-slides-07.tex
More file actions
77 lines (63 loc) · 2.25 KB
/
fp2-slides-07.tex
File metadata and controls
77 lines (63 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%! suppress = MissingImport
%! suppress = MissingLabel
%! suppress = LineBreak
% CLI args https://tex.stackexchange.com/a/1501
\newif\ifhandout
\input{flags}
\input{preamble-slides}
\setminted{xleftmargin=\parindent, autogobble, escapeinside=??}
\newcommand{\iso}{\sim}
\title{7. Эффекты}
\author{Андрей Стоян}
\institute[ИПКН ИТМО]{ИПКН ИТМО}
\date{осень 2025}
\begin{document}
\mymaketitle
\begin{frame}[noframenumbering]{Содержание}
\tableofcontents
\end{frame}
\sectionplan{Понятие эффекта}
\begin{frame}[fragile]{Эффекты для управления сложностью}
\vspace{-1em}
\begin{columns}[onlytextwidth]
\begin{column}[t]{0.52\textwidth}
\begin{minted}{haskell}
getList :: Int -> World -> (World, [Int])
getList n w | n == 0 = (w, [])
| otherwise =
let (w', x) = getInt w in
let (w'', xs) = getList (n - 1) w' in
(w'', x : xs)
\end{minted}
\end{column}\hfill%
\begin{column}[t]{0.43\textwidth}
\begin{minted}{haskell}
getList :: Int -> IO [Int]
getList n | n == 0 = pure []
| otherwise = do
x <- getInt
xs <- getList (n - 1)
return (x : xs)
\end{minted}
\end{column}
\end{columns}
\end{frame}
\begin{frame}[fragile]{Эффекты как слиент-серверное взаимодействие}
\begin{figure}
\centering
\includegraphics[width=0.6\textwidth]{figs/effects}
\end{figure}
\end{frame}
\sectionplan{Хендлеры эффектов}
\begin{frame}[fragile]{Хендлеры как resumable exceptions}
\pause
\begin{minted}{haskell}
effect reader<e>
ctl ask(): e
fun main()
with handler
ctl ask() resume(20)
print(2 + ask() + ask())
\end{minted}
\end{frame}
\end{document}