adding :kind, closes #165

This commit is contained in:
Andrew Gibiansky 2014-05-17 19:18:25 -07:00
parent c3da884841
commit e7adb88a29
3 changed files with 13 additions and 6 deletions

View File

@ -3,7 +3,7 @@
"celltoolbar": "Hiding", "celltoolbar": "Hiding",
"language": "haskell", "language": "haskell",
"name": "", "name": "",
"signature": "sha256:804b433cf50ca6157f3f59dbddeffdb20dda07eee3e4701830f71f5eee0fbfd3" "signature": "sha256:b630a2733d4a58680ceb3b868982dc891d570e9ccad5ce31a29d5e1c110962b7"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -39,9 +39,7 @@
"1+1" "1+1"
], ],
"language": "python", "language": "python",
"metadata": { "metadata": {},
"hidden": false
},
"outputs": [ "outputs": [
{ {
"metadata": {}, "metadata": {},
@ -201,7 +199,7 @@
"output_type": "display_data" "output_type": "display_data"
} }
], ],
"prompt_number": 1 "prompt_number": 2
}, },
{ {
"cell_type": "code", "cell_type": "code",

View File

@ -465,7 +465,14 @@ evalCommand a (Directive SetOption opts) state = do
evalCommand _ (Directive GetType expr) state = wrapExecution state $ do evalCommand _ (Directive GetType expr) state = wrapExecution state $ do
write $ "Type: " ++ expr 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 evalCommand _ (Directive LoadFile name) state = wrapExecution state $ do
write $ "Load: " ++ name write $ "Load: " ++ name

View File

@ -62,6 +62,7 @@ data DirectiveType
| GetHelp -- ^ General help via ':?' or ':help'. | GetHelp -- ^ General help via ':?' or ':help'.
| 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'.
deriving (Show, Eq) deriving (Show, Eq)
-- | Parse a string into code blocks. -- | Parse a string into code blocks.
@ -242,6 +243,7 @@ parseDirective (':':directive) line = case find rightDirective directives of
dir:_ -> dir `elem` tail (inits dirname) dir:_ -> dir `elem` tail (inits dirname)
directives = directives =
[ (GetType, "type") [ (GetType, "type")
, (GetKind, "kind")
, (GetInfo, "info") , (GetInfo, "info")
, (SearchHoogle, "hoogle") , (SearchHoogle, "hoogle")
, (GetDoc, "documentation") , (GetDoc, "documentation")