summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-09-23 07:45:20 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-09-23 07:45:20 +0100
commitf3c7ed721133d53f81d945ecb737a77c2ef6ef73 (patch)
tree619ec8c51c80910d3bc49c5f59f5558afcbb4b08 /ghc
parent25881af06113f2effe2da50e4981effbf0bc9249 (diff)
downloadhaskell-f3c7ed721133d53f81d945ecb737a77c2ef6ef73.tar.gz
Implement GHCi command :kind! which normalises its type
type family F a type instance F Int = Bool type instance F Bool = Char In GHCi *TF> :kind (F Int, F Bool) (F Int, F Bool) :: * *TF> :kind! F Int (F Int, F Bool) :: * = (Bool, Char) We could call it ":normalise" but it seemed quite nice to have an eager version of :kind
Diffstat (limited to 'ghc')
-rw-r--r--ghc/InteractiveUI.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 8ee580465d..28d6bca42e 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -47,7 +47,8 @@ import Panic hiding ( showException )
import Config
import StaticFlags
import Linker
-import Util
+import Util( on, global, toArgs, toCmdArgs, removeSpaces, getCmd,
+ filterOut, seqList, looksLikeModuleName, partitionWith )
import NameSet
import Maybes ( orElse, expectJust )
import FastString
@@ -130,7 +131,8 @@ builtin_commands = [
("history", keepGoing historyCmd, noCompletion),
("info", keepGoing' info, completeIdentifier),
("issafe", keepGoing' isSafeCmd, completeModule),
- ("kind", keepGoing' kindOfType, completeIdentifier),
+ ("kind", keepGoing' (kindOfType False), completeIdentifier),
+ ("kind!", keepGoing' (kindOfType True), completeIdentifier),
("load", keepGoingPaths loadModule_, completeHomeModuleOrFile),
("list", keepGoing' listCmd, noCompletion),
("module", keepGoing moduleCmd, completeSetModule),
@@ -1325,12 +1327,13 @@ typeOfExpr str
-----------------------------------------------------------------------------
-- :kind
-kindOfType :: String -> InputT GHCi ()
-kindOfType str
+kindOfType :: Bool -> String -> InputT GHCi ()
+kindOfType normalise str
= handleSourceError GHC.printException
$ do
- ty <- GHC.typeKind str
- printForUser $ text str <+> dcolon <+> ppr ty
+ (ty, kind) <- GHC.typeKind normalise str
+ printForUser $ vcat [ text str <+> dcolon <+> ppr kind
+ , ppWhen normalise $ equals <+> ppr ty ]
-----------------------------------------------------------------------------