diff --git a/notebooks/Test.ipynb b/notebooks/Test.ipynb index 6b1cbc2e..957f05d7 100644 --- a/notebooks/Test.ipynb +++ b/notebooks/Test.ipynb @@ -3,7 +3,7 @@ "celltoolbar": "Hiding", "language": "haskell", "name": "", - "signature": "sha256:804b433cf50ca6157f3f59dbddeffdb20dda07eee3e4701830f71f5eee0fbfd3" + "signature": "sha256:b630a2733d4a58680ceb3b868982dc891d570e9ccad5ce31a29d5e1c110962b7" }, "nbformat": 3, "nbformat_minor": 0, @@ -39,9 +39,7 @@ "1+1" ], "language": "python", - "metadata": { - "hidden": false - }, + "metadata": {}, "outputs": [ { "metadata": {}, @@ -201,7 +199,7 @@ "output_type": "display_data" } ], - "prompt_number": 1 + "prompt_number": 2 }, { "cell_type": "code", diff --git a/src/IHaskell/Eval/Evaluate.hs b/src/IHaskell/Eval/Evaluate.hs index 603c70d2..d8980e15 100644 --- a/src/IHaskell/Eval/Evaluate.hs +++ b/src/IHaskell/Eval/Evaluate.hs @@ -465,7 +465,14 @@ evalCommand a (Directive SetOption opts) state = do evalCommand _ (Directive GetType expr) state = wrapExecution state $ do write $ "Type: " ++ expr - formatType <$> getType expr + formatType <$> ((expr ++ " :: ") ++ ) <$> getType expr + +evalCommand _ (Directive GetKind expr) state = wrapExecution state $ do + write $ "Kind: " ++ expr + (_, kind) <- GHC.typeKind False expr + flags <- getSessionDynFlags + let typeStr = showSDocUnqual flags $ ppr kind + return $ formatType $ expr ++ " :: " ++ typeStr evalCommand _ (Directive LoadFile name) state = wrapExecution state $ do write $ "Load: " ++ name diff --git a/src/IHaskell/Eval/Parser.hs b/src/IHaskell/Eval/Parser.hs index ba8843cb..c06fc0cf 100644 --- a/src/IHaskell/Eval/Parser.hs +++ b/src/IHaskell/Eval/Parser.hs @@ -62,6 +62,7 @@ data DirectiveType | GetHelp -- ^ General help via ':?' or ':help'. | SearchHoogle -- ^ Search for something via Hoogle. | GetDoc -- ^ Get documentation for an identifier via Hoogle. + | GetKind -- ^ Get the kind of a type via ':kind'. deriving (Show, Eq) -- | Parse a string into code blocks. @@ -242,6 +243,7 @@ parseDirective (':':directive) line = case find rightDirective directives of dir:_ -> dir `elem` tail (inits dirname) directives = [ (GetType, "type") + , (GetKind, "kind") , (GetInfo, "info") , (SearchHoogle, "hoogle") , (GetDoc, "documentation")