diff options
| author | odanoburu <bcclaro@gmail.com> | 2018-06-20 12:33:05 -0300 |
|---|---|---|
| committer | odanoburu <bcclaro@gmail.com> | 2018-06-20 12:33:05 -0300 |
| commit | f0672679535e59c53ed68729bbb5a201ce507b02 (patch) | |
| tree | 839216d85c207fc4d8fc0565466899ff4a41d5b1 /examples/slowApp/MissApp.hs | |
| parent | 8b05ed9469a970590e1b11cc4e83320d8b94e846 (diff) | |
| parent | 427f8d84788fc3757fb4dacda931c878bf253fa1 (diff) | |
Merge remote-tracking branch 'upstream/master' into por
Diffstat (limited to 'examples/slowApp/MissApp.hs')
| -rw-r--r-- | examples/slowApp/MissApp.hs | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/examples/slowApp/MissApp.hs b/examples/slowApp/MissApp.hs deleted file mode 100644 index c5faa41ff..000000000 --- a/examples/slowApp/MissApp.hs +++ /dev/null @@ -1,54 +0,0 @@ -module MissApp where - -import qualified Data.Set as S -import qualified Data.Map as M -import Data.Char - --- prerequisite: pg -missing | wf -file=missing-app.txt - -missFile = "missing-app.txt" - -allLangs = words "AppBul AppCat AppChi AppDut AppEng AppFin AppFre AppGer AppHin AppIta AppSpa AppSwe" - -type Lang = String -type Fun = String - -type MissMap = M.Map Lang (S.Set Fun) - -getMissMap :: FilePath -> IO MissMap -getMissMap file = do - ms <- readFile file >>= return . map words . lines - return $ M.fromList [(lang,S.fromList ws) | lang:":":ws <- ms] - -ifMiss :: MissMap -> Lang -> Fun -> Bool -ifMiss mm lang fun = case M.lookup lang mm of - Just ws -> S.member fun ws - _ -> error $ "language not found: " ++ lang - -allMissLangs :: MissMap -> Fun -> [Lang] -allMissLangs mm fun = [l | l <- allLangs, ifMiss mm l fun] - -allMissFuns :: MissMap -> Lang -> [Fun] -allMissFuns mm lang = maybe [] S.toList $ M.lookup lang mm - -isSyntaxFun :: Fun -> Bool -isSyntaxFun (f:un) = isUpper f && any isUpper un -- the latter to exclude Phrasebook - -allMissingSyntaxFuns :: MissMap -> [(Lang,[Fun])] -allMissingSyntaxFuns mm = [(l,takeWhile isSyntaxFun $ allMissFuns mm l) | l <- allLangs] -- takeWhile works on the sorted list - -allMissingSuchFuns :: MissMap -> (Fun -> Bool) -> [(Lang,[Fun])] -allMissingSuchFuns mm f = [(l,filter f $ allMissFuns mm l) | l <- allLangs] - -allMissingThoseFuns :: MissMap -> [Fun] -> [(Lang,[Fun])] -allMissingThoseFuns mm fs = let s = S.fromList fs in allMissingSuchFuns mm (flip S.member s) - -parts :: Fun -> [String] -parts f = words (map (\c -> if c =='_' then ' ' else c) f) - -catOf :: Fun -> String -catOf = last . parts - -prepareMissing :: MissMap -> Lang -> String -> IO () -prepareMissing mm lang cat = putStrLn $ unlines - [ "lin " ++ p ++ " = mk" ++ cat ++ " \"\" ;"| (l,ps) <- allMissingSuchFuns mm (\f -> catOf f == cat), l == lang, p <- ps] |
