[Haskell-cafe] Why is the Show instance of Text not used by showTerm?

JP Moresmau jpmoresmau at gmail.com
Fri Jan 24 18:32:27 UTC 2014

OK, all simply, show is not called if the term is considered not fully
evaluated, which seems to be my case. So I'll need to write my own showTerm
or maybe pprintClosureCommand, returning a String instead of just writing
to standard out. Bypassing the isFullEvaluatedTerm condition gives me the
expected result.



On Fri, Jan 24, 2014 at 7:09 PM, JP Moresmau <jpmoresmau at gmail.com> wrote:

> Karl, thanks, but the flag is set to True... And setting it to False
> doesn't change the output. I'll continue my investigations!
> JP
> On Fri, Jan 24, 2014 at 6:12 PM, Karl Voelker <karl at karlv.net> wrote:
>>  On Fri, Jan 24, 2014, at 07:38 AM, JP Moresmau wrote:
>> Hello cafe, I'm continuing my adventures with the GHC API. I'm following
>> the code given at
>> http://www.haskell.org/haskellwiki/GHC/As_a_library#Running_interactive_statementsto run statements like in GHCi, but the behavior sometimes puzzles me.
>> If I load a simple module:
>> module Test where
>> import qualified Data.Text as T
>> And then run the statement T.pack \"test\", I expect to see "test" back.
>> But I get Data.Text.Internal.Text _ 0 4. If I run "show $ T.Pack \"test\""
>> I get the expected result. Text _ 0 4 seems to be the output of the
>> showText debugging function in Data.Text, that I don't see used in the Show
>> instance. And looking at the GHC code (Debugger.hs) it does perform a show
>> of the expression given. Why doesn't it work? What subtlety am I missing?
>> The example you linked to calls showTerm (
>> http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/src/Debugger.html#showTerm)
>> which seems to have two different paths depending on the
>> Opt_PrintEvldWithShow dynflag. One path appears to use show, and the other
>> does not.
>> -Karl
> --
> JP Moresmau
> http://jpmoresmau.blogspot.com/

JP Moresmau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140124/74626042/attachment.html>

More information about the Haskell-Cafe mailing list