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",
"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",

View File

@ -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

View File

@ -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")