GaBuZoMeu/check-valid.hs

23 lines
702 B
Haskell
Raw Permalink Normal View History

2023-06-08 21:49:35 +02:00
import Grammar
import System.Environment (getArgs)
import Registry.Registry
infile = "./language-subtag-registry"
2023-10-01 15:46:34 +02:00
analyze reg input = do
let theDate = dateOf (head reg)
case (getTag input) of
2023-06-08 21:49:35 +02:00
Left err -> err
Right tag -> let result = isValid reg tag in
if fst result then
2023-10-01 15:46:34 +02:00
(input ++ " is valid against registry " ++ theDate ++ "\n")
2023-06-08 21:49:35 +02:00
else
2023-10-01 15:46:34 +02:00
(input ++ " is NOT valid against registry " ++ theDate ++ ": " ++ snd result ++ "\n")
2023-06-08 21:49:35 +02:00
main = do
myargs <- getArgs
theregistry <- readRegistry infile
putStr (concat (map (analyze theregistry) myargs))