Library support and general haskell debugging

View: New views
2 Messages — Rating Filter:   Alert me  

Library support and general haskell debugging

by Yang-13 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi, i'm new to hat (and haskell), and i'm interested in using hat to
get a trace of a simple (actually, not so simple to me) haskell
program that uses the hscurses library (its included example
application, ContactManager). i'm specifically trying to find out what
hscurses IO calls are being made, and in what order. this in turn is
because my numerous attempts to write applications based on this code
(ie using hscurses.widgets) have runtime failures.

however, i found to my surprise that hat doesn't actually support any
libraries outside the ones. for something like hscurses, which
provides bindings to the ncurses c library and is partly written in
hsc, is there still a way to use it without subjecting myself to too
much pain?

aside: i understand that one can copy over pure haskell libraries and
compile them using hmake, but is hat honestly useable in practice?
also, the only other debuggers i've found are: hood (superceded by
hat), debug.trace (which requires modification of your src), ghci's
dynamic breakpoints (not yet done, and almost certainly too painful to
try to get working/to work with), and buddha (which only seems to do
static src transformations, so it doesn't look like it'll help me). is
there no hope for me in haskell?

thanks and happy new years,

yang
_______________________________________________
Hat mailing list
Hat@...
http://www.haskell.org/mailman/listinfo/hat

Re: Library support and general haskell debugging

by Malcolm.Wallace :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Yang" <d9jh00502@...> wrote:

> however, i found to my surprise that hat doesn't actually support any
> libraries outside the ones.

We are all too painfully aware of this particular shortcoming of Hat.
Just about everyone in Haskell now uses pre-packaged libraries, but Hat
does not (easily) support them yet.  Sorry, but the best advice I can
give is to wait until the Hat developers fix this!

> for something like hscurses, which
> provides bindings to the ncurses c library and is partly written in
> hsc, is there still a way to use it without subjecting myself to too
> much pain?

It is possible, but for a beginner in Haskell I expect the work involved
to be too unpleasant.

Here is a different suggestion that may help to solve your immediate
problem.  You only want to see the order of calls to I/O functions in
the library.  So you could manually create a wrapper for every function,
that writes a message to a logfile before calling the original function.
Then just call the wrappers instead of the originals.  (It is easy to
give the wrappers the same name as the original function, by using
module qualification, so you can swap between logging and non-logging
versions later on.)

Example:

    module HsCurses where
      foo :: Foo -> Blargh -> IO Foo
      bar :: Bar -> Baz -> IO ()

    module WrappedCurses where
      import qualified HsCurses
      foo a b = do appendFile "logfile" ("foo "++show a++show b)
                   HsCurses.foo a b
      bar a b = do appendFile "logfile" ("bar "++show a++show b)
                   HsCurses.bar a b

    module Main where
      --import HsCurses -- choose between original
      import WrappedCurses -- or logging version

Regards,
    Malcolm
_______________________________________________
Hat mailing list
Hat@...
http://www.haskell.org/mailman/listinfo/hat
LightInTheBox - Buy quality products at wholesale price