on develop help sign in
W
commit2adb278a785bdc5c583adb36420761431d654501 authorBrendan Hay <brendan.g.hay@gmail.com> dateSun 27 Sep 2015, 09:32 (11 years ago) parentce441a1
1 file changed+3−24
gen/src/Gen/Syntax.hs+3−24
gen/src/Gen/Syntax.hs+3−24
@@ -84,13 +84,13 @@ verbDecl s p l m = TypeDecl noLoc (vname p l) [] alias
8484 res = maybe (tycon "()") (tycon . Free) (_mResponse m)
8585
8686jsonDecls :: Id -> Pre -> Map Local Solved -> [Decl]
87−jsonDecls n p rs = [from, to]
87+jsonDecls n p (Map.toList -> rs) = [from, to]
8888 where
8989 from = InstDecl noLoc Nothing [] [] (unqual "FromJSON") [tycon n]
9090 [ funD "parseJSON" $
9191 app (app (var "withObject") (str (idToText n))) $
9292 lamE noLoc [pvar "o"] $
93− ctorE n (map decode (Map.toList rs))
93+ ctorE n (map decode rs)
9494 ]
9595
9696 decode (l, s)
@@ -100,7 +100,7 @@ jsonDecls n p rs = [from, to]
100100 | otherwise = optJS l
101101
102102 to = InstDecl noLoc Nothing [] [] (unqual "ToJSON") [tycon n]
103− [ wildcardD "toJSON" n omit none (map encode (Map.toList rs))
103+ [ wildcardD "toJSON" n omit none (map encode rs)
104104 ]
105105
106106 omit = app (var "object")
@@ -155,27 +155,6 @@ seqE :: Exp -> [Exp] -> Exp
155155seqE l [] = app (var "pure") l
156156seqE l (r:rs) = infixApp l "<$>" (infixE r "<*>" rs)
157157
158−-- toJSOND :: Protocol -> Id -> [Field] -> Decl
159−-- toJSOND p n = instD1 "ToJSON" n
160−-- . wildcardD n "toJSON" enc (paren $ app (var "Object") memptyE)
161−-- . map (Right . toJSONE p)
162−-- where
163−-- enc = app (var "object")
164−-- . app (var "catMaybes")
165−-- . listE
166−-- . map (either id id)
167−
168−-- instD1 :: Text -> Id -> InstDecl -> Decl
169−-- instD1 c n = instD c n . (:[])
170−
171−-- instD :: Text -> Id -> [InstDecl] -> Decl
172−-- instD c n = InstDecl noLoc Nothing [] [] (unqual c) [tycon (typeId n)]
173−
174−-- memptyE :: Exp
175−-- memptyE = var "mempty"
176−
177−
178−
179158objDecl :: Id -> Pre -> Map Local Solved -> AST Decl
180159objDecl n p rs = DataDecl noLoc arity [] d [] [conDecl d p rs] <$> derivings n
181160 where