Commit bea11742 authored by Vaibhav Sagar's avatar Vaibhav Sagar

Start implementing :sprint

parent 76bbf5e4
......@@ -28,6 +28,7 @@ import qualified Data.Set as Set
import Data.Char as Char
import Data.Dynamic
import qualified Data.Serialize as Serialize
import qualified Debugger
import System.Directory
import System.Posix.IO (fdToHandle)
import System.IO (hGetChar, hSetEncoding, utf8)
......@@ -735,7 +736,7 @@ evalCommand _ (Directive GetHelp _) state = do
, " :type <expression> - Print expression type."
, " :info <name> - Print all info for a name."
, " :hoogle <query> - Search for a query on Hoogle."
, " :doc <ident> - Get documentation for an identifier via Hogole."
, " :doc <ident> - Get documentation for an identifier via Hoogle."
, " :set -XFlag -Wall - Set an option (like ghci)."
, " :option <opt> - Set an option."
, " :option no-<opt> - Unset an option."
......@@ -785,6 +786,17 @@ evalCommand _ (Directive GetDoc query) state = safely state $ do
results <- liftIO $ Hoogle.document query
return $ hoogleResults state results
evalCommand _ (Directive SPrint binding) state = safely state $ do
Debugger.pprintClosureCommand False False binding
return
EvalOut
{ evalStatus = Success
, evalResult = mempty
, evalState = state
, evalPager = []
, evalMsgs = []
}
evalCommand output (Statement stmt) state = wrapExecution state $ evalStatementOrIO output state
(CapturedStmt stmt)
......
......@@ -63,6 +63,7 @@ data DirectiveType = GetType -- ^ Get the type of an expression via ':type'
| GetDoc -- ^ Get documentation for an identifier via Hoogle.
| GetKind -- ^ Get the kind of a type via ':kind'.
| LoadModule -- ^ Load and unload modules via ':module'.
| SPrint -- ^ Print without evaluating via ':sprint'.
deriving (Show, Eq)
-- | Pragma types. Only LANGUAGE pragmas are currently supported. Other pragma types are kept around
......@@ -285,6 +286,7 @@ parseDirective (':':directive) ln =
, (SetExtension, "extension")
, (GetHelp, "?")
, (GetHelp, "help")
, (SPrint, "sprint")
]
parseDirective _ _ = error "Directive must start with colon!"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment