ndmitchell / debug Goto Github PK
View Code? Open in Web Editor NEWHaskell library for debugging
License: BSD 3-Clause "New" or "Revised" License
Haskell library for debugging
License: BSD 3-Clause "New" or "Revised" License
Can we reconfigure things so that only 'debugView' needs to be entered as per the current documentation?
I'm trying to use debug
to instrument a function. I have followed the instructions, so the top of my source file looks like this:
{-# LANGUAGE TemplateHaskell, ViewPatterns, PartialTypeSignatures #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}
module Day2 (
-- ...
) where
import Util
import Debug
I'm instrumenting the function as follows:
debug [d|
_seek_from :: (Integer, Integer) -> Integer -> [Integer] -> Maybe (Integer, Integer)
_seek_from (a, b) t [] = Nothing
_seek_from (a, b) t mem
| a > bound && b > bound = Nothing
| a < 0 || b < 0 = Nothing
| a > bound && b <= bound = _seek_from (0, b + 1) t mem
| otherwise =
let r = test_inputs (a, b) mem in
if r == t then Just (a, b) else _seek_from (a + 1, b) t mem
where bound = let x = toInteger . ((-) 1) . length $ mem in if x > 99 then 99 else x
|]
When I build (stack build
) I get the following error:
Illegal variable name: ‘’Illegal variable name: ‘’
When splicing a TH declaration
It specifically has a problem on the debug [d|
line.
Got another one for you.
Try this:
debug [d|
f :: Int -> m Int
f _ = undefined
|]
You get an Overlapping instances for Show (m0 Int)
error. This can be "fixed" by adding a instance {-# INCOHERENT #-} Show (m Int)
somewhere because the arcane rules of instance selection pick this one.
I'm not really sure what you can really do about this.
It seems this is becoming more necessary as more variations of test functions are added.
I'd think Id like to start working on this next.
GHCi is complaining about the conflicting Mains in test and src-debug-pp
Picking one of the functions from the drop-down list doesn't seem to do anything. This is the same on all the browsers.
There should be an option to show onward calls, e.g. if map f (x:xs)
calls map f xs
that should be presented as an onward call, which is possible since debug
tracks which f
is being passed. Using this onward call information can build a call stack, giving a more traditional style of debugger.
What do we need to make a release ? The number of new features and improvements since 0.1 is huge.
Should we provide that? With the latest commits Debug.Hoed
generates things using deriving strategies, which is a GHC 8.2 only feature. We should either fix that, or declare 8.0 unsupported.
Consider the example
debug [d|
listcomp y = sum [x | x <- [1..y]]
|]
The expression listcomp 3
Produces the trace
* listcomp 3 = 6
x = 1
x = 2
x = 3
$arg1 = 3
y = 3
sum = 6
$result = 6
This is not unique to list comprehensions, it happens also for a mapped lambda:
debug [d|
listmap y = sum $ map (\x -> x) [1..y]
|]
listmap 3
produces the same trace as listcomp 3
The Hoed backend is not affected by this.
I would like to reorganise the module structure to:
getDebugTrace
) from Debug.Record and the TH bits from Debug into a new module Debug.Backend.DefaultHi,
first let me thank you for this amazing tool. Regarding the quicksort example,
if I use this inside a stack setup the intermediate values like lt, gt are not shown.
With cabal they will be shown. Is this a matter of configuration or
is it not possible to show the intermediate values inside a stack setup?
When there is an if
or pattern match it should highlight the taken path in yellow. When there is a boolean predicate it should highlight it in green/blue according to the result (perhaps, might not be necessary with the yellow color).
Note this isn't intended to be a HPC style "what got evaluated" in terms of lazy evaluation, more just which call path was taken.
stack init
stack build
stack ghci
gives:
Loaded GHCi configuration from \debug.ghci
: error:
module `main:DebugPP' is defined in multiple files
Specifically there are no docs for:
data Config
class Observable a
observer :: Observable a => a -> Parent -> a
constrain :: Observable a => a -> a -> a
observe :: Observable a => String -> a -> a
data HoedOptions :: *
defaultHoedOptions :: HoedOptions
My checking script complains, which explains the Travis GHC 8.2 error.
For example, with this function
debug [d|
lcm_gcd :: (Integral a) => a -> a -> Double
lcm_gcd x y =
let least = lcm x y
in fromIntegral least ^^ gcd x y
|]
We still get $arg1 and $arg2, but x and y are missing.
The location
function in TemplateHaskell can given me the source file, and location of the Debug block. Some kind of smart lexer and matching algorithm could give the original code, precisely, with exact locations and layout as per the original.
Then I could check the HTML from a PR
I'm new in Haskell and this package is interesting. I just would like to know is this package alive or maybe this functionality went to the HLS or an other technik is preferred instead of this? I'm asking it because the last commit is 4 years old...
This means that the frontend is broken right now, of course.
It's my fault, the toEncoding
implementation was missing the arguments. I'll send a fix asap.
Not sure about any other versions, but the functions, variables, and code are all missing in IE 11.
The DebugTrace
datatype does not provide an encoding for functions, so the Hoed backend has been representing them as strings, for instance:
$arg1 = { \ 'l' -> True, \ 'l' -> True}
Having a representation would allow the frontend to render these more effectively (and choosing when to display them), and would increase sharing, making the trace more compact.
The html frontend should build a history of visited function calls during a debugging session.
If you write:
foo x = case x of
x:xs -> ...
Then it records x
twice as different values, overwriting each other. They should be handled uniquely.
I'm getting the following when trying to instrument an entire file:
/home/george/haskell-tinywl//tmp/ghc23679_0/ghc_1.hspp:708:64: error
:
mdo, monad comprehension and [: :] not (yet) handled by Template
Haskell
I use mdo
blocks throughout my module. I'm assuming this means Debug isn't compatible with these mdo
blocks? If so, will changing all mdo
blocks to rec
statements make it work?
Can we define a schema for the JSON format via Haskell types and derived instances, so that it becomes easier to reuse by external tools and packages ?
If you call a function whose results are not otherwise immediately available they should be added as a separate expression. e.g. if you have: foo x y = bar x y + foo y z
then it would be useful to have dedicated values for bar x y
and foo y z
than than just $result
.
The summary shown on hackage says "Full usage instructions are at Debug", but there is nothing there.
And also the opaque types trick: https://codemix.com/opaque-types-in-javascript/
I put this at the top of small test file:
{-# OPTIONS -F -pgmF debug-pp #-}
I did a build and launched GHCi. The new module wasn't pre-loaded by GHCI, but when I tried to load the source file via -l I got:
parse error on input `import'
I'm seeing:
Test suite failure for package debug-0.0.2
debug-hoed-test: exited with: ExitFailure 1
This code causes a compile error:
-- (The first line is line 84)
debug [d|
f :: Int -> Int
f n = g n * h n
|]
debug [d|
g :: Int -> Int
g n = n * 3
|]
h :: Int -> Int
h n = n + 2
:\stack_root\haskell-examples\src\ProjectEuler\Problem19.hs:84:1: error:
* Variable not in scope: g :: t -> a
* `g' (splice on lines 89-92) is not in scope before line 89
C:\stack_root\haskell-examples\src\ProjectEuler\Problem19.hs:84:1: error:
* Variable not in scope: h :: t -> a
* `h' (line 95) is not in scope before the splice on lines 89-92
Is this calling functions from block to block legitimate and fixable? Or just something that needs to
be avoided and documented?
Add pagination or some other means of displaying only a limited amount of function calls in the left column.
Currently only top-level declarations are trapped. However, it should be anything that looks lambda-like, so anything nested as well. e.g.
foo x y = ...
where
bar x y = ...
Should annotate both foo
and bar
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.