mirror of
https://github.com/rgleichman/glance.git
synced 2024-11-26 09:07:01 +03:00
Initial Home page
commit
e5719b6119
23
Home.md
Normal file
23
Home.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Welcome to the Glance wiki!
|
||||||
|
|
||||||
|
The page provides a brief overview of the current code architecture of Glance, and provides some suggestions of where to start looking around in the code.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
Currently the Glance executable produces a 2D SVG image when given a textual Haskell source file.
|
||||||
|
|
||||||
|
The high level pipeline is that the Haskell source file is parsed by a library ([haskell-src-exts](https://hackage.haskell.org/package/haskell-src-exts)) which returns a syntax tree for each function. The syntax tree is then translated into a **syntax graph**, and syntax graph is then rendered into an image.
|
||||||
|
|
||||||
|
The syntax graph is a graphical representation of the Haskell syntax. The nodes of the syntax graph are the basic elements of Haskell syntax such as function composition, case expressions (pattern matching), and guards (`if` and `else if`). The edges in the syntax graph represent variables and expression results. For example, If two things are connected by edges in the syntax graph, then when the function is called, those two things will have the same value.
|
||||||
|
|
||||||
|
Once the syntax graph for a function is created, the syntax graph is rendered into a 2d image. First, a visual icon is drawn for each node in the syntax graph. The syntax graph is then given to GraphViz (a graph layout library), which returns an X,Y position for each node. The icons are then placed at the positions determined by GraphViz, and then rotated to optimize where the edges will connect. Once the icons have been rotated, the edges of the syntax graph are drawn as lines between the icons.
|
||||||
|
|
||||||
|
This process is done for all of the functions in a file, and the images for all of the functions are combined into one image.
|
||||||
|
|
||||||
|
## Files
|
||||||
|
[/app/Translate.hs](../blob/master/app/Translate.hs) translates the syntax tree into the syntax graph.
|
||||||
|
[app/TranslateCore.hs](../blob/master/app/TranslateCore.hs) has helper functions for Translate.hs
|
||||||
|
[app/Rendering.hs](../blob/master/app/Rendering.hs) renders the syntax graph into an image
|
||||||
|
|
||||||
|
The main types are defined in [app/Types.hs](../blob/master/app/Types.hs):
|
||||||
|
The you can think of the types `SyntaxNode` and `Icon` as the nodes in the syntax graph. The type `Edge` is used for the edges in the syntax graph.
|
Loading…
Reference in New Issue
Block a user