https://github.com/nunorc/reducer
a simple tool for reducing expressions to a simpler form in Haskell
https://github.com/nunorc/reducer
Last synced: about 1 month ago
JSON representation
a simple tool for reducing expressions to a simpler form in Haskell
- Host: GitHub
- URL: https://github.com/nunorc/reducer
- Owner: nunorc
- Created: 2016-04-24T23:17:38.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-24T23:45:52.000Z (about 9 years ago)
- Last Synced: 2025-04-09T21:54:41.793Z (about 1 month ago)
- Language: Haskell
- Homepage: http://reducer.nrc.pt
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Reducer
A simple tool developed in Haskell to reduce a sequence of elements,
represented by strings, to a simple expression by finding repeating patterns.For a live demo visit: http://reducer.nrc.pt.
## Example
### Using ghci
Using ghci, to reduce the sequence `["a","a","b","c","a","b","c"]`:
*Reducer> let (expr,patterns) = reduce ["a","a","b","c","a","b","c"]
The final reduced expression is:
*Reducer> expr
["a","P0","P0"]And the patterns found are:
*Reducer> patterns
[("P0",["a","b","c"])]### Using the command line
You can use the *main.hs* program to build a GraphViz representation of the reduced
expression. The input expression should be stored in a JSON file:$ cat ex/input.json
["a","a","b","c","a","b","c"]run the program using for example *runhaskell*, giving as argument the input file,
and saving the output to a new file:$ runhaskell main.hs ex/input.json > ex/expr.dot
Now use the *dot* tool from GraphViz to create a *PNG* file for example:
$ dot -Tpng ex/expr.dot > ex/expr.png
You should see something similar to the image below:

## About
Developed by: Almeida, J.J, Oliveira, J.N., and Carvalho, N.R.