import qualified System.IO import Registry.Utils import Registry.Grammar (registry) import Registry.Registry infile = "./language-subtag-registry" displayAll reg thistype = (foldr (++) "" (map toString (filter (onlyThisType thistype) reg))) displayOne reg thistype thisvalue = concat (map toString (filter (onlyThisValue thistype thisvalue) reg)) toTextFile reg thetype = do -- TODO: add the date in the filename let outfile = "lsr-" ++ thetype ++ ".txt" f <- System.IO.openFile (outfile) System.IO.WriteMode System.IO.hPutStr f (displayAll reg thetype) System.IO.hClose f foreach [] func = return () foreach a func = do func (head a) foreach (tail a) func main = do f <- System.IO.openFile (infile) System.IO.ReadMode input <- System.IO.hGetContents f let theregistry = getRegistry input foreach ["language", "script", "region", "variant", "redundant", "grandfathered"] (toTextFile theregistry)