on develop help sign in
Tweaking repeated parameter types
b8f5fd5Brendan Hay
gen/src/Gen/AST/Solve.hs+15−14
@@ -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
90 where
90 where
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)
99 where
99 where
100− lit i l
100+ res = pure . may . rep
101− | i ^. iRepeated = TList (TLit l)
102− | otherwise = TLit l
103
101
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
107
105
108− unmay (TMaybe x)
106+ req (TMaybe x)
109 | required s = x
107 | required s = x
110− unmay x = x
108+ req x = x
109+
110+ rep | s ^. iRepeated = TList
111+ | otherwise = id
111
112
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
gen/src/Gen/Syntax.hs+2
@@ -205,9 +205,11 @@ googleRequestDecl g n assoc alt p api url fields m pat prec =
205 where
205 where
206 go l = case Map.lookup l ps of
206 go l = case Map.lookup l ps of
207 Just p | _pLocation p == Query
207 Just p | _pLocation p == Query
208+ , not (required p)
208 , p ^. iRepeated -> infixApp (v l) "^." (var "_Default")
209 , p ^. iRepeated -> infixApp (v l) "^." (var "_Default")
209
210
210 Just p | _pLocation p == Query
211 Just p | _pLocation p == Query
212+ , not (p ^. iRepeated)
211 , parameter p || defaulted p -> app (var "Just") (v l)
213 , parameter p || defaulted p -> app (var "Just") (v l)
212
214
213 _ -> v l
215 _ -> v l
gen/src/Gen/Text.hs+2
@@ -209,6 +209,7 @@ upperAcronym x = Fold.foldl' (flip (uncurry RE.replaceAll)) x xs
209 , ("Dto", "DTO")
209 , ("Dto", "DTO")
210 , ("Sku", "SKU")
210 , ("Sku", "SKU")
211 , ("Cse$", "CSE")
211 , ("Cse$", "CSE")
212+ , ("Gan$", "GAN")
212
213
213 , ("access", "Access")
214 , ("access", "Access")
214 , ("account", "Account")
215 , ("account", "Account")
@@ -251,6 +252,7 @@ upperAcronym x = Fold.foldl' (flip (uncurry RE.replaceAll)) x xs
251 , ("crawl", "Crawl")
252 , ("crawl", "Crawl")
252 , ("error", "Error")
253 , ("error", "Error")
253 , ("sample", "Sample")
254 , ("sample", "Sample")
255+ , ("session", "Session")
254 ]
256 ]
255
257
256acronyms :: [(String, String)]
258acronyms :: [(String, String)]