packages feed

hsimport 0.10.0 → 0.11.0

raw patch · 52 files changed

+1116/−109 lines, 52 filesdep +bytestringdep +utf8-stringdep ~haskell-src-extsdep ~ilistdep ~tastyPVP ok

version bump matches the API change (PVP)

Dependencies added: bytestring, utf8-string

Dependency ranges changed: haskell-src-exts, ilist, tasty

API changes (from Hackage documentation)

+ HsImport.Args: [hiding] :: HsImportArgs -> Bool
- HsImport.Args: HsImportArgs :: String -> String -> Bool -> [String] -> String -> String -> FilePath -> FilePath -> HsImportArgs
+ HsImport.Args: HsImportArgs :: String -> String -> Bool -> Bool -> [String] -> String -> String -> FilePath -> FilePath -> HsImportArgs
- HsImport.Main: hsimportWithArgs :: Config -> HsImportArgs -> IO (Maybe Error)
+ HsImport.Main: hsimportWithArgs :: Config -> HsImportArgs -> IO (Maybe ErrorMessage)

Files

CHANGELOG view
@@ -1,3 +1,7 @@+0.11.0+------+* Add option '--hiding' to hide symbols from import+ 0.10.0 ------ * Ensure that no imports are placed inbetween cpp directives
hsimport.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: hsimport-version: 0.10.0+version: 0.11.0 license: BSD3 license-file: LICENSE maintainer: daniel.trstenjak@gmail.com@@ -73,10 +73,10 @@         HsImport.Types         HsImport.Parse         Paths_hsimport-    autogen-modules:-        Paths_hsimport     cpp-options: -DCABAL     hs-source-dirs: lib+    autogen-modules:+        Paths_hsimport     default-language: Haskell2010     ghc-options: -W     build-depends:@@ -110,8 +110,10 @@     ghc-options: -W     build-depends:         base >=3 && <5,-        tasty >=0.9.0.1 && <1.2,+        tasty >=0.9.0.1 && <1.3,         tasty-golden >=2.2.0.1 && <2.4,         filepath >=1.3.0.1 && <1.5,         haskell-src-exts >=1.18.0 && <1.22,+        bytestring >=0.10.8.2 && <0.11,+        utf8-string >=1.0.1.1 && <1.1,         library-internal -any
lib/HsImport/Args.hs view
@@ -17,6 +17,7 @@ data HsImportArgs = HsImportArgs    { moduleName    :: String    , symbolName    :: String+   , hiding        :: Bool    , all           :: Bool    , with          :: [String]    , qualifiedName :: String@@ -30,9 +31,11 @@ hsImportArgs = cmdArgs $ HsImportArgs    { moduleName    = def &= help "The module to import"    , symbolName    = def &= help "The symbol to import, if empty, the entire module is imported"+   , hiding        = def &= help "Hide the given symbols from the import"+                         &= name "hiding" &= name "H"    , all           = def &= help "All constructors or methods of the symbol should be imported: 'Symbol(..)'"                          &= name "all" &= name "a"-   , with          = def &= help "The constructors or methods of the symbol should be imported: 'Symbol(With)'"+   , with          = def &= help "Which constructors or methods of the symbol should be imported: 'Symbol(With)'"    , qualifiedName = def &= help "The name to use for a qualified module import"    , as            = def &= help "The name to use for an unqualified module import" &= name "as"    , outputSrcFile = def &= help "Save modified source file to file, if empty, the source file is modified inplace" &= typFile@@ -51,6 +54,7 @@ defaultArgs = HsImportArgs    { moduleName    = def    , symbolName    = def+   , hiding        = def    , all           = def    , with          = def    , qualifiedName = def
lib/HsImport/HsImportSpec.hs view
@@ -9,7 +9,7 @@ import qualified HsImport.Args as Args import HsImport.Args (HsImportArgs) import HsImport.Parse (parseFile)-import HsImport.SymbolImport (SymbolImport(..))+import HsImport.SymbolImport (SymbolImport(..), Symbol(..)) import HsImport.ModuleImport import HsImport.Types import Data.List (find)@@ -23,7 +23,7 @@    } deriving (Show)  -hsImportSpec :: HsImportArgs -> IO (Either Error HsImportSpec)+hsImportSpec :: HsImportArgs -> IO (Either ErrorMessage HsImportSpec) hsImportSpec args    | Just error <- checkArgs args = return $ Left error    | otherwise = do@@ -47,13 +47,15 @@                              , as         = find (/= "") [Args.qualifiedName args, Args.as args]                              } +      constructor = if Args.hiding args then Hiding else Import+       symbolImport =          case Args.symbolName args of               ""  -> Nothing -              name | Args.all args              -> Just $ AllOfSymbol name-                   | ws@(_:_) <- Args.with args -> Just $ SomeOfSymbol name ws-                   | otherwise                  -> Just $ Symbol name+              name | Args.all args              -> Just $ constructor $ AllOf name+                   | ws@(_:_) <- Args.with args -> Just $ constructor $ SomeOf name ws+                   | otherwise                  -> Just $ constructor $ Only name        saveToFile =          case Args.outputSrcFile args of
lib/HsImport/ImportChange.hs view
@@ -1,8 +1,11 @@-{-# Language PatternGuards #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE PatternGuards #-}  module HsImport.ImportChange    ( ImportChange(..)    , importChanges+   , hasImportError+   , toErrorMessage    ) where  import Data.Maybe@@ -10,7 +13,7 @@ import Lens.Micro import qualified Language.Haskell.Exts as HS import qualified Data.Attoparsec.Text as A-import HsImport.SymbolImport (SymbolImport(..))+import HsImport.SymbolImport (SymbolImport(..), Symbol(..), symbol, isHiding, toggleHiding) import HsImport.ModuleImport (ModuleImport(..)) import HsImport.ImportPos (matchingImports) import HsImport.Utils@@ -23,9 +26,17 @@    | AddImportAtEnd ImportDecl          -- ^ add import declaration at end of source file    | FindImportPos ImportDecl           -- ^ search for an insert position for the import declaration    | NoImportChange                     -- ^ no changes of the import declarations+   | ImportError ErrorMessage           -- ^ import error    deriving (Show) +hasImportError :: ImportChange -> Bool+hasImportError (ImportError _) = True+hasImportError _ = False +toErrorMessage :: ImportChange -> Maybe ErrorMessage+toErrorMessage (ImportError err) = Just err+toErrorMessage _ = Nothing+ importChanges :: ModuleImport -> Maybe SymbolImport -> Module -> [ImportChange] importChanges (ModuleImport moduleName False Nothing) Nothing hsModule =    [ importModule moduleName hsModule ]@@ -34,41 +45,90 @@    [ importModuleWithSymbol moduleName symbolImport hsModule ]  importChanges (ModuleImport moduleName qualified as) symbolImport hsModule =-   [ maybe NoImportChange (\sym -> importModuleWithSymbol moduleName sym hsModule) symbolImport-+   [ maybe NoImportChange+           (\sym -> importModuleWithSymbol moduleName sym hsModule)+           symbolImport    , if qualified-        then importQualifiedModule moduleName (maybe moduleName id as) hsModule-        else maybe NoImportChange (\asName -> importModuleAs moduleName asName hsModule) as+        then importQualifiedModule moduleName (fromMaybe moduleName as) hsModule+        else maybe NoImportChange+                   (\asName -> importModuleAs moduleName asName hsModule)+                   as    ] +-- | Checks whether the given import declaration is unqualified and+--   contains an import spec list.+--   Useful to replace an existing import declaration that has imports,+--   with a more general import.+isUnqualifiedWithSpecList :: ImportDecl -> Bool+isUnqualifiedWithSpecList decl+   | Just (HS.ImportSpecList _ False _) <- HS.importSpecs decl+   , not (HS.importQualified decl)+   = True +   | otherwise+   = False+ importModule :: String -> Module -> ImportChange importModule moduleName module_    | matching@(_:_) <- matchingImports moduleName (importDecls module_) =-      if any entireModuleImported matching+      if any hasEntireModuleImported matching          then NoImportChange-         else FindImportPos $ importDecl moduleName+         else case find isUnqualifiedWithSpecList matching of+            Just impDecl -> ReplaceImportAt (srcSpan . HS.ann $ impDecl)+                                            impDecl { HS.importSpecs = Nothing } +            Nothing -> FindImportPos $ importDecl moduleName+    | not $ null (importDecls module_) =       FindImportPos $ importDecl moduleName     | otherwise =       case srcLineForNewImport module_ of-           Just srcLine -> AddImportAfter srcLine (importDecl moduleName)-           Nothing      -> AddImportAtEnd (importDecl moduleName)+         Just srcLine -> AddImportAfter srcLine (importDecl moduleName)+         Nothing      -> AddImportAtEnd (importDecl moduleName)  +existingMatching :: [ImportDecl] -> String -> SymbolImport -> ImportChange+existingMatching matching moduleName symbolImport+   -- There is a module import+   | Just impDecl <- find hasEntireModuleImported matching+   = if isHiding symbolImport+         -- We add a hiding clause, since we only want to hide a very specific symbol.+        then ReplaceImportAt (srcSpan . HS.ann $ impDecl)+                             (setSymbol impDecl symbolImport)++         -- If we want to import a symbol, we dont have to, since it is already imported.+        else NoImportChange++   -- The symbol we want to import/hide is already imported/hidden.+   | any (hasSymbols symbolImport) matching+   = NoImportChange++   | otherwise+   = case find (hasAnySymbols $ isHiding symbolImport) matching of+        -- There is a fitting import declaration to which we can add the symbol to.+        Just impDecl -> ReplaceImportAt (srcSpan . HS.ann $ impDecl)+                                        (addSymbol impDecl symbolImport)++        -- The symbol is either not imported/hidden or another import+        -- hides/imports it.+        -- If something explictly imports the symbol, we remove it from the import list.+        -- If something explictly hides the symbol, we remove it from the hiding list.+        Nothing -> case find (hasSymbolsOverlap (toggleHiding symbolImport)) matching of+                      -- There is a import declaration that imports/hides the symbol we want to hide/import.+                      Just impDecl -> case removeSymbol impDecl symbolImport of+                                         Left err -> ImportError err+                                         Right symbolList -> ReplaceImportAt (srcSpan . HS.ann $ impDecl)+                                                                             symbolList++                      -- Symbol is not mentioned at all.+                      Nothing -> FindImportPos $ importDeclWithSymbol moduleName symbolImport+ importModuleWithSymbol :: String -> SymbolImport -> Module -> ImportChange importModuleWithSymbol moduleName symbolImport module_+   -- There is already a matching import line    | matching@(_:_) <- matchingImports moduleName (importDecls module_) =-      if any entireModuleImported matching || any (symbolImported symbolImport) matching-         then NoImportChange-         else case find hasImportedSymbols matching of-                   Just impDecl ->-                      ReplaceImportAt (srcSpan . HS.ann $ impDecl) (addSymbol impDecl symbolImport)--                   Nothing      ->-                      FindImportPos $ importDeclWithSymbol moduleName symbolImport+      existingMatching matching moduleName symbolImport     | not $ null (importDecls module_) =       FindImportPos $ importDeclWithSymbol moduleName symbolImport@@ -77,14 +137,94 @@       case srcLineForNewImport module_ of            Just srcLine -> AddImportAfter srcLine (importDeclWithSymbol moduleName symbolImport)            Nothing      -> AddImportAtEnd (importDeclWithSymbol moduleName symbolImport)++-- | Extend the spec list with the given symbol.+--   Might result in duplciates.+extendSpecList :: SymbolImport -> ImportSpecList -> ImportSpecList+extendSpecList symbolImport (HS.ImportSpecList annotation hid specs) =+   HS.ImportSpecList annotation hid (specs ++ [importSpec $ symbol symbolImport])++-- | Remove an element from the import list if it matches the symbol.+--   If the resulting spec list is empty afterwards, Nothing is returned to remove+--   the import list.+--   Removes duplicate imports.+removeSpecList+   :: SymbolImport+   -> ImportSpecList+   -> Either ErrorMessage (Maybe (ImportSpecList))+removeSpecList symbolImport (HS.ImportSpecList annotation hid specs) =+   let specListRemovedSymbol = traverse (removeSymbols (symbol symbolImport)) specs+       in specListRemovedSymbol >>= \specList ->+          if null (catMaybes specList)+             then Right Nothing -- Remove the spec list if it is empty now+             else Right $ Just $ HS.ImportSpecList annotation hid (catMaybes specList)+    where-      addSymbol (id@HS.ImportDecl {HS.importSpecs = specs}) symbolImport =-         id {HS.importSpecs = specs & _Just %~ extendSpecList symbolImport}+      removeSymbols :: Symbol -> ImportSpec -> Either ErrorMessage (Maybe ImportSpec)+      removeSymbols (SomeOf symName _) t@(HS.IThingAll _ name) =+         if symName == nameString name+            then Left $ unlines+               [ "Tried to remove Constructors from a Type that exposed all Constructors."+               , "This does not work because other Constructors are not available for HsImport."+               , "Thus, this operation can not be performed."+               , ""+               , "Example:"+               , "import Foo.Bar (Baz(..))"+               , ""+               , "> hsimport --hiding -m Foo.Bar -s Baz -w A"+               , ""+               , "The correct solution would be, assuming Constructors are A, B and C, to change the import to:"+               , "import Foo.Bar (Baz(B,C))"+               , ""+               , "However, this is not possible for this program, thus, we abort the program execution."+               ]+            else Right $ Just t -      extendSpecList symbolImport (HS.ImportSpecList srcSpan hid specs) =-         HS.ImportSpecList srcSpan hid (specs ++ [importSpec symbolImport])+      removeSymbols (SomeOf symName names) t@(HS.IThingWith a hsSymName hsNames) =+         if symName == nameString hsSymName+            then Right $ Just (HS.IThingWith a hsSymName (removeFromList names hsNames))+            else Right $ Just t +      removeSymbols (AllOf symName) t@(HS.IThingWith a hsSymName _) =+         if symName == nameString hsSymName+            -- Remove all used constructors+            then Right $ Just (HS.IThingWith a hsSymName [])+            else Right $ Just t +      removeSymbols sym spec =+         if imports sym spec+            then Right $ Nothing+            else Right $ Just spec++      removeFromList :: [String] -> [CName] -> [CName]+      removeFromList names = filter ((`notElem` names) . nameString . toName)+++-- | Set the spec list to the given symbol.+setSpecList :: SymbolImport -> Annotation -> ImportSpecList+setSpecList symbolImport annotation =+   HS.ImportSpecList annotation (isHiding symbolImport) [importSpec $ symbol symbolImport]++-- | Add a symbol to the given spec list. May result in duplicates.+addSymbol :: ImportDecl -> SymbolImport -> ImportDecl+addSymbol id@HS.ImportDecl {HS.importSpecs = specs} symbolImport =+   id {HS.importSpecs = specs & _Just %~ extendSpecList symbolImport}++-- | Set a symbol to be exported from the current import declaration.+--   Does not care whether the import declaration already has a spec list.+setSymbol :: ImportDecl -> SymbolImport -> ImportDecl+setSymbol id@HS.ImportDecl {HS.importAnn = importAnn } symbolImport =+   id {HS.importSpecs = Just (setSpecList symbolImport importAnn) }++-- | Remove a symbol from the import declaration.+--   May remove the whole spec list if the list is empty after removal.+removeSymbol :: ImportDecl -> SymbolImport -> Either ErrorMessage ImportDecl+removeSymbol id@HS.ImportDecl {HS.importSpecs = specs} symbolImport =+   case specs & _Just %~ removeSpecList symbolImport of+      Nothing -> Right id {HS.importSpecs = Nothing }+      Just xs -> xs >>= \newSpecList -> Right id {HS.importSpecs = newSpecList}++ importQualifiedModule :: String -> String -> Module -> ImportChange importQualifiedModule moduleName qualifiedName module_    | matching@(_:_) <- matchingImports moduleName (importDecls module_) =@@ -117,8 +257,8 @@            Nothing      -> AddImportAtEnd (asImportDecl moduleName asName)  -entireModuleImported :: ImportDecl -> Bool-entireModuleImported import_ =+hasEntireModuleImported :: ImportDecl -> Bool+hasEntireModuleImported import_ =    not (HS.importQualified import_) && isNothing (HS.importSpecs import_)  @@ -142,42 +282,72 @@    | otherwise    = False +-- | Checks whether the given symbol is somehow mentioned in the import spec.+--   Mainly used to check for constructor overlaps.+hasSymbolsOverlap :: SymbolImport -> ImportDecl -> Bool+hasSymbolsOverlap symbolImport import_+   | Just (HS.ImportSpecList _ hidden hsSymbols) <- HS.importSpecs import_+   , hidden == isHiding symbolImport+   , any (importsOverlap $ symbol symbolImport) hsSymbols+   = True -symbolImported :: SymbolImport -> ImportDecl -> Bool-symbolImported symbolImport import_-   | Just (HS.ImportSpecList _ False hsSymbols) <- HS.importSpecs import_-   , any (imports symbolImport) hsSymbols+   | otherwise+   = False++-- | Checks whether the given SymbolImport is already covered by the current ImportDecl.+hasSymbols :: SymbolImport -> ImportDecl -> Bool+hasSymbols symbolImport import_+   | Just (HS.ImportSpecList _ hidden hsSymbols) <- HS.importSpecs import_+   , hidden == isHiding symbolImport+   , any (imports $ symbol symbolImport) hsSymbols    = True     | otherwise    = False++-- | Checks whether the given symbol is somehow mentioned in the import spec.+--   Mainly used to check for constructor overlaps.+importsOverlap :: Symbol -> ImportSpec -> Bool+importsOverlap (AllOf symName)    (HS.IThingWith _ name _) = symName == nameString name+importsOverlap (SomeOf symName _) (HS.IThingAll _ name)    = symName == nameString name+importsOverlap (SomeOf symName _) (HS.IThingWith _ name _) = symName == nameString name+importsOverlap sym spec                                    = imports sym spec++-- | Checks whether the given symbol is completely covered by the import spec.+imports :: Symbol -> ImportSpec -> Bool+imports = imports_    where-      imports (Symbol symName)             (HS.IVar _ name)                    = symName == nameString name-      imports (Symbol symName)             (HS.IAbs _ _ name)                  = symName == nameString name-      imports (Symbol symName)             (HS.IThingAll _ name)               = symName == nameString name-      imports (Symbol symName)             (HS.IThingWith _ name _)            = symName == nameString name-      imports (AllOfSymbol symName)        (HS.IThingAll _ name)               = symName == nameString name-      imports (SomeOfSymbol symName _    ) (HS.IThingAll _ name)               = symName == nameString name-      imports (SomeOfSymbol symName names) (HS.IThingWith _ hsSymName hsNames) =+      imports_ :: Symbol -> ImportSpec -> Bool+      imports_ (Only symName)         (HS.IVar _ name)                    = symName == nameString name+      imports_ (Only symName)         (HS.IAbs _ _ name)                  = symName == nameString name+      imports_ (Only symName)         (HS.IThingAll _ name)               = symName == nameString name+      imports_ (Only symName)         (HS.IThingWith _ name _)            = symName == nameString name+      imports_ (AllOf symName)        (HS.IThingAll _ name)               = symName == nameString name+      imports_ (SomeOf symName _    ) (HS.IThingAll _ name)               = symName == nameString name+      imports_ (SomeOf symName names) (HS.IThingWith _ hsSymName hsNames) =          symName == nameString hsSymName && null (names \\ (map (nameString . toName) hsNames)) -      imports _ _ = False+      imports_ _ _ = False -      nameString (HS.Ident _ id)   = id-      nameString (HS.Symbol _ sym) = sym+nameString :: Name -> String+nameString (HS.Ident _ id)   = id+nameString (HS.Symbol _ sym) = sym -      toName (HS.VarName _ name) = name-      toName (HS.ConName _ name) = name+toName :: CName -> Name+toName (HS.VarName _ name) = name+toName (HS.ConName _ name) = name  -hasImportedSymbols :: ImportDecl -> Bool-hasImportedSymbols import_-   | Just (HS.ImportSpecList _ False (_:_)) <- HS.importSpecs import_+hasAnySymbols :: Bool -> ImportDecl -> Bool+hasAnySymbols hiding import_+   | Just (HS.ImportSpecList _ hid (_:_)) <- HS.importSpecs import_+   , hid == hiding    = True     | otherwise    = False + importDecl :: String -> ImportDecl importDecl moduleName = HS.ImportDecl    { HS.importAnn       = noAnnotation@@ -193,10 +363,17 @@  importDeclWithSymbol :: String -> SymbolImport -> ImportDecl importDeclWithSymbol moduleName symbolImport =-   (importDecl moduleName) { HS.importSpecs = Just (HS.ImportSpecList noAnnotation-                                                                      False-                                                                      [importSpec symbolImport])-                           }+   case symbolImport of+      Hiding s -> makeImportDecl True s+      Import s -> makeImportDecl False s+   where+      makeImportDecl :: Bool -> Symbol -> ImportDecl+      makeImportDecl hiding symbols =+         (importDecl moduleName)+            { HS.importSpecs = Just (HS.ImportSpecList noAnnotation+                                                       hiding+                                                       [importSpec symbols])+            }   qualifiedImportDecl :: String -> String -> ImportDecl@@ -215,13 +392,12 @@                            }  -importSpec :: SymbolImport -> ImportSpec-importSpec (Symbol symName)             = HS.IVar noAnnotation (hsName symName)-importSpec (AllOfSymbol symName)        = HS.IThingAll noAnnotation (hsName symName)-importSpec (SomeOfSymbol symName names) = HS.IThingWith noAnnotation-                                                        (hsName symName)-                                                        (map ((HS.VarName noAnnotation) . hsName) names)-+importSpec :: Symbol -> ImportSpec+importSpec (Only symName)         = HS.IVar noAnnotation (hsName symName)+importSpec (AllOf symName)        = HS.IThingAll noAnnotation (hsName symName)+importSpec (SomeOf symName names) = HS.IThingWith noAnnotation+                                                  (hsName symName)+                                                  (map (HS.VarName noAnnotation . hsName) names)  hsName :: String -> Name hsName symbolName@@ -234,9 +410,9 @@ srcLineForNewImport :: Module -> Maybe SrcLine srcLineForNewImport module_ =    case module_ of-        HS.Module ann _ _ imports decls            -> newSrcLine ann imports decls-        HS.XmlPage _ _ _ _ _ _ _                   -> Nothing-        HS.XmlHybrid ann _ _ imports decls _ _ _ _ -> newSrcLine ann imports decls+       HS.Module ann _ _ imports decls            -> newSrcLine ann imports decls+       HS.XmlPage _ _ _ _ _ _ _                   -> Nothing+       HS.XmlHybrid ann _ _ imports decls _ _ _ _ -> newSrcLine ann imports decls    where       newSrcLine :: Annotation -> [ImportDecl] -> [Decl] -> Maybe SrcLine       newSrcLine ann imports decls
lib/HsImport/Main.hs view
@@ -8,8 +8,8 @@ import Control.Monad (when) import System.Exit (exitFailure, exitSuccess) import System.IO (hPutStrLn, stderr)-import Data.Maybe (isJust)-import Data.List (foldl')+import Data.Maybe (isJust, mapMaybe)+import Data.List (foldl', partition) import qualified Data.Text as T import qualified Data.Text.IO as TIO import qualified Config.Dyre as Dyre@@ -20,6 +20,7 @@ import qualified HsImport.Args as Args import HsImport.Config import HsImport.Utils+import HsImport.Types  #if __GLASGOW_HASKELL__ < 710 import Control.Applicative ((<$>))@@ -36,33 +37,37 @@       realMain :: Config -> IO ()       realMain config = do          case configError config of-              Just error -> hPutStrLn stderr ("hsimport: " ++ error) >> exitFailure-              _          -> return ()+            Just error -> hPutStrLn stderr ("hsimport: " ++ error) >> exitFailure+            _          -> return ()           args     <- Args.hsImportArgs          maybeErr <- hsimportWithArgs config args          case maybeErr of-              Just err -> hPutStrLn stderr ("hsimport: " ++ err) >> exitFailure-              _        -> exitSuccess+            Just err -> hPutStrLn stderr ("hsimport: " ++ err) >> exitFailure+            _        -> exitSuccess  -type Error = String-hsimportWithArgs :: Config -> Args.HsImportArgs -> IO (Maybe Error)+hsimportWithArgs :: Config -> Args.HsImportArgs -> IO (Maybe ErrorMessage) hsimportWithArgs config args = do    maybeSpec <- hsImportSpec args    case maybeSpec of-        Left  error -> return $ Just error-        Right spec  -> hsimportWithSpec config spec >> return Nothing+      Left  error -> return $ Just error+      Right spec  -> hsimportWithSpec config spec  -hsimportWithSpec :: Config -> HsImportSpec -> IO ()+hsimportWithSpec :: Config -> HsImportSpec -> IO (Maybe ErrorMessage) hsimportWithSpec Config { prettyPrint = prettyPrint, findImportPos = findImportPos } spec = do    let impChanges = importChanges (moduleImport spec) (symbolImport spec) (parsedSrcFile spec)+   case partition hasImportError impChanges of+       ([], changes) -> do+          srcLines <- lines . T.unpack <$> TIO.readFile (sourceFile spec)+          let srcLines' = applyChanges srcLines changes+          when (srcLines' /= srcLines || isJust (saveToFile spec)) $+             TIO.writeFile (outputFile spec) (T.pack $ unlines srcLines')+          return Nothing -   srcLines <- lines . T.unpack <$> TIO.readFile (sourceFile spec)-   let srcLines' = applyChanges srcLines impChanges-   when (srcLines' /= srcLines || isJust (saveToFile spec)) $-      TIO.writeFile (outputFile spec) (T.pack $ unlines srcLines')+       (errors, _) ->+          return (Just (unlines $ mapMaybe toErrorMessage errors))     where       applyChanges = foldl' applyChange@@ -82,14 +87,16 @@        applyChange srcLines (FindImportPos importDecl) =          case findImportPos importDecl allImportDecls of-              Just (After impDecl)  -> applyChange srcLines (AddImportAfter (lastSrcLine . HS.ann $ impDecl)-                                                                            importDecl)-              Just (Before impDecl) -> applyChange srcLines (AddImportAfter (max 0 ((firstSrcLine . HS.ann $ impDecl) - 1))-                                                                            importDecl)-              _                     -> applyChange srcLines (AddImportAfter (lastSrcLine . HS.ann . last $ allImportDecls)-                                                                            importDecl)+             Just (After impDecl)  -> applyChange srcLines (AddImportAfter (lastSrcLine . HS.ann $ impDecl)+                                                                           importDecl)+             Just (Before impDecl) -> applyChange srcLines (AddImportAfter (max 0 ((firstSrcLine . HS.ann $ impDecl) - 1))+                                                                           importDecl)+             _                     -> applyChange srcLines (AddImportAfter (lastSrcLine . HS.ann . last $ allImportDecls)+                                                                           importDecl)        applyChange srcLines NoImportChange = srcLines++      applyChange _ (ImportError _) = error "hsimportWithSpec: unexpected 'ImportError'"        outputFile spec          | Just file <- saveToFile spec = file
lib/HsImport/Parse.hs view
@@ -17,7 +17,7 @@  import HsImport.Types -parseFile :: FilePath -> IO (Either Error ParseResult)+parseFile :: FilePath -> IO (Either ErrorMessage ParseResult) parseFile file = do    srcFile <- replaceCpp . T.unpack <$> TIO.readFile file    catch (do let result = parseFileContents srcFile
lib/HsImport/SymbolImport.hs view
@@ -1,13 +1,41 @@  module HsImport.SymbolImport    ( SymbolImport(..)-   ) where+   , Symbol(..)+   , symbol+   , isHiding+   , toggleHiding+   )+where  type Name = String --- | What of the symbol should be imported.+-- | What of the symbol should be taken.+data Symbol+   = Only Name            -- ^ only the symbol should be taken+   | AllOf Name           -- ^ all constructors or methods of the symbol should be taken: Symbol(..)+   | SomeOf Name [String] -- ^ some constructors or methods of the symbol should be taken: Symbol(X, Y)+   deriving (Show)+++-- | The imported or from the import hidden symbol. data SymbolImport-   = Symbol Name                -- ^ only the symbol should be imported-   | AllOfSymbol Name           -- ^ all constructors or methods of the symbol should be imported: Symbol(..)-   | SomeOfSymbol Name [String] -- ^ some constructors or methods of the symbol should be imported: Symbol(X, Y)+   = Import Symbol -- ^ the symbol to import+   | Hiding Symbol -- ^ the symbol to hide from the import    deriving (Show)++-- | Retrieve the symbol out of the symbol import+symbol :: SymbolImport -> Symbol+symbol (Hiding s) = s+symbol (Import s) = s++-- | Check whether this symbol import is meant to hide a symbol.+isHiding :: SymbolImport -> Bool+isHiding (Hiding _) = True+isHiding (Import _) = False++-- | Toogle the import style from hiding to import and vice versa.+toggleHiding :: SymbolImport -> SymbolImport+toggleHiding (Hiding s) = Import s+toggleHiding (Import s) = Hiding s+
lib/HsImport/Types.hs view
@@ -3,18 +3,20 @@  import qualified Language.Haskell.Exts as HS -type SrcLine     = Int-type SrcColumn   = Int-type SrcSpan     = HS.SrcSpan-type SrcLoc      = HS.SrcLoc-type Annotation  = (HS.SrcSpanInfo, [HS.Comment])-type Decl        = HS.Decl Annotation-type ImportDecl  = HS.ImportDecl Annotation-type ImportSpec  = HS.ImportSpec Annotation-type Name        = HS.Name Annotation-type Module      = HS.Module Annotation-type ModuleName  = String-type Error       = String+type SrcLine        = Int+type SrcColumn      = Int+type SrcSpan        = HS.SrcSpan+type SrcLoc         = HS.SrcLoc+type Annotation     = (HS.SrcSpanInfo, [HS.Comment])+type Decl           = HS.Decl Annotation+type ImportDecl     = HS.ImportDecl Annotation+type ImportSpec     = HS.ImportSpec Annotation+type ImportSpecList = HS.ImportSpecList Annotation+type Name           = HS.Name Annotation+type CName          = HS.CName Annotation+type Module         = HS.Module Annotation+type ModuleName     = String+type ErrorMessage   = String  data ParseResult = ParseResult    { -- | the parse result
tests/Main.hs view
@@ -6,6 +6,7 @@ import System.FilePath import System.IO (hPutStrLn, stderr) import Data.List (intercalate)+import qualified Data.ByteString.Lazy.UTF8 as BS import qualified Language.Haskell.Exts as HS import qualified HsImport as HI import qualified HsImport.Parse as HIP@@ -56,6 +57,7 @@    , test "ModuleTest35" $ HI.defaultArgs { HI.moduleName = "Control.Monad" }    , test "ModuleTest36" $ HI.defaultArgs { HI.moduleName = "Control.Monad" }    , test "ModuleTest37" $ HI.defaultArgs { HI.moduleName = "Control.Monad" }+   , test "ModuleTest38" $ HI.defaultArgs { HI.moduleName = "Data.Text" }    ]  @@ -94,6 +96,25 @@    , configTest "SymbolTest30" (HI.defaultConfig { HI.prettyPrint = prettyPrint }) (HI.defaultArgs { HI.moduleName = "X.Y", HI.symbolName = "x" })    , test "SymbolTest31" $ HI.defaultArgs { HI.moduleName = "Ugah.Blub", HI.symbolName = "d" }    , test "SymbolTest32" $ HI.defaultArgs { HI.moduleName = "Control.Foo", HI.symbolName = "foo" }+   , test "SymbolTest33" $ HI.defaultArgs { HI.moduleName = "Control.Monad", HI.symbolName = "mapM_", HI.hiding = True }+   , test "SymbolTest34" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "isPrefixOf", HI.hiding = True }+   , test "SymbolTest35" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "isInfixOf", HI.hiding = True }+   , test "SymbolTest36" $ HI.defaultArgs { HI.qualifiedName = "T", HI.moduleName = "Data.Text", HI.symbolName = "isInfixOf", HI.hiding = True }+   , test "SymbolTest37" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.all = True, HI.hiding = True }+   , test "SymbolTest38" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.with = ["A", "B", "C"], HI.hiding = True }+   , test "SymbolTest39" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.all = True, HI.as = "T", HI.hiding = True }+   , test "SymbolTest40" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.with = ["A", "B", "C"], HI.as = "T", HI.hiding = True }+   , test "SymbolTest41" $ HI.defaultArgs { HI.moduleName = "Control.Applicative", HI.symbolName = "t", HI.hiding = True }+   , test "SymbolTest42" $ HI.defaultArgs { HI.moduleName = "Control.Applicative", HI.symbolName = "z", HI.hiding = True }+   , test "SymbolTest43" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "isInfixOf" }+   , test "SymbolTest44" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.all = True, HI.hiding = True }+   , test "SymbolTest45" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.with = ["A"], HI.hiding = True }+   , test "SymbolTest46" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.with = ["A"], HI.hiding = True }+   , test "SymbolTest47" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.all = True, HI.hiding = True }+   , test "SymbolTest48" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "isInfixOf" }+   , test "SymbolTest49" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.hiding = True }+   , test "SymbolTest50" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.with = ["B", "C"], HI.hiding = True }+   , failedTest "SymbolTest51" $ HI.defaultArgs { HI.moduleName = "Data.Text", HI.symbolName = "Text", HI.with = ["A"], HI.hiding = True }    ]  @@ -114,6 +135,21 @@  test :: String -> HI.HsImportArgs -> TestTree test testName args = configTest testName HI.defaultConfig args+++failedTest :: String -> HI.HsImportArgs -> TestTree+failedTest testName args =+   goldenVsStringDiff testName diff goldenFile command+   where+      command = do+         Just message <- HI.hsimportWithArgs HI.defaultConfig (args { HI.inputSrcFile = inputFile, HI.outputSrcFile = outputFile })+         return . BS.fromString $ message++      diff ref new = ["diff", "-u", ref, new]++      goldenFile = "tests" </> "goldenFiles" </> testName <.> "hs"+      outputFile = "tests" </> "outputFiles" </> testName <.> "hs"+      inputFile  = "tests" </> "inputFiles"  </> testName <.> "hs"   configTest :: String -> HI.Config -> HI.HsImportArgs -> TestTree
+ tests/goldenFiles/ModuleTest38.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
tests/goldenFiles/ModuleTest5.hs view
@@ -2,7 +2,6 @@ import Foo.Bar import Foo.Bar.Blub import Ugah.Argh-import Control.Monad (when) import Control.Monad  f :: Int -> Int
tests/goldenFiles/ModuleTest7.hs view
@@ -2,9 +2,8 @@ import Foo.Bar import Foo.Bar.Blub import Ugah.Argh-import Control.Monad (when)-import qualified Control.Monad as M import Control.Monad+import qualified Control.Monad as M  f :: Int -> Int f = (+ 3)
+ tests/goldenFiles/SymbolTest33.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Control.Monad hiding (when, mapM_)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest34.hs view
@@ -0,0 +1,20 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Data.Text (isPrefixOf)+import Data.Text hiding (isInfixOf, isPrefixOf)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest35.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Data.Text hiding (isInfixOf)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest36.hs view
@@ -0,0 +1,20 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import qualified Data.Text as T+import Data.Text hiding (isInfixOf)+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest37.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text hiding (Text(..))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest38.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text hiding (Text(A, B, C))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest39.hs view
@@ -0,0 +1,20 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text as T+import Data.Text hiding (Text(..))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest40.hs view
@@ -0,0 +1,20 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text as T+import Data.Text hiding (Text(A, B, C))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest41.hs view
@@ -0,0 +1,17 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative hiding (t)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest42.hs view
@@ -0,0 +1,17 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative (r, t)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest43.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text hiding (isPrefixOf)+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest44.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest45.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text())+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest46.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(B))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest47.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text())+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest48.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest49.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest50.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(A))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/goldenFiles/SymbolTest51.hs view
@@ -0,0 +1,14 @@+Tried to remove Constructors from a Type that exposed all Constructors.+This does not work because other Constructors are not available for HsImport.+Thus, this operation can not be performed.++Example:+import Foo.Bar (Baz(..))++> hsimport --hiding -m Foo.Bar -s Baz -w A++The correct solution would be, assuming Constructors are A, B and C, to change the import to:+import Foo.Bar (Baz(B,C))++However, this is not possible for this program, thus, we abort the program execution.+
+ tests/inputFiles/ModuleTest38.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(..))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest33.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Control.Monad hiding (when)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest34.hs view
@@ -0,0 +1,20 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Data.Text (isPrefixOf)+import Data.Text hiding (isInfixOf)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest35.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Data.Text hiding (isInfixOf)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest36.hs view
@@ -0,0 +1,18 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest37.hs view
@@ -0,0 +1,18 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest38.hs view
@@ -0,0 +1,18 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest39.hs view
@@ -0,0 +1,18 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest40.hs view
@@ -0,0 +1,18 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest41.hs view
@@ -0,0 +1,17 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest42.hs view
@@ -0,0 +1,18 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest43.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text hiding (isPrefixOf, isInfixOf)+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest44.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(..))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest45.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(A))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest46.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(A, B))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest47.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(A, B))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest48.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text hiding (isInfixOf)+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest49.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(A, B))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest50.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(A, B))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =
+ tests/inputFiles/SymbolTest51.hs view
@@ -0,0 +1,19 @@+{-# Language PatternGuards #-}+module Blub+   ( blub+   , foo+   , bar+   ) where+import Control.Applicative+   (r, t, z)+import Ugah.Blub+   ( a+   , b+   , c+   )+import Data.Text (Text(..))+f :: Int -> Int+f = (+ 3)++r :: Int -> Int+r =