diff options
author | Vincent Ambo <mail@tazj.in> | 2020-06-26T19·38+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-06-26T19·51+0000 |
commit | 2e3b03b5ae04cc9d4da0001aff07962bf4107d42 (patch) | |
tree | 75d929acb15720bc8eb1182d105e2ecaa2626ba0 /presentations/servant-2016/slides.pdfpc | |
parent | 1d0e421cb86861c64b58d5aa66dce295ffe28af5 (diff) |
chore(tazjin): Move my presentations to my user directory r/1090
Change-Id: I72b25680e7167c3a55477111c28b1d4936c60e2c Reviewed-on: https://cl.tvl.fyi/c/depot/+/606 Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'presentations/servant-2016/slides.pdfpc')
-rw-r--r-- | presentations/servant-2016/slides.pdfpc | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/presentations/servant-2016/slides.pdfpc b/presentations/servant-2016/slides.pdfpc deleted file mode 100644 index ed46003768c0..000000000000 --- a/presentations/servant-2016/slides.pdfpc +++ /dev/null @@ -1,75 +0,0 @@ -[file] -slides.pdf -[font_size] -10897 -[notes] -### 1 -13### 2 -Let's talk about servant, which is several things: -API description DSL, we'll speak about how this DSL works -and why it's at the type level - -Interpretations of the types resulting from that DSL, for example in -web servers or API clients - -Servant is commonly used or implementing services with APIs, or for accessing -other APIs with a simple, typed client -### 3 -Why type-level DSLs? -Type-level DSL: express *something*, e.g. endpoints of API, on type level by combining types. Types can be uninhabited - -Phil Wadler's: expression problem: things should be extensible both in the cases of a type, and in the functions operating on the type -Normal data types: can't add new constructors easily -Servant lifts thisup to simply allow the declaration of new types that can be included in the DSL, and new interpretations that can be attached to the types through typeclasses - -APIs become first-class citizens, can pass them around, combine them etc, they are separate from interpretations such as server implementations. In contrast, in most webframeworks, API declaration is implicit - -(Mention previous attemps at type-safe web, Yesod / web-routes + boomerang etc) -### 4 -Three extensions are necessary: -TypeOperators lets us use infix operators on the type level as constructors -DataKinds promotes new type declarations to the kind level, makes type-level literals (strings and natural numbers) available, lets us use type-level lists and pairs in combination with typeoperators -TypeFamilies: Type-level functions, map one set of types to another, come in two forms (type families, non-injective; data families, injective), more powerful than associated types -### 5 -Here you can see servant's general syntax, we define an API type as a simple alias of some other type combinations -strings are type-level strings, not actually values, represent path elements -endpoints are separated by :<|>, all endpoints end in a method with content types and return types -Capture captures path segments, but there are other combinators, for example for headers -Everything that is used from the request is expressed in types, enforcing checkability, no "escape hatch" inside handlers to get request -Every combinator has associated interpretations through typeclasses -### 6 -Explain type alias, point out Capture -Server is a type level function (type family), as mentioned earlier -### 7 -If we expand server (in ghci with kind!) we can see the actual type of the -function -### 8 -Lets speak about some interpretations of these things -### 9 -Servant server is the main interpretation that people are interested in, it's used -for taking a type specification and creating a server from it -Based on WAI, the web application interface, common abstraction for web servers which came out of the Yesod project. Implemented by the web server warp, which Yesod runs on -### 10 -Explain snippet, path gets removed from server type (irrelevant for handler), -route extracts string to value level -### 11 -Explain echo server quickly -### 12 -servant client allows generation of Haskell functions that query the API with the same types -this makes for easy to use RPC for example -### 13 -A lot of other interpretations exist for all kinds of things, mock servers for testing, foreign functions in various languages, documentation ... -### 14 -Demo! -1. Go quickly through code -2. Run server, query with curl -3. Open javascript function -4. Show JS code in the thing -5. Open the map itself -6. Open GHCi, use client -7. Generate docs -### 15 -Conclusion -Servant is pretty good, it's very easy to get started and it's great to raise the level of things that the compiler can tell you about when you do them wrong. -### 16 -Drawbacks. |