-
Notifications
You must be signed in to change notification settings - Fork 0
/
Precedence.fold
103 lines (71 loc) · 2 KB
/
Precedence.fold
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
--
-- Prefix Function Application
--
-> - 1
-- ^~~
-- ` unary prefix function application
-> - 1 2
-- ^~~~~
-- ` binary prefix function application
-> f a b = a + b
-> f 2 3 - 1
= (- (f 2 3) 1)
-> f 3 3 - 1
-- ^~~~~ ^~~
-- | |
-- ` prefix function application
-- |
-- ` infix function application
= (- (f 3 3) 1)
-> f 3 - 1
-- ^~~
-- Error: This expression has type Int -> Int
-- but expression was expected of type Int
= (- (f 3) 1)
-> f 3 (- 1)
= 2
-- The prefix functions are parsed until an infix function is found, this means
-- that the arithmetic operations can be written in a prefix form, since there
-- are prefix variants of the infix addition, subtraction, addition and
-- division functions.
-> - 4 2
= 2
-> - 5 1 1 1
= 5 - 1 - 1 - 1
= (- 5 1 1 1)
= (- (- (- 5 1) 1) 1)
= 2
=> - 5 1 1 1 + 1
= (- 5 1 1 1) + 1
= 3
=> (view::View) did_update ~context::Context = ...
=> main_view did_update ~context
=> View.create geometry: Fullscreen did_update ~context
^~~~~~~~~~
* Error: This expression has type Geometry,
but an expression was expected of type View.
=> (View.create geometry: Fullscreen) did_update ~context
=> sum 3 with: 4 + 5
= sum 3 with: (4 + 5)
-- Why? Because of the `:` operator.
=> f a b c d
= (f a b c d)
=> f a g: b c d
= (f:g:, [a b c d])
-- FIXME: How to provide the argument order?
-- For every nud symbol, parsing is performed
module Plug.HeadTest:
open ExUnit.Case async: true
open Plug.Test
@opts Plug.Head.init([])
test "converts HEAD requests to GET requests":
conn = Plug.Head.call (conn head: "/") @opts
assert: conn.method == "GET"
test "HEAD responses have headers but do not have a body":
conn = conn head: "/"
|> Plug.Head.call opts
|> put_resp_content_type "text/plain"
|> send_resp 200 "Hello world"
assert: conn.status == 200
assert: get_resp_header conn "content-type" == ["text/plain; charset=utf-8"]
assert: conn.resp_body == ""