Commit 486fc9f4 authored by Vaibhav Sagar's avatar Vaibhav Sagar

Support :kind!

parent d929dfac
...@@ -677,6 +677,15 @@ evalCommand _ (Directive GetKind expr) state = wrapExecution state $ do ...@@ -677,6 +677,15 @@ evalCommand _ (Directive GetKind expr) state = wrapExecution state $ do
let typeStr = showSDocUnqual flags $ ppr kind let typeStr = showSDocUnqual flags $ ppr kind
return $ formatType $ expr ++ " :: " ++ typeStr return $ formatType $ expr ++ " :: " ++ typeStr
evalCommand _ (Directive GetKindBang expr) state = wrapExecution state $ do
write state $ "Kind!: " ++ expr
(typ, kind) <- GHC.typeKind True expr
flags <- getSessionDynFlags
let kindStr = text expr <+> dcolon <+> ppr kind
let typeStr = equals <+> ppr typ
let finalStr = showSDocUnqual flags $ vcat [kindStr, typeStr]
return $ formatType finalStr
evalCommand _ (Directive LoadFile names) state = wrapExecution state $ do evalCommand _ (Directive LoadFile names) state = wrapExecution state $ do
write state $ "Load: " ++ names write state $ "Load: " ++ names
......
...@@ -62,6 +62,7 @@ data DirectiveType = GetType -- ^ Get the type of an expression via ':type' ...@@ -62,6 +62,7 @@ data DirectiveType = GetType -- ^ Get the type of an expression via ':type'
| SearchHoogle -- ^ Search for something via Hoogle. | SearchHoogle -- ^ Search for something via Hoogle.
| 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'.
| GetKindBang -- ^ Get the kind and normalised type via ':kind!'.
| LoadModule -- ^ Load and unload modules via ':module'. | LoadModule -- ^ Load and unload modules via ':module'.
| SPrint -- ^ Print without evaluating via ':sprint'. | SPrint -- ^ Print without evaluating via ':sprint'.
deriving (Show, Eq) deriving (Show, Eq)
...@@ -277,6 +278,7 @@ parseDirective (':':directive) ln = ...@@ -277,6 +278,7 @@ parseDirective (':':directive) ln =
[ (LoadModule, "module") [ (LoadModule, "module")
, (GetType, "type") , (GetType, "type")
, (GetKind, "kind") , (GetKind, "kind")
, (GetKindBang, "kind!")
, (GetInfo, "info") , (GetInfo, "info")
, (SearchHoogle, "hoogle") , (SearchHoogle, "hoogle")
, (GetDoc, "documentation") , (GetDoc, "documentation")
......
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