well-typed / visualize-cbn Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
One of the issues I mentioned at #12
Function applications are indeed unevaluated thunks, however they can have their own layout, like here https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/HeapObjects#Genericapplication
For the example above we could have two additional nodes, one for the function and one for 1.
An option to create a graph visualization would be tremendously useful.
$ cat t.hs
span = (\p -> \xs ->
case xs of {
Nil -> Pair xs xs ;
Cons x xs' ->
if p x then
let res = @span p xs'
in Pair (case @res of { Pair ys zs -> Cons x ys})
(case @res of { Pair ys zs -> zs })
else Pair Nil xs
}
)
main = case (@span (\x -> True) (Cons 1 (Cons 2 (Cons 3 Nil)))) of {
Pair ys zs -> case ys of {
Cons y ys2 -> ys ;
Nil -> ys
}
}
$ git log -1
commit d8a1ebc0a29d68b5dde8d8fbadd6c85bc47c6a7b
Author: Edsko de Vries <[email protected]>
Date: Fri Sep 15 17:27:40 2017 +0200
Add README
$ .cabal-sandbox/bin/visualize-cbn -i t.hs --show-trace --hide-prelude
...
visualize-cbn: deref: invalid pointer Ptr Nothing (Just "res")
CallStack (from HasCallStack):
error, called at src/CBN/Heap.hs:78:26 in main:CBN.Heap
For example, in this example from the blog post
Prev Next (step 1, next step: apply enumFromTo)
case enumFromTo 1 3 of {
[] -> 0
x:xs' -> length (1 + 0) xs'
}
It would be very neat to also see the definition of enumFromTo
and a note of what the values are. Something like this:
Will apply enumFromTo, with n = 1 and m = 3:
enumFromTo = (\n -> \m ->
if le n m then Cons n (@enumFromTo (add n 1) m)
else Nil
)
This should probably be a separate feature request but it would also be very helpful to highlight the parts of the code where the rule will be applied. In particular when the next step is selecting a branch of a case
expression. To be extra clear, we could highlight the parameters of the rule with different colours.
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.