Code Snippet
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
| module Standard =
let (@@) : ('a -> 'b option) -> ('a -> 'b option) -> 'a -> 'b option =
fun f g x ->
match f x with
| None -> g x
| some -> some
let standard : string -> string option = function
| ".txt" -> Some "text/plain"
| ______ -> None
type config =
{ mimeTypes : string -> string option }
let patternMatch : string -> config -> string option =
fun x { config.mimeTypes = f } ->
f x
let config = { mimeTypes = standard }
module Custom =
open Standard
let extended : string -> string option = function
| ".avi" -> Some "video/avi"
| ______ -> None
let custom = standard @@ extended
let config = { config with mimeTypes = custom }
Standard . config |> Standard . patternMatch ".avi"
Custom . config |> Standard . patternMatch ".avi"
|
Code output:
References:
- Suave.IO:
- Suave.IO @ GitHub: