Code Monkey home page Code Monkey logo

debug's Introduction

I'm a Haskell/Rust programmer who lives in Cambridge with my wife Emily and son Henry. I have a PhD in Computer Science from York University, working on making functional programs shorter, faster and safer. Since then I've worked at Credit Suisse, Standard Chartered, Barclays Bank and Digital Asset, and I currently work at Meta — but all content and opinions are my own. I'm a strong believer in the functional programming approach, finding the combination of conciseness, static-typing and testability to offer significant advantages. I've got a blog mostly about Haskell, and I'm also on Threads, Twitter, LinkedIn and GitHub. To get in touch email me at [email protected].

Open Source Projects

At work, I am a major contributor to the Buck2 build system. At home, I develop a number of open source Haskell projects, all of which can be found at my Github page or on Hackage. I welcome both contributions via pull requests and bug reports via the GitHub issue trackers. Some of my more popular projects include:

  • Shake - a library for writing build systems, an alternative to make.
  • Hoogle - a Haskell API search engine, searching the standard Haskell libraries by function name and type signature.
  • HLint - a tool that suggests stylistic improvements to Haskell code.

A list of all my talks and papers are available on ndmitchell.com.

debug's People

Contributors

dwijnand avatar ffaf1 avatar marklnichols avatar ndmitchell avatar pepeiborra avatar sholland1 avatar vaibhavsagar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

debug's Issues

Multiple observations of the same variable in a function call

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.

Refactor the default backend into a module

I would like to reorganise the module structure to:

  • move the trace recording (getDebugTrace) from Debug.Record and the TH bits from Debug into a new module Debug.Backend.Default
  • Debug.Record gets renamed to Debug.Types
  • Debug simply reexports Debug.Backend.Default

Document Hoed better

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.

Limit number of "shadowed" variables

Situations like this are a problem if the list is larger than a few elements:

image

I can put in a fix to limit the number of (') vars added, but we probably also need a way to show that there really were more values but they aren't being shown.

Something like this maybe:

x'''(+) =  ...

Is this alive?

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...

Illegal variable name when splicing a TH declaration

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.

Hoed test error

I'm seeing:

Test suite failure for package debug-0.0.2
debug-hoed-test: exited with: ExitFailure 1

Externalize the JSON format

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 ?

Integrate location

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.

Make a release

What do we need to make a release ? The number of new features and improvements since 0.1 is huge.

Add a representation for function arguments

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.

JSON serialisation is broken

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 showing intermediate values when used with stack

Hi,
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?

Parse error when using the pragma

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'

Document TemplateHaskell debug block restrictions

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?

Deal properly with name clashes

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.

Doesnt work in IE 11

Not sure about any other versions, but the functions, variables, and code are all missing in IE 11.

Debug not compatible with mdo blocks?

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?

Add subexpressions

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.

Show which branches are taken

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.

Apply to nested lambdas/functions

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.

GHCi error

stack init
stack build
stack ghci

gives:
Loaded GHCi configuration from \debug.ghci

: error:
module `main:DebugPP' is defined in multiple files

Ovelapping Show instances for monadic values

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.

GHC 8.0 compatibility

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.

CC @pepeiborra @marklnichols

Show onward calls

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.

Function param names missing

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.