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 ...@@ -28,6 +28,7 @@ import qualified Data.Set as Set
import Data.Char as Char import Data.Char as Char
import Data.Dynamic import Data.Dynamic
import qualified Data.Serialize as Serialize import qualified Data.Serialize as Serialize
import qualified Debugger
import System.Directory import System.Directory
import System.Posix.IO (fdToHandle) import System.Posix.IO (fdToHandle)
import System.IO (hGetChar, hSetEncoding, utf8) import System.IO (hGetChar, hSetEncoding, utf8)
...@@ -735,7 +736,7 @@ evalCommand _ (Directive GetHelp _) state = do ...@@ -735,7 +736,7 @@ evalCommand _ (Directive GetHelp _) state = do
, " :type <expression> - Print expression type." , " :type <expression> - Print expression type."
, " :info <name> - Print all info for a name." , " :info <name> - Print all info for a name."
, " :hoogle <query> - Search for a query on Hoogle." , " :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)." , " :set -XFlag -Wall - Set an option (like ghci)."
, " :option <opt> - Set an option." , " :option <opt> - Set an option."
, " :option no-<opt> - Unset an option." , " :option no-<opt> - Unset an option."
...@@ -785,6 +786,17 @@ evalCommand _ (Directive GetDoc query) state = safely state $ do ...@@ -785,6 +786,17 @@ evalCommand _ (Directive GetDoc query) state = safely state $ do
results <- liftIO $ Hoogle.document query results <- liftIO $ Hoogle.document query
return $ hoogleResults state results 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 evalCommand output (Statement stmt) state = wrapExecution state $ evalStatementOrIO output state
(CapturedStmt stmt) (CapturedStmt stmt)
......
...@@ -63,6 +63,7 @@ data DirectiveType = GetType -- ^ Get the type of an expression via ':type' ...@@ -63,6 +63,7 @@ data DirectiveType = GetType -- ^ Get the type of an expression via ':type'
| GetDoc -- ^ Get documentation for an identifier via Hoogle. | GetDoc -- ^ Get documentation for an identifier via Hoogle.
| GetKind -- ^ Get the kind of a type via ':kind'. | GetKind -- ^ Get the kind of a type via ':kind'.
| LoadModule -- ^ Load and unload modules via ':module'. | LoadModule -- ^ Load and unload modules via ':module'.
| SPrint -- ^ Print without evaluating via ':sprint'.
deriving (Show, Eq) deriving (Show, Eq)
-- | Pragma types. Only LANGUAGE pragmas are currently supported. Other pragma types are kept around -- | Pragma types. Only LANGUAGE pragmas are currently supported. Other pragma types are kept around
...@@ -285,6 +286,7 @@ parseDirective (':':directive) ln = ...@@ -285,6 +286,7 @@ parseDirective (':':directive) ln =
, (SetExtension, "extension") , (SetExtension, "extension")
, (GetHelp, "?") , (GetHelp, "?")
, (GetHelp, "help") , (GetHelp, "help")
, (SPrint, "sprint")
] ]
parseDirective _ _ = error "Directive must start with colon!" 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