GaBuZoMeu/Registry/registry2postgresql.hs

24 lines
666 B
Haskell

import qualified System.IO
import Registry.Utils
import Registry.Utils.PostgreSQL
import Registry.Grammar (registry)
import Registry.Registry
infile = "./language-subtag-registry"
displayAll reg thistype =
(foldr (++) "" (map toPostgreSQL
(filter (onlyThisType thistype) reg)))
main = do
f <- System.IO.openFile (infile) System.IO.ReadMode
input <- System.IO.hGetContents f
let theregistry = getRegistry input
putStrLn "BEGIN;"
putStrLn (displayAll theregistry "script")
putStrLn (displayAll theregistry "region")
putStrLn (displayAll theregistry "language")
putStrLn (displayAll theregistry "variant")
putStrLn "COMMIT;"