summaryrefslogtreecommitdiff
path: root/ddl/Generate.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ddl/Generate.hs')
-rw-r--r--ddl/Generate.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/ddl/Generate.hs b/ddl/Generate.hs
index 7e7d3ca..c407510 100644
--- a/ddl/Generate.hs
+++ b/ddl/Generate.hs
@@ -61,6 +61,13 @@ main = do
61 , "swiftType" @: swiftType aliasMap 61 , "swiftType" @: swiftType aliasMap
62 , "hasEnumConstructor" @: hasEnumConstructor 62 , "hasEnumConstructor" @: hasEnumConstructor
63 ] 63 ]
64 writeFileIfDiffer fname txt = doesFileExist fname >>= \case
65 False -> writeFile fname txt
66 True -> do
67 oldTxt <- readFile fname
68 case (lines oldTxt, lines txt) of
69 (_ : oldTime : old, _ : newTime : new) | old == new -> return () -- NOTE: timestamp is always in the second line
70 _ -> writeFile fname txt
64 71
65 -- Haskell 72 -- Haskell
66 either error (\x -> writeFile ("out/" ++ name ++ ".hs") $ LText.unpack x) $ dataHs >>= (\t -> eitherRenderWith mylib t env) 73 either error (\x -> writeFile ("out/" ++ name ++ ".hs") $ LText.unpack x) $ dataHs >>= (\t -> eitherRenderWith mylib t env)