-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | GHCi based bare bones IDE
--   
--   Either "GHCi as a daemon" or "GHC + a bit of an IDE". A very simple
--   Haskell development tool which shows you the errors in your project
--   and updates them whenever you save. Run <tt>ghcid --topmost
--   --command=ghci</tt>, where <tt>--topmost</tt> makes the window on top
--   of all others (Windows only) and <tt>--command</tt> is the command to
--   start GHCi on your project (defaults to <tt>ghci</tt> if you have a
--   <tt>.ghci</tt> file, or else to <tt>cabal repl</tt>).
@package ghcid
@version 0.8.9


-- | Library for spawning and working with Ghci sessions.
module Language.Haskell.Ghcid

-- | A GHCi session. Created with <a>startGhci</a>, closed with
--   <a>stopGhci</a>.
--   
--   The interactions with a <a>Ghci</a> session must all occur
--   single-threaded, or an error will be raised. The only exception is
--   <a>interrupt</a>, which aborts a running computation, or does nothing
--   if no computation is running.
data Ghci

-- | GHCi shut down
data GhciError
UnexpectedExit :: String -> String -> Maybe String -> GhciError
[ghciErrorCmd] :: GhciError -> String
[ghciErrorMsg] :: GhciError -> String
[ghciErrorLastStdErr] :: GhciError -> Maybe String

-- | The stream Ghci is talking over.
data Stream
Stdout :: Stream
Stderr :: Stream

-- | Load messages
data Load

-- | A module/file was being loaded.
Loading :: String -> FilePath -> Load

-- | The module that was being loaded, <tt>Foo.Bar</tt>.
[loadModule] :: Load -> String

-- | The file that was being loaded, <tt>Foo/Bar.hs</tt>.
[loadFile] :: Load -> FilePath

-- | An error/warning was emitted.
Message :: Severity -> FilePath -> (Int, Int) -> (Int, Int) -> [String] -> Load

-- | The severity of the message, either <a>Warning</a> or <a>Error</a>.
[loadSeverity] :: Load -> Severity

-- | The file that was being loaded, <tt>Foo/Bar.hs</tt>.
[loadFile] :: Load -> FilePath

-- | The position in the file, <tt>(line,col)</tt>, both 1-based. Uses
--   <tt>(0,0)</tt> for no position information.
[loadFilePos] :: Load -> (Int, Int)

-- | The end position in the file, <tt>(line,col)</tt>, both 1-based. If
--   not present will be the same as <a>loadFilePos</a>.
[loadFilePosEnd] :: Load -> (Int, Int)

-- | The message, split into separate lines, may contain ANSI Escape codes.
[loadMessage] :: Load -> [String]

-- | A config file was loaded, usually a .ghci file (GHC 8.2 and above
--   only)
LoadConfig :: FilePath -> Load

-- | The file that was being loaded, <tt>Foo/Bar.hs</tt>.
[loadFile] :: Load -> FilePath

-- | A response to an eval comment
Eval :: EvalResult -> Load

-- | Severity of messages
data Severity
Warning :: Severity
Error :: Severity

-- | Start GHCi by running the given shell command, a helper around
--   <a>startGhciProcess</a>.
startGhci :: String -> Maybe FilePath -> (Stream -> String -> IO ()) -> IO (Ghci, [Load])

-- | Start GHCi by running the described process, returning the result of
--   the initial loading. If you do not call <a>stopGhci</a> then the
--   underlying process may be leaked. The callback will be given the
--   messages produced while loading, useful if invoking something like
--   "cabal repl" which might compile dependent packages before really
--   loading.
--   
--   To create a <a>CreateProcess</a> use the functions in
--   <a>System.Process</a>, particularly <a>shell</a> and <a>proc</a>.
startGhciProcess :: CreateProcess -> (Stream -> String -> IO ()) -> IO (Ghci, [Load])

-- | Stop GHCi. Attempts to interrupt and execute <tt>:quit:</tt>, but if
--   that doesn't complete within 5 seconds it just terminates the process.
stopGhci :: Ghci -> IO ()

-- | Interrupt Ghci, stopping the current computation (if any), but leaving
--   the process open to new input.
interrupt :: Ghci -> IO ()

-- | Obtain the progress handle behind a GHCi instance.
process :: Ghci -> ProcessHandle

-- | Execute a command, calling a callback on each response. The callback
--   will be called single threaded.
execStream :: Ghci -> String -> (Stream -> String -> IO ()) -> IO ()

-- | List the modules currently loaded, with module name and source file.
showModules :: Ghci -> IO [(String, FilePath)]

-- | Return the current working directory, and a list of module import
--   paths
showPaths :: Ghci -> IO (FilePath, [FilePath])

-- | Perform a reload, list the messages that reload generated.
reload :: Ghci -> IO [Load]

-- | Send a command, get lines of result. Must be called single-threaded.
exec :: Ghci -> String -> IO [String]

-- | Send <tt>:quit</tt> and wait for the process to quit.
quit :: Ghci -> IO ()
instance GHC.Classes.Eq Language.Haskell.Ghcid.Ghci
