Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tristancacqueray/simple-haskell-minifier
Simple Haskell Minifier
https://github.com/tristancacqueray/simple-haskell-minifier
Last synced: 14 days ago
JSON representation
Simple Haskell Minifier
- Host: GitHub
- URL: https://github.com/tristancacqueray/simple-haskell-minifier
- Owner: TristanCacqueray
- License: bsd-3-clause
- Created: 2023-02-25T04:08:37.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-24T14:36:27.000Z (about 1 year ago)
- Last Synced: 2024-10-11T01:43:16.394Z (27 days ago)
- Language: Haskell
- Homepage:
- Size: 106 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-haskell-minifier
This project implements a transpiler to minify a simple subset of the Haskell language.
```mermaid
graph LR
I(Source) --> G(GHCHaskell)
G --> S(SimpleHaskell)
S --> M(Minifier)
M --> O(Source)
```## Overview and scope
The project is composed of three modules:
- [GHCHaskell](src/GHCHaskell.hs): parses and decodes Haskell source with [ghc-lib-parser][ghc-lib-parser].
- [SimpleHaskell](src/SimpleHaskell.hs): defines a simple Expr data type.
- [Minifier](src/Minifier.hs): transforms and renders the Expr.The Minifier does the following transformation:
- [x] Combine repeated names when possible.
- [x] Rename binder to single letter name.
- [x] Inline single-use variable.
- [x] Remove unused space.
- [ ] Pack the lines to fit a column limit.## Usage
```ShellSession
$ cabal run << EOF
module Demo whererender 0 = putStrLn "game-over"
render score
| score >= 1, score <= 2 = pure ()
| otherwise = putStrLn ("score: " ++ show score)eval pos | pos > 42 = True
| otherwise = FalseEOF
```
```haskell
a 0=d"game-over";
a e|e>=1,e<=2=pure()|c=d("score: "++show e);
b e|e>42=c|c=False;
c=True;
d=putStrLn
```Checkout the [examples](examples) for more minification demos.
## Contribute
Contributions and bug reports are welcome!
The implementation works ok for the examples, and I'd be happy to integrate changes to support other usage.To work on this project you need a Haskell toolchain: [get-started](https://www.haskell.org/get-started/).
Run the `./bin/run-tests` script to validate a commit.[ghc-lib-parser]: https://hackage.haskell.org/package/ghc-lib-parser