Changeset 25
- Timestamp:
- Nov 23, 2007, 11:18:30 AM (18 years ago)
- Author:
- ats
- Message:
-
Various small tweaks based on the OOo version and Neil's comments.
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/trunk/200711-tock-seminars/200711-tock-slides.tex
r24 r25 28 28 \title{Tock} 29 29 \subtitle{A Swift Kick in the Monads} 30 (追記) % FIXME: Ahem... (追記ここまで) 31 (追記) % "Our quest to use as many Haskell libraries as possible in one (追記ここまで) 32 (追記) % project" (追記ここまで) 30 33 31 34 \author{Neil Brown and Adam Sampson} … … 82 85 columns=flexible, 83 86 basicstyle=\small, 84 keywordstyle=\color{b (削除) (削除ここまで)lue}\bfseries,87 keywordstyle=\color{b(追記) eamer@blendedb (追記ここまで)lue}\bfseries, 85 88 identifierstyle=, 86 89 commentstyle=\color{ForestGreen}\itshape, … … 146 149 \item Relatively straightforward to add new frontends and backends 147 150 \end{itemize} 151 (追記) %FIXME: Needs >-< diagram (追記ここまで) 148 152 \end{frame} 149 153 … … 187 191 \end{itemize} 188 192 %FIXME: picture 193 (追記) %FIXME: code gen isn't really separate pass -- could rename to "output"? (追記ここまで) 189 194 \end{itemize} 190 195 \end{frame} … … 200 205 \item Emit final AST as generated code 201 206 %FIXME: picture 207 (追記) %FIXME: this feels like a duplicate of the previous slide (追記ここまで) 202 208 \end{itemize} 203 209 \end{frame} … … 283 289 data Meta = Meta SourcePos 284 290 data Process = Seq Meta [Process] 285 (削除) (削除ここまで)| Alt Meta [AltGuard]286 (削除) (削除ここまで)| ...291 (追記) (追記ここまで)| Alt Meta [AltGuard] 292 (追記) (追記ここまで)| ... 287 293 data AltGuard = AltGuard Meta Guard Process 288 (削除) (削除ここまで)| ...294 (追記) (追記ここまで)| ... 289 295 \end{lstlisting} 290 296 \begin{itemize} … … 309 315 \end{lstlisting} 310 316 \begin{itemize} 311 \item \lstinline|foo'| can be applied to any (削除) (削除ここまで)|Typeable| type317 \item \lstinline|foo'| can be applied to any (追記) \lstinline (追記ここまで)|Typeable| type 312 318 \item Provides introspection and dynamic typing in Haskell 313 319 \end{itemize} 320 (追記) % FIXME: Justify choice of generics library (because it works and it (追記ここまで) 321 (追記) % comes with GHC) (追記ここまで) 314 322 \end{frame} 315 323 … … 318 326 \begin{itemize} 319 327 \item This does not automatically recurse 320 \item You get (削除) |gmapT| -- generic (削除ここまで)|map| -- which looks at the type and328 \item You get (追記) \lstinline|gmapT| -- generic \lstinline (追記ここまで)|map| -- which looks at the type and 321 329 maps across all the type constructor arguments 322 330 \item Library provides various higher-level functions built on this … … 331 339 \frametitle{Scrap Your Boilerstate} 332 340 \begin{itemize} 333 \item (削除) (削除ここまで)|Data.Generics| also provides monadic and query versions of all341 \item (追記) \lstinline (追記ここまで)|Data.Generics| also provides monadic and query versions of all 334 342 its functions 335 343 \end{itemize} … … 350 358 \frametitle{Scrapping Our Boilerplate} 351 359 \begin{itemize} 352 \item (削除) (削除ここまで)|everywhere| applies a transformation recursively360 \item (追記) \lstinline (追記ここまで)|everywhere| applies a transformation recursively 353 361 \item We can use this to write transformation passes 354 362 \begin{itemize} … … 368 376 \frametitle{Problems with generics} 369 377 \begin{itemize} 370 \item |everywhere| really does look \emph{everywhere} 371 \begin{itemize} 372 \item e.g. at all the |Char|s in all the |String|s\ldots 378 \item \lstinline|everywhere| really does look \emph{everywhere} 379 \begin{itemize} 380 \item e.g. at all the \lstinline|Char|s in all the 381 \lstinline|String|s\ldots 373 382 \end{itemize} 374 383 \item Very slow! … … 381 390 \frametitle{Problems with generics} 382 391 \begin{itemize} 383 \item Sometimes (削除) (削除ここまで)|everywhere| is not the traversal we want392 \item Sometimes (追記) \lstinline (追記ここまで)|everywhere| is not the traversal we want 384 393 \begin{itemize} 385 394 \item e.g. we only want the outermost part of a recursive type 386 395 % FIXME: emph first Par 387 \item (削除) (削除ここまで)|Par (Par a b) (Par c d)|396 \item (追記) \lstinline (追記ここまで)|Par (Par a b) (Par c d)| 388 397 \end{itemize} 389 398 \item No problem -- we can write different traversal functions for … … 395 404 \frametitle{Problems with generics} 396 405 \begin{itemize} 397 \item (削除) (削除ここまで)|Data.Generics| has some limitations406 \item (追記) \lstinline (追記ここまで)|Data.Generics| has some limitations 398 407 \item In particular, higher-order types are awkward to work with 399 408 \begin{itemize} … … 465 474 \end{itemize} 466 475 \end{itemize} 476 (追記) %FIXME: Split this up among the following slides (追記ここまで) 467 477 \end{frame} 468 478 … … 478 488 (Block (Pos 7) [ ]) 479 489 \end{lstlisting} 490 (追記) %FIXME: Explain what Pos is (in description above anyway) (追記ここまで) 480 491 \end{frame} 481 492 … … 495 506 ) = True 496 507 checkIfTest0 _ = False 497 (削除) (削除ここまで)498 508 \end{lstlisting} 499 509 \end{frame} … … 521 531 p0 = Pos 0 522 532 \end{lstlisting} 533 (追記) %FIXME: More explanation (追記ここまで) 523 534 \end{frame} 524 535 … … 537 548 = Assign p0 (VarList p0 [lhv]) (ExprList p0 [JustVar rhv]) 538 549 \end{lstlisting} 550 (追記) %FIXME: Say "tmp42" or something instead of "t" here, to make it clear (追記ここまで) 551 (追記) %it's a nonce? (追記ここまで) 539 552 \end{frame} 540 553 … … 560 573 \item Use Haskell's pattern matching? 561 574 \begin{itemize} 562 \item Can't (削除) avoid duplication in (削除ここまで)pattern575 \item Can't (追記) reuse repeated bits of (追記ここまで) pattern 563 576 \item Can't give a \emph{helpful} error when the pattern match 564 577 fails … … 587 600 \frametitle{Generic pattern-matching} 588 601 \begin{itemize} 589 \item Built on (削除) (削除ここまで)|Data.Generics|602 \item Built on (追記) \lstinline (追記ここまで)|Data.Generics| 590 603 \end{itemize} 591 604 \begin{lstlisting} … … 596 609 \end{lstlisting} 597 610 \begin{itemize} 598 \item All (削除) (削除ここまで)|Named| items with the same name must match611 \item All (追記) \lstinline (追記ここまで)|Named| items with the same name must match 599 612 \end{itemize} 600 613 \end{frame} … … 625 638 (mBlock DC ([ ] :: [Statement]))) 626 639 (parse "if (a) { }") 627 640 628 641 mExpr :: (Data a0, Data a1) => a0 -> a1 -> Pattern 629 642 \end{lstlisting} 643 (追記) %FIXME: Show the helpful output from a failed match? (追記ここまで) 644 (追記) %FIXME: Point out mixing of pattern and normal data here (追記ここまで) 630 645 \end{frame} 631 646 … … 645 660 (mExprList DC [mJustVar rhv]) 646 661 \end{lstlisting} 662 (追記) %FIXME: Point out that singleAssign' can be reused between tests (追記ここまで) 647 663 \end{frame} 648 664 … … 652 668 \item Removed duplication, improved readability 653 669 \item More helpful errors when match fails 654 \item We can match anything that's an instance of (削除) (削除ここまで)|Typeable|670 \item We can match anything that's an instance of (追記) \lstinline (追記ここまで)|Typeable| 655 671 \begin{itemize} 656 672 \item Functions are trickier 657 673 \end{itemize} 658 674 \item Patterns are type-checked at run-time (i.e. test-time) 675 (追記) \item Speed's not great (追記ここまで) 676 (追記) \begin{itemize} (追記ここまで) 677 (追記) \item Doesn't matter for tests (追記ここまで) 678 (追記) \item But if it were faster, we could use it in real (追記ここまで) 679 (追記) passes (追記ここまで) 680 (追記) \end{itemize} (追記ここまで) 659 681 \end{itemize} 660 682 \end{frame} … … 752 774 753 775 %{{{ monads 776 (追記) %FIXME: kill this section (追記ここまで) 754 777 \section{Monads} 755 778 … … 765 788 \frametitle{Some useful monads} 766 789 \begin{itemize} 767 \item (削除) (削除ここまで)|IO|: dealing with the real world768 \item (削除) (削除ここまで)|State|: persistent state which can be changed769 \item (削除) (削除ここまで)|Error|: any operation can throw an exception, short-circuiting the evaluation770 \item (削除) (削除ここまで)|Parser|: operations can consume tokens and backtrack upon failure790 \item (追記) \lstinline (追記ここまで)|IO|: dealing with the real world 791 \item (追記) \lstinline (追記ここまで)|State|: persistent state which can be changed 792 \item (追記) \lstinline (追記ここまで)|Error|: any operation can throw an exception, short-circuiting the evaluation 793 \item (追記) \lstinline (追記ここまで)|Parser|: operations can consume tokens and backtrack upon failure 771 794 \end{itemize} 772 795 \end{frame} … … 776 799 \begin{itemize} 777 800 \item Monads can be composed using monad transformers 778 \item Our main monad composes the |Error|, |State| and |IO| monads 801 \item Our main monad composes the \lstinline|Error|, 802 \lstinline|State| and \lstinline|IO| monads 779 803 \begin{itemize} 780 804 \item Many other variations throughout Tock … … 815 839 \begin{itemize} 816 840 \item No lookahead needed 817 \item (削除) (削除ここまで)|try| lets you decide when to commit to a particular branch (like Prolog cut)841 \item (追記) \lstinline (追記ここまで)|try| lets you decide when to commit to a particular branch (like Prolog cut) 818 842 \end{itemize} 819 843 \item Can pass state around for awkward languages … … 886 910 isJustVar _ = False 887 911 \end{lstlisting} 912 (追記) %FIXME: "The code snippet is short, but I worry that it is not very (追記ここまで) 913 (追記) %understandable" (追記ここまで) 888 914 \end{frame} 889 915 … … 936 962 \item Must support recursion 937 963 \begin{itemize} 938 \item e.g. |genWhile| -> |genProcess| -> |cppGenCall| 964 \item e.g. \lstinline|genWhile| -> 965 \lstinline|genProcess| -> \lstinline|cppGenCall| 939 966 %Note: don't want the above -> arrows to be highlighted as 940 967 %if they were Haskell code! … … 984 1011 genStatement = (\_ _ -> tell ["$$$"]) } 985 1012 \end{lstlisting} 1013 (追記) %FIXME: undefined saves needing to construct a value, and makes sure (追記ここまで) 1014 (追記) %it's not evaluated (追記ここまで) 986 1015 \end{frame} 987 1016 … … 1016 1045 %Note: we can't avoid exceptions or virtual functions in C++, 1017 1046 %because they are part of C++CSP itself! 1047 (追記) %FIXME: That's OK -- we don't need to analyse C++CSP itself, (追記ここまで) 1048 (追記) %just like we don't analyse CCSP... say "control how we (追記ここまで) 1049 (追記) %generate"? (追記ここまで) 1018 1050 \end{itemize} 1019 1051 \end{itemize} … … 1169 1201 1170 1202 \begin{frame} 1171 \frametitle{How we use Haskell: a fistful of dollars} 1203 \frametitle{How we use Haskell} 1204 \framesubtitle{A fistful of dollars} 1172 1205 \begin{itemize} 1173 1206 \item Use the \lstinline|$| operator to avoid nested brackets … … 1188 1221 1189 1222 \begin{frame} 1190 \frametitle{Haskell frustrations: why doesn't this work?} 1223 \frametitle{Haskell frustrations} 1224 \framesubtitle{Why doesn't this work?} 1191 1225 \begin{itemize} 1192 1226 \item Debugging is hard … … 1198 1232 \end{itemize} 1199 1233 \item Unit tests do help to narrow down problems 1200 \item We often resort to printf debugging (that's why |IO| is in |PassM|) 1201 \end{itemize} 1202 \end{itemize} 1203 \end{frame} 1204 1205 \begin{frame} 1206 \frametitle{Haskell frustrations: what is your problem?} 1234 \item We often resort to printf debugging (that's why 1235 \lstinline|IO| is in \lstinline|PassM|) 1236 \end{itemize} 1237 \end{itemize} 1238 %FIXME: example of a nasty type error with solution? 1239 \end{frame} 1240 1241 \begin{frame} 1242 \frametitle{Haskell frustrations} 1243 \framesubtitle{What's the problem?} 1207 1244 \begin{itemize} 1208 1245 \item Type errors … … 1215 1252 \begin{itemize} 1216 1253 \item Would be nice to be able to ask GHCI about 1217 definitions in (削除) (削除ここまで)|where| clauses\ldots1254 definitions in (追記) \lstinline (追記ここまで)|where| clauses\ldots 1218 1255 \end{itemize} 1219 1256 \item We often resort to trial and error … … 1223 1260 1224 1261 \begin{frame} 1225 \frametitle{Haskell frustrations: going in circles} 1262 \frametitle{Haskell frustrations} 1263 \framesubtitle{Going in circles} 1226 1264 \begin{itemize} 1227 1265 \item Haskell disallows mutually recursive modules 1228 1266 \begin{itemize} 1229 \item |A.foo| calls |B.bar|, |B.bar| calls |A.baz| 1267 \item \lstinline|A.foo| calls \lstinline|B.bar|, which 1268 calls \lstinline|A.baz| 1230 1269 \end{itemize} 1231 1270 \item But we want to do this quite often … … 1238 1277 1239 1278 \begin{frame} 1240 \frametitle{Haskell frustrations: a pain in the monads} 1279 \frametitle{Haskell frustrations} 1280 \framesubtitle{A pain in the monads} 1241 1281 \begin{itemize} 1242 1282 \item Monad transformers aren't available for all monads … … 1245 1285 \item You can't have a parser or test that does IO (safely!) 1246 1286 \end{itemize} 1247 \item Monad transformer typeclass instances (e.g. (削除) (削除ここまで)|MonadState|) aren't1287 \item Monad transformer typeclass instances (e.g. (追記) \lstinline (追記ここまで)|MonadState|) aren't 1248 1288 derived automatically 1249 1289 \end{itemize}
Note:
See TracChangeset
for help on using the changeset viewer.