mmsyn4 0.4.0.0 → 0.5.0.0
raw patch · 3 files changed
+37/−11 lines, 3 filesdep ~mmsyn2PVP ok
version bump matches the API change (PVP)
Dependency ranges changed: mmsyn2
API changes (from Hackage documentation)
Files
- ChangeLog.md +6/−0
- MMSyn4.hs +28/−8
- mmsyn4.cabal +3/−3
ChangeLog.md view
@@ -62,3 +62,9 @@ * Fourth version. Added the new command line arguments "-y", "-s...", "-b..." to specify whether to remove the '@' markers, which option is used to splines GraphViz functionality and what is the basic name for the created files respectively. For this changed the functions. Some documentation additions respectively.++## 0.5.0.0 -- 2020-10-29++* Fifth version. Changed the inlining policies. Some minor code improvements. Boundaries changes for dependencies.++
MMSyn4.hs view
@@ -43,6 +43,7 @@ -- | Returns @True@ if OS is Windows. isWindows :: Bool isWindows = take 5 os == "mingw" +{-# INLINE isWindows #-} divideString :: (Char -> Bool) -> String -> [String] divideString p xs @@ -60,16 +61,20 @@ cells :: String -> V.Vector [String] cells = V.map (divideString isSep) . V.fromList . dropEmptyLines . map (\rs -> if drop (length rs - 1) rs == "\r" then init rs else rs) . lines+{-# INLINE cells #-} processCells :: String -> V.Vector [String] -> String processCells xs v = makeRecordGv xs . convertElemsToStringGv . filterNeeded . changeNeededCells $ v+{-# INLINE processCells #-} processCellsG :: String -> String -> String processCellsG xs = processCells xs . cells+{-# INLINE processCellsG #-} -- | Do not change the lengths of element lists changeNeededCells :: V.Vector [String] -> V.Vector [String] changeNeededCells v = V.generate (V.length v) (\i -> changeLine i v)+{-# INLINE changeNeededCells #-} -- | Changes every line by changing (if needed) one empty String to the needed one non-empty. It is necessary for this to find the parent cell for the -- line in the previous elements of the 'V.Vector'. The contents of the cell (if exist) are substituted instead of the empty 'String' in the line being @@ -78,6 +83,7 @@ changeLine i v = let n = length . takeWhile null . V.unsafeIndex v $ i xs = parentCellContents n i v in if null xs then drop n . V.unsafeIndex v $ i else xs:(drop n . V.unsafeIndex v $ i)+{-# NOINLINE changeLine #-} parentCellContents :: Int -> Int -> V.Vector [String] -> String parentCellContents n i v @@ -87,6 +93,7 @@ -- | Change the lengths of element lists by dropping the last empty strings in every element. filterNeeded :: V.Vector [String] -> V.Vector [String] filterNeeded = V.map (takeWhile (not . null))+{-# INLINE filterNeeded #-} -- | Makes conversion for every line convertElemsToStringGv :: V.Vector [String] -> V.Vector String@@ -94,27 +101,33 @@ convertLineToStrGv :: [String] -> String convertLineToStrGv xss = "\"" ++ (let ys = concatMap (++"\"->\"") xss in take (length ys - 3) ys) ++ endOfLineGv+{-# INLINE convertLineToStrGv #-} endOfLineGv :: String endOfLineGv | isWindows = "\r\n" | otherwise = "\n"+{-# INLINE endOfLineGv #-} findAndMakeFilledWithClr :: V.Vector [String] -> V.Vector String findAndMakeFilledWithClr = V.singleton . concatMap (('\"':) . (++ "\" [style=filled, fillcolor=\"#ffffba\"];" ++ endOfLineGv)) . nub . mconcat . V.toList . V.map lineWithAtSign+{-# INLINE findAndMakeFilledWithClr #-} -- | In every list (representing a line) returns only those strings that begin with at-sign. lineWithAtSign :: [String] -> [String] lineWithAtSign = filter beginsWithAtSign+{-# INLINE lineWithAtSign #-} beginsWithAtSign :: String -> Bool beginsWithAtSign xs = if take 1 xs == "@" then True else take 2 xs == "\"@" +{-# INLINE beginsWithAtSign #-} -- | Makes all needed additions and synthesizes into a single String ready to be recorded to the .gv file. makeRecordGv :: String -> V.Vector String -> String makeRecordGv xs v = mconcat ["strict digraph 1 {", endOfLineGv, "overlap=false", endOfLineGv, "splines=", getBFst' ("true", V.fromList [("0", "false"), ("1", "true"), ("2", "ortho"), ("3", "polyline")]) xs, endOfLineGv, mconcat . V.toList $ v, "}", endOfLineGv]+{-# INLINE makeRecordGv #-} -- | Processes the given text (the first 'String' argument). The second one is used to get a name of the command to be -- executed to obtain a visualization file. The third argument is used for the 'getFormat'. The fourth argument is the @@ -124,16 +137,16 @@ process2 text xxs yys bnames splines remAts | length text > 0 = do ts <- getCPUTime- [bnames,splines] <- proc2Params2 bnames splines+ [bnames1,splines1] <- proc2Params2 bnames splines if remAts == "y" then do - let ys = filter (/='@') . processCellsG splines $ text in writeFile (show ts ++ "." ++ bnames ++ ".gv") ys+ let ys = filter (/='@') . processCellsG splines1 $ text in writeFile (show ts ++ "." ++ bnames1 ++ ".gv") ys putStrLn "The visualization will be created without the at-sign."- processFile 'n' ts bnames xxs yys+ processFile 'n' ts bnames1 xxs yys else do - let ys = processCellsG splines text in writeFile ("at." ++ show ts ++ "." ++ bnames ++ ".gv") ys+ let ys = processCellsG splines1 text in writeFile ("at." ++ show ts ++ "." ++ bnames1 ++ ".gv") ys putStrLn "The visualization will be created with the at-sign preserved."- processFile 'a' ts bnames xxs yys+ processFile 'a' ts bnames1 xxs yys | otherwise = error "Empty text to be processed! " procCtrl :: Int -> IO String@@ -153,6 +166,7 @@ if all (isJust . showE) ["fdp","twopi","circo","neato","sfdp","dot","patchwork","osage"] then processFile1 w t zs xxs yys else error "MMSyn4.processFile: Please, install the GraphViz so that its executables are in the directories mentioned in the variable PATH!"+{-# INLINE processFile #-} processFile1 :: Char -> Integer -> String -> String -> String -> IO () processFile1 w t zs xxs yys = do @@ -171,6 +185,7 @@ | null xxs = if null yys then mapM getFormat1 [1,2] else do { vs <- getFormat1 1 ; return [vs,yys] } | null yys = do { spec <- getFormat1 2 ; return [xxs,spec] } | otherwise = return [xxs,yys]+{-# INLINE proc2Params #-} specFormatFile :: IO String specFormatFile = do@@ -178,12 +193,14 @@ mapM_ printFormF ["do", "xd", "ps", "pd", "sv", "sz", "fi", "pn", "gi", "jp", "je", "js", "im", "cm"] putStrLn "otherwise there will be used the default -Tsvg" getLine+{-# INLINE specFormatFile #-} proc2Params2 :: String -> String -> IO [String] proc2Params2 bnames splines - | null bnames = if null splines then mapM procCtrl [1,2] else do { bnames <- procCtrl 1 ; return [bnames,splines] }- | null splines = do { splines <- procCtrl 2 ; return [bnames,splines] }+ | null bnames = if null splines then mapM procCtrl [1,2] else do { bnames1 <- procCtrl 1 ; return [bnames1,splines] }+ | null splines = do { splines1 <- procCtrl 2 ; return [bnames,splines1] } | otherwise = return [bnames,splines]+{-# INLINE proc2Params2 #-} getFormat1 :: Int -> IO String getFormat1 1 = do @@ -192,18 +209,21 @@ putStrLn "otherwise there will be used the default sfdp" getLine getFormat1 _ = specFormatFile +{-# INLINE getFormat1 #-} -- | For the given argument (usually of two characters) return the full form of the file format to be generated by GraphViz and @mmsyn4@. The default one -- is \"svg\". getFormat :: String -> String getFormat = getBFst' ("svg",V.fromList [("cm", "cmapx"),("do", "dot"),("fi", "fig"),("gi", "gif"),("im", "imap"), ("je", "jpeg"),("jp", "jpg"),("js", "json"),("pd", "pdf"),("pn", "png"),("ps", "ps"),("sv", "svg"),("sz", "svgz"),("xd", "xdot")])+{-# INLINE getFormat #-} printFormF :: String -> IO () printFormF xs = putStrLn $ show xs ++ " -- for -T" ++ getBFst' ("svg",V.fromList [("cm", "cmapx"),("do", "dot"),("fi", "fig"),("gi", "gif"),("im", "imap"), ("je", "jpeg"),("jp", "jpg"),("js", "json"),("pd", "pdf"),("pn", "png"),("ps", "ps"),("sv", "svg"),("sz", "svgz"),("xd", "xdot")]) xs ++ "\""+{-# INLINE printFormF #-} printGraphFilter :: String -> IO () printGraphFilter xs = putStrLn $ show (take 1 xs) ++ " -- for " ++ getBFst' ("sfdp", V.fromList [("c", "circo"), ("d", "dot"), ("f", "fdp"), ("n", "neato"), ("o", "osage"), ("p", "patchwork"), ("s", "sfdp"), ("t", "twopi")]) (take 1 xs)-+{-# INLINE printGraphFilter #-}
mmsyn4.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: mmsyn4-version: 0.4.0.0+version: 0.5.0.0 synopsis: The "glue" between electronic tables and GraphViz description: The program mmsyn4 converts a specially formated .csv file with a colon as a field separator obtained from the electronic table into a visualized by GraphViz graph. homepage: https://hackage.haskell.org/package/mmsyn4@@ -20,7 +20,7 @@ exposed-modules: Main, MMSyn4 -- other-modules: other-extensions: CPP- build-depends: base >=4.7 && <4.15, directory >=1 && <1.5, process >=1.2 && <1.8, mmsyn2 >=0.1.8 && <0.2, vector >=0.11 && <0.14, mmsyn3 >=0.1.5 && <0.2+ build-depends: base >=4.7 && <4.15, directory >=1 && <1.5, process >=1.2 && <1.8, mmsyn2 >=0.3 && <1, vector >=0.11 && <0.14, mmsyn3 >=0.1.5 && <0.2 -- hs-source-dirs: default-language: Haskell2010 @@ -28,6 +28,6 @@ main-is: Main.hs -- other-modules: other-extensions: CPP- build-depends: base >=4.7 && <4.15, directory >=1 && <1.5, process >=1.2 && <1.8, mmsyn2 >=0.1.8 && <0.2, vector >=0.11 && <0.14, mmsyn3 >=0.1.5 && <0.2+ build-depends: base >=4.7 && <4.15, directory >=1 && <1.5, process >=1.2 && <1.8, mmsyn2 >=0.3 && <1, vector >=0.11 && <0.14, mmsyn3 >=0.1.5 && <0.2 -- hs-source-dirs: default-language: Haskell2010