File tree 4 files changed +38
-25
lines changed 4 files changed +38
-25
lines changed Original file line number Diff line number Diff line change @@ -23,33 +23,11 @@ It does so by
23
23
When type specs are added the program is checked against
24
24
these specs statically. The more type specs, the more static typing.
25
25
26
- An example is worth more than a thousand words:
26
+ A picture is worth more than a thousand words:
27
27
28
- ``` erlang
29
- 1 - module (exhaustive_type ).
30
- 2
31
- 3 - export ([allergen_score / 1 ]).
32
- 4
33
- 5 - type allergen () :: eggs
34
- 6 | chocolate
35
- 7 | pollen
36
- 8 | cats .
37
- 9
38
- 10 - spec allergen_score (allergen ()) -> integer ().
39
- 11 allergen_score (Al ) ->
40
- 12 case Al of
41
- 13 eggs -> 1 ;
42
- 14 chocolate -> 32 ;
43
- 15 pollen -> 64
44
- 16 end .
45
- ```
28
+ [ ![ ] ( screenshots/exhaustive_type.png ) ![ ] ( doc/screenshots/exhaustive_type.png )] [ examples ]
46
29
47
- ```
48
- $ gradualizer test/should_fail/exhaustive_type.erl
49
- test/should_fail/exhaustive_type.erl: Nonexhaustive patterns on line 13 at column 9
50
- Example values which are not covered:
51
- cats
52
- ```
30
+ [ examples ] : https://github.com/erszcz/Gradualizer/blob/release-0.2.0/doc/examples.md
53
31
54
32
55
33
## Usage
Original file line number Diff line number Diff line change
1
+ # Some examples of Gradualizer in action
2
+
3
+ ![ An example Gradualizer exhaustiveness checking diagnostic] ( screenshots/exhaustive_type.png )
4
+
5
+ Here's the same example in text for copy-pasting:
6
+
7
+ ``` erlang
8
+ 1 - module (exhaustive_type ).
9
+ 2
10
+ 3 - export ([allergen_score / 1 ]).
11
+ 4
12
+ 5 - type allergen () :: eggs
13
+ 6 | chocolate
14
+ 7 | pollen
15
+ 8 | cats .
16
+ 9
17
+ 10 - spec allergen_score (allergen ()) -> integer ().
18
+ 11 allergen_score (Al ) ->
19
+ 12 case Al of
20
+ 13 eggs -> 1 ;
21
+ 14 chocolate -> 32 ;
22
+ 15 pollen -> 64
23
+ 16 end .
24
+ ```
25
+
26
+ ```
27
+ $ gradualizer test/should_fail/exhaustive_type.erl
28
+ test/should_fail/exhaustive_type.erl: Nonexhaustive patterns on line 13 at column 9
29
+ Example values which are not covered:
30
+ cats
31
+ ```
32
+
33
+ [ ErlangLS] ( https://github.com/erlang-ls/erlang_ls ) integration example:
34
+
35
+ ![ Gradualizer diagnostics with ErlangLS] ( screenshots/134913123-4700b299-2714-4227-b7e2-f8c816b138a5.gif )
You can’t perform that action at this time.
0 commit comments