From 586149353a755cf7ba7c0bd499a397c3c8230839 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 7 Jan 2007 19:12:27 +0000 Subject: [PATCH] Extended the debugger documentation with a 'tips' section --- docs/users_guide/ghci.xml | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 94d352b..e722739 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -1641,6 +1641,7 @@ qsort2.hs:2:15-46> type to do its work. Let's go on with the debugging session of the qsort example: +A short debugging session qsort2.hs:2:15-46> x This is an untyped, unevaluated computation. You can use seq to @@ -1658,7 +1659,7 @@ x - 10 qsort2.hs:2:15-46> :t x x :: Int - + GHCi reminds us that this value is untyped, and instructs us to force its evaluation @@ -1767,7 +1768,44 @@ x :: Int - + Tips + + * Use PRAGMAs to fine tune which modules are loaded under debugging mode + + {-# OPTIONS_GHC -fdebugging #-} + + + * Repeated use of seq and + :print may be necessary to observe unevaluated + untyped bindings + see + + + * GHC.Exts.unsafeCoerce can help if you are positive about the type of a binding + +type MyLongType a = [Maybe [Maybe a]] + +main:Main> :m +GHC.Exts +main:Main> main +Local bindings in scope: + x :: a +Main.hs:15> let x' = unsafeCoerce x :: MyLongType Bool +Main.hs:15> x' +[Just [Just False, Just True]] + + Note that a wrong coercion will likely result in your debugging session being interrupted by a segmentation fault + + + * The undocumented (and unsupported) :force command + + equivalent to :print with automatic + seq forcing, + may prove useful to replace sequences of seq and + :print in some situations. + + + + The <filename>.ghci</filename> file .ghcifile -- 1.7.10.4