<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi ghc-devs,</p>
<p>About 10 days ago, I made a thread about defining a function
called elaborateExpr which <a moz-do-not-send="true"
href="https://github.com/yiyunliu/ghc-elaboration-test/blob/8f362ad92dc6601b4cb7e4c76f0a42bc6b64480f/src/Main.hs#L55">turns
a string into a core expression</a> within an interactive
context. Now here's an unexpected behavior which I'm not sure how
to deal with.<br>
</p>
<p>Given the expression: <br>
</p>
<p>(\x -> x + 1) :: Int -> Int</p>
<p>I expect to get something that looks like:</p>
<p>\ (x :: Int) -> + @ Int GHC.Num.$fNumInt x (GHC.Types.I# 1#)<br>
</p>
<p>where GHC.Num.$fNumInt is the exported dictionary.</p>
<p><br>
</p>
<p>What I actually get is something like this:</p>
<p>\ (x :: Int) -> + @ Int $dNum_someuniqueid x (GHC.Types.I# 1#)</p>
<p>where $dNum_someuniqueid is a free dictionary variable within the
expression.<br>
</p>
<p><br>
</p>
<p>I was confused by the occurrence of the free variable $dNum at
first, but after running the command: "ghc -ddump-ds-preopt
somefile.hs" to dump the core bindings, I found that the
dictionary variables like $dNum_ are actually local variables
defined at the top-level.</p>
<p>My objective is to inline those top-level dictionary definitions
into the core expression using let bindings, but it seems tricky
since I'm doing everything within an interactive context. Calling
<a moz-do-not-send="true"
href="https://hackage.haskell.org/package/ghc-8.6.5/docs/GHC.html#v:getBindings">getBindings</a>
only gives me the expression I elaborated, but the dictionary is
no where to be found.<br>
</p>
<p>Interestingly, when I turn on flags such as "DeferTypedHoles" or
"DeferOutOfScopeVariables", all the dictionaries are defined
locally in let bindings. However, I can't replicate that behavior
even with the flags on in the interactive context. How do I find
the dictionaries?<br>
</p>
<p>Thanks,</p>
<p>- Yiyun<br>
</p>
</body>
</html>