glance/README.md

62 lines
4.0 KiB
Markdown
Raw Permalink Normal View History

2017-01-10 11:50:38 +03:00
[Link to project wiki](https://github.com/rgleichman/glance/wiki) (for mobile viewers)
2020-09-21 09:14:33 +03:00
For updates and coding livestreams check out the [Glance YouTube channel](https://www.youtube.com/channel/UCs2gsWfcy83Yqk873WkPfeg).
Also, check out [Only1Loatheb's fork](https://github.com/Only1Loatheb/glance/) which has a different visual style and an interactive mode.
# Glance
2017-01-05 12:24:06 +03:00
Glance is a visual syntax for the programming language Haskell. The goal of this project is to increase programmer happiness and productivity by allowing programmers to create and understand programs in new and different ways. Currently, the Glance executable produces a visual representation of your code in the form of an SVG image when given a textual Haskell source file. In the future, I hope to create a visual editor for Haskell. Please scroll down to see some example images.
The current Glance program is an experiment created to answer the question:
*Is it possible to create a readable and compact graphical representation of Haskell function and value declarations?*
For small to medium functions, in my opinion Glance produces images good enough to indicate that the answer is yes. For large functions, the results right now are inconclusive due to issues with graph layout. Specifically, large programs unnecessarily become very spread out. If you have any ideas about how to improve Glance, please [create an issue](https://github.com/rgleichman/glance/issues/new).
2017-01-09 23:32:38 +03:00
The next steps for the project are to improve graph layout, and then to start work on a visual editor. **If you would like to help** and have any knowledge about graph layout, please make a comment on [this issue](https://github.com/rgleichman/glance/issues/1). All contributions to any part of Glance are very much encouraged.
2016-12-12 09:27:35 +03:00
## Try it
2016-12-10 01:06:56 +03:00
First install Graphviz. For instance, in Ubuntu run:
2017-01-07 07:41:07 +03:00
```
sudo apt install graphviz
```
Then build and execute glance:
```
stack build :glance-exe
stack exec glance-exe -- examples/fact.hs images/fact.svg 500
2016-12-11 03:23:15 +03:00
```
To see the command line options run
```
stack exec glance-exe -- --help
```
2017-01-05 12:24:06 +03:00
Now display the SVG image in a web browser
2016-12-11 03:23:15 +03:00
```
2016-12-10 22:20:01 +03:00
firefox --new-window images/fact.svg
```
2016-12-12 09:27:35 +03:00
You should now see in your browser window a visual representation of the factorial function. Next, you will probably want to read the Getting Started guide below to help understand the images Glance generates.
2016-12-11 03:23:15 +03:00
2016-12-10 01:06:56 +03:00
## Issues
2017-01-05 12:24:06 +03:00
Glance is still in development, so for the time being, graph layout, line routing, and icon design all have much room for improvement. Here are some specific issues:
* Text may be misaligned with some SVG viewers.
* [Images become very spread out when rendering medium to large functions](https://github.com/rgleichman/glance/issues/1).
2017-01-05 12:25:40 +03:00
* Only a subset of Haskell is rendered.
2016-08-14 02:19:49 +03:00
2017-01-07 07:41:07 +03:00
## To learn more
To learn more about the project after reading this README, please check out the [Glance wiki](../../wiki).
2016-12-10 01:06:56 +03:00
## Getting started
2016-05-29 08:03:09 +03:00
Below is a getting started guide for Glance rendered by Glance itself ([source here](examples/tutorial.hs)). To generate this image run
2016-05-29 07:45:31 +03:00
`stack exec glance-exe -- examples/tutorial.hs examples/tutorial.svg 873 -c`
2016-05-29 07:45:31 +03:00
2018-11-11 14:24:47 +03:00
<img src="https://cdn.rawgit.com/rgleichman/glance/9d9862539dda7b7aceea33616816ac30ccf9b393/examples/tutorial.svg" alt="Introduction to Glance" />
2017-01-07 07:43:49 +03:00
You should now be able to understand Glance's visual syntax. If you would like to see how visual code might be an improvement over textual code, or if you just want to see more examples, please take a look at the Glance wiki page [Advantages of Glance](../../wiki/Advantages-of-Glance).
2017-01-07 03:53:46 +03:00
## Thanks
A large thanks to the creators of [diagrams](http://projects.haskell.org/diagrams/), the main Haskell library used in this project.
Thank you to the [Santa Monica Haskell Users Group](https://www.meetup.com/santa-monica-haskell/) for their support and feedback.
2017-01-07 07:41:07 +03:00
Also thanks to the [/r/haskell](https://www.reddit.com/r/haskell/) subreddit for [reviewing a very early design of the language](https://www.reddit.com/r/haskell/comments/35swgl/review_my_introduction_to_glance_a_new_visual/).