summaryrefslogtreecommitdiff
path: root/examples/phrasebook/Update.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/phrasebook/Update.hs')
-rw-r--r--examples/phrasebook/Update.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/phrasebook/Update.hs b/examples/phrasebook/Update.hs
new file mode 100644
index 000000000..1e7cf2578
--- /dev/null
+++ b/examples/phrasebook/Update.hs
@@ -0,0 +1,23 @@
+import System
+
+main = do
+ file:_ <- getArgs
+ updates <- readFile file >= return . readUpdates
+ mapM_ (doUpdate file) updates
+ return ()
+
+type Update = (FilePath, [String])
+
+readUpdates :: String -> [Update]
+readUpdates s = []
+
+doUpdate :: FilePath -> Update -> IO ()
+doUpdate src (target,ls) = do
+ s <- readFile target
+ let beg = dropLastBracket s
+ let tmp = tmpFile target
+ writeFile tmp beg
+ appendFile tmp $ unlines [(line ++ "-- UPDATE FROM " ++ src) | line <- ls]
+ appendFile tmp "\n}\n"
+
+dropLastBracket s = s