0 | module Lana.AnyJSON
 1 |
 2 | -- This is only necessary because of some transitive import bug
 3 | import Data.List.Quantifiers as Bug
 4 | import Data.List.Elem
 5 |
 6 | import Data.SortedMap
 7 | import Lana.Class
 8 | import Lana.Name
 9 | import Lana.Schemas
10 |
11 | data AnyJSON
12 |   = MkAnyJSON
13 |       ( Union
14 |           [ String
15 |           , Bool
16 |           --, Scientific
17 |           , List AnyJSON
18 |           , SortedMap String AnyJSON
19 |           , Null
20 |           ]
21 |       )
22 |
23 | mutual
24 |   anyJSON : {schema: Type -> Type} ->
25 |             Lana schema =>
26 |             schema AnyJSON
27 |   anyJSON =
28 |     transformNamed (unqualifiedName "AnyJSON") (\(MkAnyJSON u) => u) MkAnyJSON $
29 |       unionNamed (unqualifiedName "AnyJSON") $
30 |         unionMemberWithIndex Here text
31 |           #| unionMemberWithIndex (There Here) boolean
32 |           -- #| unionMemberWithIndex ?bool number
33 |           #| unionMemberWithIndex (There $ There Here) anyArray
34 |           #| unionMemberWithIndex (There $ There $ There Here) anyObject
35 |           #| unionMemberWithIndex (There $ There $ There $ There Here) Lana.Class.null
36 |
37 |   anyArray : {schema: Type -> Type} -> Lana schema => schema (List AnyJSON)
38 |   anyArray =
39 |     array anyJSON
40 |
41 |   anyObject : {schema: Type -> Type} -> Lana schema => schema (SortedMap String AnyJSON)
42 |   anyObject =
43 |     objectNamed {schema} (unqualifiedName "AnyJSON object") $
44 |       constructor id
45 |         #* additionalFields id anyJSON
46 |