Changes between Version 43 and Version 44 of ExplicitCallStack


Ignore:
Timestamp:
Jan 30, 2007 4:47:10 PM (9 years ago)
Author:
guest
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ExplicitCallStack

    v43 v44  
    6868== An example to consider ==
    6969
    70 Suppose we are to transform the following code:
     70Suppose we are to transform the following code. The line numbers in comments are useful later when we consider what hat-stack does.
    7171
    7272{{{
     
    7474
    7575   d :: Int
    76    d = e []
     76   d = e []                                               {- line 6 -}
    7777
    7878   e :: [Int] -> Int
     
    8484                False -> hd
    8585
    86    hd = \x -> case x of
    87                  [] -> error "hd: empty list"
     86   hd = \x -> case x of                                   {- line 16 -}
     87                 [] -> error "hd: empty list"             {- line 17 -}
    8888                 (x:_) -> x
    8989
     
    136136As a starting point it is useful to see what Hat does, in particular hat-stack, which is the tool for generating stack traces. The example of `hd []` is exactly the kind of problem that hat-stack is designed to tackle.
    137137
    138 Here is the stack trace generated for the example program. I've added comments on the RHS to indicate what some of the entries mean (because they refer to source code locations).
     138Here is the stack trace generated for the example program. You can see the relevant line numbers in comments in the source code above. I've added comments to the hat output on the RHS to emphasise what the entries mean, when it is not immediately clear.
    139139{{{
    140140   Program terminated with error:
    141141           hd: empty list
    142142   Virtual stack trace:
    143    (unknown)       {?}
    144    (H.hs:17)       error "hd: empty..."
    145    (H.hs:16)       (\..) [] | case []
    146    (H.hs:6)        (\..) []
     143   (unknown)       {?}                               
     144   (H.hs:17)       error "hd: empty..."               
     145   (H.hs:16)       (\..) [] | case []                 {- the case analysis of the list in hd -}
     146   (H.hs:6)        (\..) []                           {- the application of hd in the body of d -}
    147147   (unknown)       d
    148148}}}