https://github.com/disconcision/spyshare
a tiny tool for visualising substructual sharing in data structures 🕵️♀️
https://github.com/disconcision/spyshare
Last synced: about 1 month ago
JSON representation
a tiny tool for visualising substructual sharing in data structures 🕵️♀️
- Host: GitHub
- URL: https://github.com/disconcision/spyshare
- Owner: disconcision
- Created: 2019-03-31T00:56:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-04T01:58:14.000Z (about 6 years ago)
- Last Synced: 2025-04-02T20:04:58.586Z (about 2 months ago)
- Language: Haskell
- Homepage:
- Size: 175 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
🔍 SPYSHARE 🔍
=========================**A tiny tool for visualising sharing between Haskell data structures.**
**Example:** In the screenshot below, a persistent base list (list0) shares data with its tail (list1) and a new list which prepends to the base list (list2). Note that append (++) shares (list3) but concat does not (list4).)

### 🔍 Graphvis and StableNames expose shared structure
Spyshare generates a graph-based visualization of composite data structures in Haskell. It uses StableName (and hence unsafePerformIO) to track actual memory locations, and can thus be used to visualize substructural sharing, as in the above screenshot. Out of the box, spyshare works only on lists, but it is rudimentarily abstractble (via its MemMappable typeclass) to permit easy extension to some ADTs, like the binary trees below:

I made this as a personal utility when I was doing research on variational data structures with Ramy Shahin. It's barebones, but could likely be straightforwardly extended into a useful didactic tool
### 🔍 Installation and Usage Instructions
- Install [Graphvis](https://graphviz.gitlab.io/download/) and clone this repository
- Import SpyShare and call showGraph on a list of pairs where the first elements are labels (Strings) and the second elements are identifiers indicating the data to be visualized
- A png-format image will be created in the working directory. In linux, the image will open automatically, provided there's an application installed which can handle PNGs
- Untamed unsafeness warning: keep programs simple to avoid confusing results