All Projects → ocharles → what-it-do

ocharles / what-it-do

Licence: MIT license
Automatically trace all (showable) binds in do expressions

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to what-it-do

Asterius
A Haskell to WebAssembly compiler
Stars: ✭ 1,799 (+2120.99%)
Mutual labels:  ghc
Ghcup
DEPRECATED IN FAVOR OF haskell/ghcup-hs
Stars: ✭ 249 (+207.41%)
Mutual labels:  ghc
ghc-stack
Hacking GHC's Stack for Fun and Profit (featuring The Glorious Haskell Debugger v0.0.1 Pre-alpha)
Stars: ✭ 69 (-14.81%)
Mutual labels:  ghc
Haskell Gi
Generate Haskell bindings for GObject-Introspection capable libraries
Stars: ✭ 190 (+134.57%)
Mutual labels:  ghc
Haskell Ide Engine
The engine for haskell ide-integration. Not an IDE
Stars: ✭ 2,433 (+2903.7%)
Mutual labels:  ghc
smuggler2
Minimise haskell imports, make exports explicit
Stars: ✭ 18 (-77.78%)
Mutual labels:  ghc
Haste Compiler
A GHC-based Haskell to JavaScript compiler
Stars: ✭ 1,429 (+1664.2%)
Mutual labels:  ghc
the-thoralf-plugin
This a type-checker plugin to rule all type checker plugins involving type-equality reasoning using smt solvers.
Stars: ✭ 22 (-72.84%)
Mutual labels:  ghc
Haskell Symbol Search Cheatsheet
Haskell/GHC symbol search cheatsheet
Stars: ✭ 243 (+200%)
Mutual labels:  ghc
stm
Software Transactional Memory
Stars: ✭ 74 (-8.64%)
Mutual labels:  ghc
All Hies
Cached Haskell IDE Engine Nix builds for all GHC versions
Stars: ✭ 201 (+148.15%)
Mutual labels:  ghc
Haskell Ghc Illustrated
haskell ghc-illustrated
Stars: ✭ 218 (+169.14%)
Mutual labels:  ghc
zsh-haskell
ghc and cabal completion for zsh shell
Stars: ✭ 18 (-77.78%)
Mutual labels:  ghc
Higgledy
Higher-kinded data via generics
Stars: ✭ 153 (+88.89%)
Mutual labels:  ghc
Pi-Pool
Cardano Stakepool on Raspberry Pi
Stars: ✭ 204 (+151.85%)
Mutual labels:  ghc
Ghc Grin
GRIN backend for GHC
Stars: ✭ 123 (+51.85%)
Mutual labels:  ghc
vabal
cabal in Valle
Stars: ✭ 43 (-46.91%)
Mutual labels:  ghc
ghc-alt-libc
GHC compiled against musl & uClibc
Stars: ✭ 41 (-49.38%)
Mutual labels:  ghc
stupid-computer
A understandable Haskell tracer.
Stars: ✭ 13 (-83.95%)
Mutual labels:  ghc
haskell-hot-swap
Hot swapping compiled code while keeping a websocket connection open
Stars: ✭ 24 (-70.37%)
Mutual labels:  ghc

Hey GHC, what-it-do?

what-it-do is a GHC source plugin that rewrites do expressions to trace all binds. For example, given the following code:

main =
  do 
    a <- return ( 42 :: Int )
    b <- return ( a * 2 )
    f <- return ( \b -> return ( b - 1 ) )
    c <- f ( a * b )
    print c

We can trace all binds by using debugDo from what-it-do, and enabling the plugin:

{-# OPTIONS -fplugin=WhatItDo #-}
import WhatItDo (traceDo)
main =
  traceDo (do 
    a <- return 42
    b <- return ( a * 2 )
    f <- return ( \b -> return ( b - 1 ) )
    c <- f ( a * b )
    print c)

Now, when this code runs, we see:

(Test.hs:5:5-29) a = 42
(Test.hs:6:5-25) b = 84
(Test.hs:8:5-20) c = 3527
3527

Magic!

Wha... how is this possible?

Under the hood, what-it-do has rewritten the original do expression to:

main =
  do 
    a <- return ( 42 :: Int ) >>= \x -> trace ( show x ) ( return x )
    b <- return ( a * 2 ) >>= \x -> trace ( show x ) ( return x )
    f <- return ( \b -> return ( b - 1 ) )
    c <- f ( a * b ) >>= \x -> trace ( show x ) ( return x )
    print c

Notice that because the plugin has access to the type-checker, we only trace things that can be shown. The binding to f doesn't get traced, because we can't show what f is.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].