From b3e78b49f0c05af4f734fc8e40af0c5c3041969e Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 4 Jan 2018 12:09:56 +0200 Subject: [PATCH] Finish up slides for whirlwind tour --- .../whirlwind-tour-core-haskell-libraries.md | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/reveal/whirlwind-tour-core-haskell-libraries.md b/reveal/whirlwind-tour-core-haskell-libraries.md index f9b5202..73d7200 100644 --- a/reveal/whirlwind-tour-core-haskell-libraries.md +++ b/reveal/whirlwind-tour-core-haskell-libraries.md @@ -109,7 +109,7 @@ Sequential data the most complicated, let's knock out the other two * `data IntMap value` * `data HashMap key value` * `IntMap` is a specialized, optimized `Map Int` -* `Map` is a binary tree, `HashMap` is (surprised) hash map +* `Map` is a binary tree, `HashMap` is (surprise) hash map * `Map` requires `Ord` on keys, `HashMap` requires `Hashable` and `Eq` * Generally: `HashMap` performs better @@ -651,7 +651,19 @@ main = hPutBuilder stdout $ toLines $ take 1000 odds ## Network server with conduit -* FIXME include some code samples +Simple echo server example + +```haskell +{-# LANGUAGE OverloadedStrings #-} +import Data.Conduit +import Data.Conduit.Network + +main :: IO () +main = runTCPServer (serverSettings 3001 "127.0.0.1") echo + +echo :: AppData -> IO () +echo app = runConduit $ appSource app .| appSink app +``` --- @@ -666,17 +678,17 @@ main = hPutBuilder stdout $ toLines $ take 1000 odds --- -## Concurrency +## Mutable data -* FIXME UnliftIO.Async -* https://haskell-lang.org/library/async +* https://github.com/fpco/applied-haskell/blob/master/mutable-variables.md +* Single cell references: https://www.stackage.org/package/mutable-containers --- -## Mutable data +## Concurrency -* FIXME -* https://github.com/fpco/applied-haskell/blob/master/mutable-variables.md +* tl;dr: use `UnliftIO.Async` and `UnliftIO.STM` +* https://haskell-lang.org/library/async --- @@ -690,14 +702,22 @@ main = hPutBuilder stdout $ toLines $ take 1000 odds ## External processes -* FIXME typed-process * https://haskell-lang.org/library/typed-process --- +## Structuring applications + +* Use `RIO` +* Define `Has` typeclasses +* Demonstration: `pantry`: https://github.com/snoyberg/codename-karka/blob/master/pantry/src/Pantry.hs +* + +--- + ## Random grab bag -* Typeclassopedia FIXME add link +* * * *