From 7c79aae07fede967931be8794e15a9388aad6c64 Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Fri, 4 Jun 2021 11:04:22 +0800 Subject: [PATCH] (Morphodict) use Safe's read for better error msg --- src/morphodict/MkMorphodict.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/morphodict/MkMorphodict.hs b/src/morphodict/MkMorphodict.hs index f70c360d..4af9f33d 100644 --- a/src/morphodict/MkMorphodict.hs +++ b/src/morphodict/MkMorphodict.hs @@ -41,7 +41,7 @@ main = do rawdata <- case mode of "pgf" -> pgfFile2rawData config datafile "raw" -> readFile datafile >>= return . map getRawData . filter (not . null) . lines - _ -> putStrLn $ "Expected mode (pgf|raw), got " ++ mode + _ -> error $ "Expected mode (pgf|raw), got " ++ mode rawdata2gf config rawdata outfile @@ -94,8 +94,9 @@ mkConfig ls = M.fromList [(c,i) | Left (c,i) <- map mkOne (lines ls)] cat:":":tcat:oper:ints -> Left (cat,(tcat,oper,mkArgs ints)) _ -> Right s mkArgs ints = case break (=="#") ints of - (ss,[]) -> (map read ss, []) - (ss,_:fs) -> (map read ss, map read fs) + (ss,[]) -> (map read' ss, []) + (ss,_:fs) -> (map read' ss, map read' fs) + read' a = readNote [] a -- Safe.readNote provides better error message getRawData s = case words s of c:cs -> (c,cs)