1
1
module Core.Options.Log
2
2
3
- import Data.List
3
+ import public Data . List
4
4
import Data.List1
5
- import Data.Maybe
5
+ import public Data . Maybe
6
6
import Libraries.Data.StringMap
7
7
import Libraries.Data.StringTrie
8
8
import Data.Strings
@@ -34,6 +34,126 @@ import Libraries.Text.PrettyPrint.Prettyprinter
34
34
-- --------------------------------------------------------------------------------
35
35
-- INDIVIDUAL LOG LEVEL
36
36
37
+ public export
38
+ knownTopics : List (String,String)
39
+ knownTopics = [
40
+ (" auto" , " some documentation of this option" ),
41
+ (" builtin.Natural" , " some documentation of this option" ),
42
+ (" builtin.Natural.addTransform" , " some documentation of this option" ),
43
+ (" builtin.NaturalToInteger" , " some documentation of this option" ),
44
+ (" builtin.NaturalToInteger.addTransforms" , " some documentation of this option" ),
45
+ (" compile.casetree" , " some documentation of this option" ),
46
+ (" compiler.inline.eval" , " some documentation of this option" ),
47
+ (" compiler.refc" , " some documentation of this option" ),
48
+ (" compiler.refc.cc" , " some documentation of this option" ),
49
+ (" compiler.scheme.chez" , " some documentation of this option" ),
50
+ (" coverage" , " some documentation of this option" ),
51
+ (" coverage.empty" , " some documentation of this option" ),
52
+ (" coverage.missing" , " some documentation of this option" ),
53
+ (" coverage.recover" , " some documentation of this option" ),
54
+ (" declare.data" , " some documentation of this option" ),
55
+ (" declare.data.constructor" , " some documentation of this option" ),
56
+ (" declare.data.parameters" , " some documentation of this option" ),
57
+ (" declare.def" , " some documentation of this option" ),
58
+ (" declare.def.clause" , " some documentation of this option" ),
59
+ (" declare.def.clause.impossible" , " some documentation of this option" ),
60
+ (" declare.def.clause.with" , " some documentation of this option" ),
61
+ (" declare.def.impossible" , " some documentation of this option" ),
62
+ (" declare.def.lhs" , " some documentation of this option" ),
63
+ (" declare.def.lhs.implicits" , " some documentation of this option" ),
64
+ (" declare.param" , " some documentation of this option" ),
65
+ (" declare.record" , " some documentation of this option" ),
66
+ (" declare.record.field" , " some documentation of this option" ),
67
+ (" declare.record.projection" , " some documentation of this option" ),
68
+ (" declare.record.projection.prefix" , " some documentation of this option" ),
69
+ (" declare.type" , " some documentation of this option" ),
70
+ (" desugar.idiom" , " some documentation of this option" ),
71
+ (" doc.record" , " some documentation of this option" ),
72
+ (" elab" , " some documentation of this option" ),
73
+ (" elab.ambiguous" , " some documentation of this option" ),
74
+ (" elab.app.lhs" , " some documentation of this option" ),
75
+ (" elab.as" , " some documentation of this option" ),
76
+ (" elab.bindnames" , " some documentation of this option" ),
77
+ (" elab.binder" , " some documentation of this option" ),
78
+ (" elab.case" , " some documentation of this option" ),
79
+ (" elab.def.local" , " some documentation of this option" ),
80
+ (" elab.delay" , " some documentation of this option" ),
81
+ (" elab.hole" , " some documentation of this option" ),
82
+ (" elab.implicits" , " some documentation of this option" ),
83
+ (" elab.implementation" , " some documentation of this option" ),
84
+ (" elab.interface" , " some documentation of this option" ),
85
+ (" elab.interface.default" , " some documentation of this option" ),
86
+ (" elab.local" , " some documentation of this option" ),
87
+ (" elab.prun" , " some documentation of this option" ),
88
+ (" elab.prune" , " some documentation of this option" ),
89
+ (" elab.record" , " some documentation of this option" ),
90
+ (" elab.retry" , " some documentation of this option" ),
91
+ (" elab.rewrite" , " some documentation of this option" ),
92
+ (" elab.unify" , " some documentation of this option" ),
93
+ (" elab.update" , " some documentation of this option" ),
94
+ (" elab.with" , " some documentation of this option" ),
95
+ (" eval.casetree" , " some documentation of this option" ),
96
+ (" eval.casetree.stuck" , " some documentation of this option" ),
97
+ (" eval.eta" , " some documentation of this option" ),
98
+ (" eval.stuck" , " some documentation of this option" ),
99
+ (" idemode.hole" , " some documentation of this option" ),
100
+ (" ide-mode.highlight" , " some documentation of this option" ),
101
+ (" ide-mode.highlight.alias" , " some documentation of this option" ),
102
+ (" ide-mode.send" , " some documentation of this option" ),
103
+ (" import" , " some documentation of this option" ),
104
+ (" import.file" , " some documentation of this option" ),
105
+ (" interaction.casesplit" , " some documentation of this option" ),
106
+ (" interaction.generate" , " some documentation of this option" ),
107
+ (" interaction.search" , " some documentation of this option" ),
108
+ (" metadata.names" , " some documentation of this option" ),
109
+ (" module.hash" , " some documentation of this option" ),
110
+ (" quantity" , " some documentation of this option" ),
111
+ (" quantity.hole" , " some documentation of this option" ),
112
+ (" quantity.hole.update" , " some documentation of this option" ),
113
+ (" repl.eval" , " some documentation of this option" ),
114
+ (" specialise" , " some documentation of this option" ),
115
+ (" totality" , " some documentation of this option" ),
116
+ (" totality.positivity" , " some documentation of this option" ),
117
+ (" totality.termination" , " some documentation of this option" ),
118
+ (" totality.termination.calc" , " some documentation of this option" ),
119
+ (" totality.termination.guarded" , " some documentation of this option" ),
120
+ (" totality.termination.sizechange" , " some documentation of this option" ),
121
+ (" totality.termination.sizechange.checkCall" , " some documentation of this option" ),
122
+ (" totality.termination.sizechange.checkCall.inPath" , " some documentation of this option" ),
123
+ (" totality.termination.sizechange.checkCall.inPathNot.restart" , " some documentation of this option" ),
124
+ (" totality.termination.sizechange.checkCall.inPathNot.return" , " some documentation of this option" ),
125
+ (" totality.termination.sizechange.inPath" , " some documentation of this option" ),
126
+ (" totality.termination.sizechange.isTerminating" , " some documentation of this option" ),
127
+ (" totality.termination.sizechange.needsChecking" , " some documentation of this option" ),
128
+ (" transform.lhs" , " some documentation of this option" ),
129
+ (" transform.rhs" , " some documentation of this option" ),
130
+ (" ttc.read" , " some documentation of this option" ),
131
+ (" ttc.write" , " some documentation of this option" ),
132
+ (" typesearch.equiv" , " some documentation of this option" ),
133
+ (" unelab.case" , " some documentation of this option" ),
134
+ (" unify" , " some documentation of this option" ),
135
+ (" unify.application" , " some documentation of this option" ),
136
+ (" unify.binder" , " some documentation of this option" ),
137
+ (" unify.constant" , " some documentation of this option" ),
138
+ (" unify.constraint" , " some documentation of this option" ),
139
+ (" unify.delay" , " some documentation of this option" ),
140
+ (" unify.equal" , " some documentation of this option" ),
141
+ (" unify.head" , " some documentation of this option" ),
142
+ (" unify.hole" , " some documentation of this option" ),
143
+ (" unify.instantiate" , " some documentation of this option" ),
144
+ (" unify.invertible" , " some documentation of this option" ),
145
+ (" unify.meta" , " some documentation of this option" ),
146
+ (" unify.noeta" , " some documentation of this option" ),
147
+ (" unify.postpone" , " some documentation of this option" ),
148
+ (" unify.retry" , " some documentation of this option" ),
149
+ (" unify.search" , " some documentation of this option" ),
150
+ (" unify.unsolved" , " some documentation of this option" )
151
+ ]
152
+
153
+ public export
154
+ KnownTopic : String -> Type
155
+ KnownTopic s = IsJust (lookup s knownTopics)
156
+
37
157
||| An individual log level is a pair of a list of non-empty strings and a number.
38
158
||| We keep the representation opaque to force users to call the smart constructor
39
159
export
@@ -49,11 +169,24 @@ mkLogLevel' ps n = MkLogLevel (maybe [] forget ps) n
49
169
||| The smart constructor makes sure that the empty string is mapped to the empty
50
170
||| list. This bypasses the fact that the function `split` returns a non-empty
51
171
||| list no matter what.
172
+ |||
173
+ ||| However, invoking this function comes without guarantees that
174
+ ||| the passed string corresponds to a known topic. For this,
175
+ ||| use `mkLogLevel`.
176
+ |||
177
+ ||| Use this function to create user defined loglevels, for instance, during
178
+ ||| elaborator reflection.
179
+ export
180
+ mkUnverifiedLogLevel : Bool -> (s : String) -> Nat -> LogLevel
181
+ mkUnverifiedLogLevel False _ = mkLogLevel' Nothing
182
+ mkUnverifiedLogLevel _ " " = mkLogLevel' Nothing
183
+ mkUnverifiedLogLevel _ ps = mkLogLevel' (Just (split (== ' .' ) ps))
184
+
185
+ ||| Like `mkUnverifiedLogLevel` but with a compile time check that
186
+ ||| the passed string is a known topic.
52
187
export
53
- mkLogLevel : Bool -> String -> Nat -> LogLevel
54
- mkLogLevel False _ = mkLogLevel' Nothing
55
- mkLogLevel _ " " = mkLogLevel' Nothing
56
- mkLogLevel _ ps = mkLogLevel' (Just (split (== ' .' ) ps))
188
+ mkLogLevel : Bool -> (s : String) -> {auto 0 _ : KnownTopic s} -> Nat -> LogLevel
189
+ mkLogLevel b s = mkUnverifiedLogLevel b s
57
190
58
191
||| The unsafe constructor should only be used in places where the topic has already
59
192
||| been appropriately processed.
@@ -99,7 +232,7 @@ parseLogLevel str = do
99
232
ns = tail nns in
100
233
case ns of
101
234
[] => pure (MkLogLevel [], n)
102
- [ns] => pure (mkLogLevel True n, ns)
235
+ [ns] => pure (mkUnverifiedLogLevel True n, ns)
103
236
_ => Nothing
104
237
lvl <- parsePositive n
105
238
pure $ c (fromInteger lvl)
0 commit comments