diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2017-11-25 12:13:16 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2017-11-25 12:13:16 +0300 |
commit | 0c1963044b47793eff2958b775287216ecca7993 (patch) | |
tree | 885f2732731522de862d0f21aabdacc04bb98416 /modules/pkgs | |
parent | f24569893f6a2bef290c9bb097de338292b54b50 (diff) | |
download | nixsap-0c1963044b47793eff2958b775287216ecca7993.tar.gz |
xinclude2nix: format with hindent -XArrows
Diffstat (limited to 'modules/pkgs')
-rw-r--r-- | modules/pkgs/xinclude2nix/xinclude2nix.hs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/modules/pkgs/xinclude2nix/xinclude2nix.hs b/modules/pkgs/xinclude2nix/xinclude2nix.hs index 49d34ca..aaf505e 100644 --- a/modules/pkgs/xinclude2nix/xinclude2nix.hs +++ b/modules/pkgs/xinclude2nix/xinclude2nix.hs @@ -6,21 +6,25 @@ Extract included files Prints list of included files -} - -module Main where +module Main + ( main + ) where import Data.List (intercalate, isPrefixOf, stripPrefix) import Data.Maybe (fromMaybe) import System.Environment (getArgs) -import Text.XML.HXT.Core ( (>>>), deep, getAttrValue, hasAttr, hasName, - isElem, readDocument, returnA, runX) +import Text.XML.HXT.Core + ((>>>), deep, getAttrValue, hasAttr, hasName, isElem, readDocument, + returnA, runX) getXIncludes :: String -> IO [String] -getXIncludes xmlFileName = runX $ readDocument [] xmlFileName - >>> deep (isElem >>> hasName "xi:include" >>> hasAttr "href") >>> - proc d -> do - href <- getAttrValue "href" -< d - returnA -< href +getXIncludes xmlFileName = + runX $ + readDocument [] xmlFileName >>> + deep (isElem >>> hasName "xi:include" >>> hasAttr "href") >>> + proc d -> + do href <- getAttrValue "href" -< d + returnA -< href getFiles :: [String] -> [String] getFiles = map stripScheme . filter isFile @@ -33,7 +37,7 @@ unique :: [String] -> [String] unique [] = [] unique (x:xs) | x `elem` xs = unique xs - | otherwise = x:unique xs + | otherwise = x : unique xs toNix :: [String] -> String toNix ss = "[" ++ intercalate " " (map show ss) ++ "]" @@ -43,4 +47,3 @@ main = do paths <- getArgs includedFiles <- unique . getFiles . concat <$> mapM getXIncludes paths putStrLn $ toNix includedFiles - |