projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a bug in the closure viewer
[ghc-hetmet.git]
/
compiler
/
ghci
/
RtClosureInspect.hs
diff --git
a/compiler/ghci/RtClosureInspect.hs
b/compiler/ghci/RtClosureInspect.hs
index
d3650a3
..
e0a1250
100644
(file)
--- a/
compiler/ghci/RtClosureInspect.hs
+++ b/
compiler/ghci/RtClosureInspect.hs
@@
-19,12
+19,12
@@
module RtClosureInspect(
lookupAddressEnv,
ClosureType(..),
lookupAddressEnv,
ClosureType(..),
- getClosureData,
+ getClosureData, -- :: a -> IO Closure
Closure ( tipe, infoTable, ptrs, nonPtrs ),
Closure ( tipe, infoTable, ptrs, nonPtrs ),
- getClosureType,
- isConstr,
- isIndirection,
- getInfoTablePtr,
+ getClosureType, -- :: a -> IO ClosureType
+ isConstr, -- :: ClosureType -> Bool
+ isIndirection, -- :: ClosureType -> Bool
+ getInfoTablePtr, -- :: a -> Ptr StgInfoTable
Term(..),
printTerm,
Term(..),
printTerm,
@@
-39,6
+39,8
@@
module RtClosureInspect(
isPointed,
isFullyEvaluatedTerm,
-- unsafeDeepSeq,
isPointed,
isFullyEvaluatedTerm,
-- unsafeDeepSeq,
+
+ sigmaType
) where
#include "HsVersions.h"
) where
#include "HsVersions.h"
@@
-61,7
+63,6
@@
import Name
import VarEnv
import OccName
import VarSet
import VarEnv
import OccName
import VarSet
-import Unique
import {-#SOURCE#-} TcRnDriver ( tcRnRecoverDataCon )
import TysPrim
import {-#SOURCE#-} TcRnDriver ( tcRnRecoverDataCon )
import TysPrim
@@
-125,6
+126,11
@@
isPrim _ = False
termType t@(Suspension {}) = mb_ty t
termType t = Just$ ty t
termType t@(Suspension {}) = mb_ty t
termType t = Just$ ty t
+isFullyEvaluatedTerm :: Term -> Bool
+isFullyEvaluatedTerm Term {subTerms=tt} = all isFullyEvaluatedTerm tt
+isFullyEvaluatedTerm Suspension {} = False
+isFullyEvaluatedTerm Prim {} = True
+
instance Outputable (Term) where
ppr = head . customPrintTerm customPrintTermBase
instance Outputable (Term) where
ppr = head . customPrintTerm customPrintTermBase
@@
-343,7
+349,7
@@
customPrintTerm custom = let
customPrintTermBase :: Monad m => (Int->Term-> m SDoc)->[Term->m (Maybe SDoc)]
customPrintTermBase showP =
[
customPrintTermBase :: Monad m => (Int->Term-> m SDoc)->[Term->m (Maybe SDoc)]
customPrintTermBase showP =
[
- test isTupleDC (liftM (parens . cat . punctuate comma) . mapM (showP 0) . subTerms)
+ test isTupleDC (liftM (parens . hcat . punctuate comma) . mapM (showP 0) . subTerms)
, test (isDC consDataCon) (\Term{subTerms=[h,t]} -> doList h t)
, test (isDC intDataCon) (coerceShow$ \(a::Int)->a)
, test (isDC charDataCon) (coerceShow$ \(a::Char)->a)
, test (isDC consDataCon) (\Term{subTerms=[h,t]} -> doList h t)
, test (isDC intDataCon) (coerceShow$ \(a::Int)->a)
, test (isDC charDataCon) (coerceShow$ \(a::Char)->a)
@@
-358,7
+364,7
@@
customPrintTermBase showP =
, largeIntegerDataConName]
isTupleDC Term{dc=dc} = dc `elem` snd (unzip (elems boxedTupleArr))
isDC a_dc Term{dc=dc} = a_dc == dc
, largeIntegerDataConName]
isTupleDC Term{dc=dc} = dc `elem` snd (unzip (elems boxedTupleArr))
isDC a_dc Term{dc=dc} = a_dc == dc
- coerceShow f Term{val=val} = return . text . show . f . unsafeCoerce# $ val
+ coerceShow f = return . text . show . f . unsafeCoerce# . val
--TODO pprinting of list terms is not lazy
doList h t = do
let elems = h : getListTerms t
--TODO pprinting of list terms is not lazy
doList h t = do
let elems = h : getListTerms t
@@
-370,7
+376,7
@@
customPrintTermBase showP =
1 -> last0
_ | isConsLast -> text " | " <> last0
_ -> comma <> last0
1 -> last0
_ | isConsLast -> text " | " <> last0
_ -> comma <> last0
- return$ brackets (cat (punctuate comma init ++ [last]))
+ return$ brackets (hcat (punctuate comma init ++ [last]))
where Just a /= Just b = not (a `coreEqType` b)
_ /= _ = True
where Just a /= Just b = not (a `coreEqType` b)
_ /= _ = True
@@
-379,12
+385,6
@@
customPrintTermBase showP =
getListTerms t@Suspension{} = [t]
getListTerms t = pprPanic "getListTerms" (ppr t)
getListTerms t@Suspension{} = [t]
getListTerms t = pprPanic "getListTerms" (ppr t)
-isFullyEvaluatedTerm :: Term -> Bool
-isFullyEvaluatedTerm Term {subTerms=tt} = all isFullyEvaluatedTerm tt
-isFullyEvaluatedTerm Suspension {} = False
-isFullyEvaluatedTerm Prim {} = True
-
-
-----------------------------------
-- Type Reconstruction
-----------------------------------
-----------------------------------
-- Type Reconstruction
-----------------------------------
@@
-474,7
+474,7
@@
cvObtainTerm1 hsc_env force mb_ty hval
| Nothing <- mb_ty = runTR hsc_env . go argTypeKind $ hval
| Just ty <- mb_ty = runTR hsc_env $ do
term <- go argTypeKind hval
| Nothing <- mb_ty = runTR hsc_env . go argTypeKind $ hval
| Just ty <- mb_ty = runTR hsc_env $ do
term <- go argTypeKind hval
- ty' <- instScheme ty
+ ty' <- instScheme (sigmaType ty)
addConstraint ty' (fromMaybe (error "by definition")
(termType term))
return term
addConstraint ty' (fromMaybe (error "by definition")
(termType term))
return term
@@
-541,6
+541,11
@@
zonkTerm = foldTerm idTermFoldM {
,fSuspension = \ct ty v b -> fmapMMaybe zonkTcType ty >>= \ty ->
return (Suspension ct ty v b)}
,fSuspension = \ct ty v b -> fmapMMaybe zonkTcType ty >>= \ty ->
return (Suspension ct ty v b)}
+
+-- Is this defined elsewhere?
+-- Find all free tyvars and insert the appropiate ForAll.
+sigmaType ty = mkForAllTys (varSetElems$ tyVarsOfType (dropForAlls ty)) ty
+
{-
Example of Type Reconstruction
--------------------------------
{-
Example of Type Reconstruction
--------------------------------