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