File tree Expand file tree Collapse file tree 7 files changed +369
-59
lines changed Expand file tree Collapse file tree 7 files changed +369
-59
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ import Primer.API (
50
50
Selection (.. ),
51
51
Tree ,
52
52
)
53
+ import Primer.API qualified as API
53
54
import Primer.Action.Available qualified as Available
54
55
import Primer.App (NodeType )
55
56
import Primer.App.Base (Level )
@@ -59,6 +60,7 @@ import Primer.Core (
59
60
ID (.. ),
60
61
LVarName ,
61
62
ModuleName ,
63
+ PrimCon ,
62
64
)
63
65
import Primer.Database (
64
66
LastModified ,
@@ -121,6 +123,8 @@ deriving via GlobalName 'ADefName instance ToSchema (GlobalName 'AValCon)
121
123
122
124
deriving via Name instance (ToSchema LVarName )
123
125
deriving via PrimerJSON Tree instance ToSchema Tree
126
+ deriving via PrimerJSON API. Name instance ToSchema API. Name
127
+ deriving via PrimerJSON PrimCon instance ToSchema PrimCon
124
128
deriving via PrimerJSON NodeBody instance ToSchema NodeBody
125
129
deriving via PrimerJSON NodeFlavor instance ToSchema NodeFlavor
126
130
deriving via PrimerJSON Def instance ToSchema Def
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ import Primer.Database (
48
48
safeMkSessionName ,
49
49
)
50
50
import Primer.Gen.API (genExprTreeOpts )
51
+ import Primer.Gen.API qualified as API
51
52
import Primer.Gen.Core.Raw (
52
53
ExprGen ,
53
54
evalExprGen ,
@@ -171,7 +172,7 @@ tasty_NodeBody :: Property
171
172
tasty_NodeBody =
172
173
testToJSON $
173
174
G. choice
174
- [ TextBody <$> G. text ( R. linear 1 20 ) G. unicode
175
+ [ TextBody <$> API. genName
175
176
, BoxBody <$> genTree
176
177
, pure NoBody
177
178
]
Original file line number Diff line number Diff line change 232
232
],
233
233
"type" : " object"
234
234
},
235
+ "Name" : {
236
+ "properties" : {
237
+ "baseName" : {
238
+ "type" : " string"
239
+ },
240
+ "qualifiedModule" : {
241
+ "items" : {
242
+ "type" : " string"
243
+ },
244
+ "minItems" : 1 ,
245
+ "type" : " array"
246
+ }
247
+ },
248
+ "required" : [
249
+ " baseName"
250
+ ],
251
+ "type" : " object"
252
+ },
235
253
"NewSessionReq" : {
236
254
"properties" : {
237
255
"name" : {
270
288
{
271
289
"properties" : {
272
290
"contents" : {
273
- "type " : " string "
291
+ "$ref " : " #/components/schemas/Name "
274
292
},
275
293
"tag" : {
276
294
"enum" : [
285
303
],
286
304
"type" : " object"
287
305
},
306
+ {
307
+ "properties" : {
308
+ "contents" : {
309
+ "$ref" : " #/components/schemas/PrimCon"
310
+ },
311
+ "tag" : {
312
+ "enum" : [
313
+ " PrimBody"
314
+ ],
315
+ "type" : " string"
316
+ }
317
+ },
318
+ "required" : [
319
+ " tag" ,
320
+ " contents"
321
+ ],
322
+ "type" : " object"
323
+ },
288
324
{
289
325
"properties" : {
290
326
"contents" : {
484
520
],
485
521
"type" : " object"
486
522
},
523
+ "PrimCon" : {
524
+ "oneOf" : [
525
+ {
526
+ "properties" : {
527
+ "contents" : {
528
+ "example" : " ?" ,
529
+ "maxLength" : 1 ,
530
+ "minLength" : 1 ,
531
+ "type" : " string"
532
+ },
533
+ "tag" : {
534
+ "enum" : [
535
+ " PrimChar"
536
+ ],
537
+ "type" : " string"
538
+ }
539
+ },
540
+ "required" : [
541
+ " tag" ,
542
+ " contents"
543
+ ],
544
+ "type" : " object"
545
+ },
546
+ {
547
+ "properties" : {
548
+ "contents" : {
549
+ "type" : " integer"
550
+ },
551
+ "tag" : {
552
+ "enum" : [
553
+ " PrimInt"
554
+ ],
555
+ "type" : " string"
556
+ }
557
+ },
558
+ "required" : [
559
+ " tag" ,
560
+ " contents"
561
+ ],
562
+ "type" : " object"
563
+ }
564
+ ],
565
+ "type" : " object"
566
+ },
487
567
"Prog" : {
488
568
"properties" : {
489
569
"modules" : {
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE RecordWildCards #-}
2
+
1
3
module Primer.Gen.API (
2
4
genExprTreeOpts ,
5
+ genName ,
3
6
) where
4
7
5
8
import Foreword
6
9
7
10
import Hedgehog (MonadGen )
11
+ import Hedgehog.Gen qualified as G
8
12
import Hedgehog.Gen qualified as Gen
9
- import Primer.API (ExprTreeOpts (.. ))
13
+ import Hedgehog.Range qualified as R
14
+ import Primer.API (ExprTreeOpts (.. ), Name (.. ))
15
+ import Primer.Gen.Core.Raw qualified as Raw
16
+ import Primer.Name (unsafeMkName )
10
17
11
18
genExprTreeOpts :: MonadGen m => m ExprTreeOpts
12
19
genExprTreeOpts = do
13
20
patternsUnder <- Gen. bool
14
21
pure ExprTreeOpts {patternsUnder}
22
+
23
+ genName :: MonadGen m => m Name
24
+ genName = do
25
+ baseName <- unsafeMkName <$> G. text (R. linear 1 20 ) G. unicode
26
+ qualifiedModule <- G. maybe Raw. genModuleName
27
+ pure Name {.. }
You can’t perform that action at this time.
0 commit comments