[Haskell-cafe] x -> String
pumpkingod at gmail.com
Fri Oct 16 14:27:37 EDT 2009
GHCi can't show you functions can it? Unless you have a Show instance
for functions loaded. I think the basic answer is no, not even with
crazy unsafe stuff, because without the typeclass constraint GHC
doesn't know to pass around the secret dictionary containing the
methods that tell it how to show your data.
On Fri, Oct 16, 2009 at 2:19 PM, Andrew Coppin
<andrewcoppin at btinternet.com> wrote:
> Is there any way that you can turn an arbitrary Haskell value into a string?
> I rephrase: There *is* a way to turn arbitrary values into strings. I know
> there is, because the GHCi debugger *does* it. The question is, does anybody
> know of an /easy/ way to do this?
> Basically, I'm writing a mutable container implementation. It can hold any
> type of data, but it would massively aid debugging if I could actually print
> out what's in it. On the other hand, I don't want to alter the entire
> program to have Show constraints everywhere just so I can print out some
> debug traces (and then alter everything back again afterwards once I'm done
> Anybody know of a way to do this? (As it happens, the values I'm testing
> with are all Showable anyway, but the type checker doesn't know that...)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe