@@ -89,25 +89,26 @@ getType :: Global -> AST TType
89getType g = loc "getType" g $ memo typed g go
89getType g = loc "getType" g $ memo typed g go
91 go s = case s of
91 go s = case s of
92− SAny {} -> may (TType "JSONValue")
92+ SAny {} -> res (TType "JSONValue")
93− SRef _ r -> unmay <$> getType (ref r)
93+ SRef _ r -> req <$> getType (ref r)
94 --- FIXME: add natural/numeric manipulations
94 --- FIXME: add natural/numeric manipulations
95− SLit i l -> may (lit i l)
95+ SLit i l -> res (TLit l)
96− SEnm {} -> may (TType g)
96+ SEnm {} -> res (TType g)
97− SArr _ (Arr e) -> (TList <$> (getType e)) >>= may
97+ SArr _ (Arr e) -> (TList <$> (getType e)) >>= pure . may
98− SObj {} -> may (TType g)
98+ SObj {} -> res (TType g)
100− lit i l
100+ res = pure . may . rep
101− | i ^. iRepeated = TList (TLit l)
102− | otherwise = TLit l
104− may | required s = pure
102+ may | required s = id
105− | defaulted s = pure
103+ | defaulted s = id
106− | otherwise = pure . TMaybe
104+ | otherwise = TMaybe
108− unmay (TMaybe x)
106+ req (TMaybe x)
109 | required s = x
107 | required s = x
110− unmay x = x
108+ req x = x
110+ rep | s ^. iRepeated = TList
112getDerive :: Global -> AST [Derive]
113getDerive :: Global -> AST [Derive]
113getDerive g = loc "getDerive" g $ memo derived g go
114getDerive g = loc "getDerive" g $ memo derived g go