@@ -52,6 +52,36 @@ import System.IO (putStrLn)
5252import System.IO.Temp (getCanonicalTemporaryDirectory )
5353import System.Permissions (setScriptPerms )
5454
55+ -- | Type representing exceptions thrown by functions exported by the
56+ -- "Stack.Ghci" module.
57+ data GhciException
58+ = InvalidPackageOption String
59+ | LoadingDuplicateModules
60+ | MissingFileTarget String
61+ | Can'tSpecifyFilesAndTargets
62+ | Can'tSpecifyFilesAndMainIs
63+ | GhciTargetParseException [Text ]
64+ deriving Typeable
65+
66+ instance Show GhciException where
67+ show (InvalidPackageOption name) =
68+ " Failed to parse --package option " ++ name
69+ show LoadingDuplicateModules = unlines
70+ [ " Not attempting to start ghci due to these duplicate modules."
71+ , " Use --no-load to try to start it anyway, without loading any modules (but these are still likely to cause errors)"
72+ ]
73+ show (MissingFileTarget name) =
74+ " Cannot find file target " ++ name
75+ show Can'tSpecifyFilesAndTargets =
76+ " Cannot use 'stack ghci' with both file targets and package targets"
77+ show Can'tSpecifyFilesAndMainIs =
78+ " Cannot use 'stack ghci' with both file targets and --main-is flag"
79+ show (GhciTargetParseException xs) =
80+ show (TargetParseException xs) ++
81+ " \n Note that to specify options to be passed to GHCi, use the --ghci-options flag"
82+
83+ instance Exception GhciException
84+
5585-- | Command-line options for GHC.
5686data GhciOpts = GhciOpts
5787 { ghciTargets :: ! [Text ]
@@ -100,34 +130,6 @@ type ModuleMap = Map ModuleName (Map (Path Abs File) (Set (PackageName, NamedCom
100130unionModuleMaps :: [ModuleMap ] -> ModuleMap
101131unionModuleMaps = M. unionsWith (M. unionWith S. union)
102132
103- data GhciException
104- = InvalidPackageOption String
105- | LoadingDuplicateModules
106- | MissingFileTarget String
107- | Can'tSpecifyFilesAndTargets
108- | Can'tSpecifyFilesAndMainIs
109- | GhciTargetParseException [Text ]
110- deriving (Typeable )
111-
112- instance Exception GhciException
113-
114- instance Show GhciException where
115- show (InvalidPackageOption name) =
116- " Failed to parse --package option " ++ name
117- show LoadingDuplicateModules = unlines
118- [ " Not attempting to start ghci due to these duplicate modules."
119- , " Use --no-load to try to start it anyway, without loading any modules (but these are still likely to cause errors)"
120- ]
121- show (MissingFileTarget name) =
122- " Cannot find file target " ++ name
123- show Can'tSpecifyFilesAndTargets =
124- " Cannot use 'stack ghci' with both file targets and package targets"
125- show Can'tSpecifyFilesAndMainIs =
126- " Cannot use 'stack ghci' with both file targets and --main-is flag"
127- show (GhciTargetParseException xs) =
128- show (TargetParseException xs) ++
129- " \n Note that to specify options to be passed to GHCi, use the --ghci-options flag"
130-
131133-- | Launch a GHCi session for the given local package targets with the
132134-- given options and configure it with the load paths and extensions
133135-- of those targets.
0 commit comments