GHC Core question
Neil Mitchell
ndmitchell at gmail.com
Sat Jan 5 15:00:44 EST 2008
Hi
I've compiled the Debug.Trace module to Core, but can't understand the
resulting output. The original code is:
trace string expr = unsafePerformIO $ do
putTraceMsg string
return expr
The core is:
Debug.Trace.trace =
\ (@ a) ->
__letrec {
trace :: GHC.Base.String -> a -> a
[]
trace =
\ (string :: GHC.Base.String) (expr :: a) ->
GHC.Base.$
@ (GHC.IOBase.IO a)
@ a
(GHC.IOBase.unsafePerformIO @ a)
(>> @ () @ a (Debug.Trace.putTraceMsg string) (return @ a expr));
$dMonad :: GHC.Base.Monad GHC.IOBase.IO
[]
$dMonad = $dMonad;
return :: forall a. a -> GHC.IOBase.IO a
[]
return = GHC.Base.return @ GHC.IOBase.IO $dMonad;
$dMonad :: GHC.Base.Monad GHC.IOBase.IO
[]
$dMonad = GHC.IOBase.$f16;
>> :: forall a b.
GHC.IOBase.IO a -> GHC.IOBase.IO b -> GHC.IOBase.IO b
[]
>> = GHC.Base.>> @ GHC.IOBase.IO $dMonad;
} in trace;
And my Haskell reformatting of that is:
Debug.Trace.trace = let
trace string expr = unsafePerformIO $ putTraceMsg string >> return expr
$dMonad = $dMonad;
return = GHC.Base.return $dMonad;
$dMonad = GHC.IOBase.$f16;
>> = GHC.Base.>> $dMonad;
in trace
However, that let expression has two bindings for $dMonad, one of
which looks like a black-hole. Are the semantics of __letrec different
from let in some way?
Thanks
Neil
More information about the Glasgow-haskell-users
mailing list