Re: how can I run ghci monad actions from ghci command line
manually when debugging. Most of my expriments are related to the tickets I filled in: checking whether I can have some cheap workarourd till they are implemented or whether they actually help as much as I hope. That means that for anything more complicated I need access directly to the representation of the same code which is just being debugged. From your response it looks that if I needed something more again I'll just need to create my own version of GHCi driver and reuse the rest through GHC API. If there is some tutorial how to build custom GHCi driver or something else at a higher level (i.e. not the GHC API docs directly), please, let me know. No tutorial that I'm aware of, and recent changes to the GHC API mean that some of the example code out there isn't up to date, either. But there is currently a small example of a modified GHCi on hackage (likely to be folded into the main line later). ghci-haskeline This package reimplements ghci using the GHC API and the Haskeline package for line input in command-line programs. Just a copymodify of some of the GHCi sources, including a Main.hs to call the modified code. Claus ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: how can I run ghci monad actions from ghci command line
Claus Reinke wrote: ghci-haskeline This package reimplements ghci using the GHC API and the Haskeline package for line input in command-line programs. Just a copymodify of some of the GHCi sources, including a Main.hs to call the modified code. Thanks for the information. Ok, from the example, it looks like ghci is significantly smaller than the source in ghc-6.10.1/compiler/ghci directory. Hopefully my next changes (if any at all) will not need more than a custom ghci. The test I did needed also ghc change. The type of function GHC.resume changed from: /resume :: GhcMonad m = SingleStep - m RunResult/ to: /resume :: GhcMonad m = (SrcSpan-Bool) - SingleStep - m RunResult/ ... plus the corresponding implementation change. The added argument is a filtering function to limit source spans which can recorded in the trace history. I'll post more when I know how it changes my debugging experience. Peter. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: how can I run ghci monad actions from ghci command line
Peter Hercek wrote: Is it possible to run ghci monad actions from ghci command line somehow? For example: I would like to check whether it variable is of type Bool and whether it is True using normal Haskell code (i.e. not using ghci commands starting with colon like :type :print). There's no way to do that right now, although you can play tricks with :define to pipe the output of GHCi commands into Haskell code. Look up Claus Reinke's example macros - they're on one of the wikis somewhere, but I don't seem to be able to find them with Google right now. Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: how can I run ghci monad actions from ghci command line
Simon Marlow wrote: Peter Hercek wrote: Is it possible to run ghci monad actions from ghci command line somehow? For example: I would like to check whether it variable is of type Bool and whether it is True using normal Haskell code (i.e. not using ghci commands starting with colon like :type :print). There's no way to do that right now, although you can play tricks with :define to pipe the output of GHCi commands into Haskell code. Look up Claus Reinke's example macros - they're on one of the wikis somewhere, but I don't seem to be able to find them with Google right now. Yes, I know about Claus' tutorial, it was great and I already use his techniques a lot. I even did a small change to ghc source code to try out some stuff for easier debugging. I'm hoping to post about my experience here (maybe in a week or two). What I was searching for in this post was a possibility to write full fledged plugins or something like that. Never mind, I already went through the initial pain of my custom change to ghc so if I ever need something more complicated again I can do my tests directly in the source code. Thanks, Peter. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: how can I run ghci monad actions from ghci command line
Is it possible to run ghci monad actions from ghci command line somehow? For example: I would like to check whether it variable is of type Bool and whether it is True using normal Haskell code (i.e. not using ghci commands starting with colon like :type :print). What I was searching for in this post was a possibility to write full fledged plugins or something like that. Never mind, I already went through the initial pain of my custom change to ghc so if I ever need something more complicated again I can do my tests directly in the source code. An intermediate approach between scripting GHCi and modifying GHCi's source would be to use the GHC API. You'd still need to read the source, but your code could be used with any GHC (via the ghc package), not just with your modified sources. I didn't mention this earlier because it doesn't give you direct access to your GHCi session (you'd be running a separate GHC session, for which you could provide GHCi style frontend and debugger functionality, plus your plugins/ modifications), but if you're thinking plugins, the GHC API is probably the way to go. If the necessary functionality is not yet exposed through the API, it probably should be (iirc, GHCi's frontend itself isn't part of the API, but the functionality used by it is, so GHCi is just one of several GHC API clients; don't know how far the debugger features you are interested in are tied to the frontend or available for all GHC API sessions). As usual, there is the design question of what to expose and how, on which GHC HQ would like user input. Nothing is as helpful for that as an actual use case!-) So, yes, please do report on your experiments. Claus ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: how can I run ghci monad actions from ghci command line
Claus Reinke wrote: If the necessary functionality is not yet exposed through the API, it probably should be (iirc, GHCi's frontend itself isn't part of the API, but the functionality used by it is, so GHCi is just one of several GHC API clients; don't know how far the debugger features you are interested in are tied to the frontend or available for all GHC API sessions). As usual, there is the design question of what to expose and how, on which GHC HQ would like user input. Nothing is as helpful for that as an actual use case!-) So, yes, please do report on your experiments. Actually, I do not think I want much. I just want to have something significantly better than printf debugging for my application. GHC/GHCi hacking is not my primary goal. Even now I think I'm better off with ghci and my extensions than with printf debugging. It will improve much when 6.10.2 is out (fixing ticket #2740 you helped to pin down). This mostly means adding some ghci commands which automate what I'm doing manually when debugging. Most of my expriments are related to the tickets I filled in: checking whether I can have some cheap workarourd till they are implemented or whether they actually help as much as I hope. That means that for anything more complicated I need access directly to the representation of the same code which is just being debugged. From your response it looks that if I needed something more again I'll just need to create my own version of GHCi driver and reuse the rest through GHC API. If there is some tutorial how to build custom GHCi driver or something else at a higher level (i.e. not the GHC API docs directly), please, let me know. I'll post when I have my first round of enhancements done and will be able at least guess how much they are helping. It may even help GHC team to decide whether to scrap my tickets or implement them :-D Thanks, Peter. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users