15 KiB
GRIN
The name GRIN is short for Graph Reduction Intermediate Notation, and it is an intermediate language for graph reduction. For an overview read The GRIN Project article. To grasp the details take your time and read Urban Boquist's PhD thesis on Code Optimisation Techniques for Lazy Functional Languages .
We presented the core ideas of GRIN at Haskell Exchange 2018. slides video
Also check the GRIN transformation example from Boquist PhD and an example from our imlementation.
![](https://raw.githubusercontent.com/grin-tech/grin/master/images/grin-syntax.png)
Showcase
Setup
Installing LLVM
Homebrew
Example using Homebrew on macOS:
$ brew install llvm-hs/llvm/llvm-7.0
Debian/Ubuntu
For Debian/Ubuntu based Linux distributions, the LLVM.org website provides binary distribution packages. Check apt.llvm.org for instructions for adding the correct package database for your OS version, and then:
$ apt-get install llvm-7-dev
Nix
To get a nix shell with all the required dependencies do the following in the top level folder.
nix-shell
To run the example do the following from the top level folder.
(cd grin; cabal run grin -- grin/opt-stages-high-level/stage-00.grin)
To run a local Hoogle server with Haskell documentation do the following.
hoogle server --port 8087 1>/dev/null 2>/dev/null&
Build GRIN
stack setup
stack build
Usage
stack exec -- grin grin/grin/opt-stages-high-level/stage-00.grin
How to Contribute
See: Issues / Tasks for new contributors
Keep it simple: We follow the fundamentals laid down in HaskellerZ - Feb 2018 - Getting things done in Haskell
Example Front-End
Read about how to generate GRIN code from a frontend language.
Also check the corresponding source code.
i.e.
- Lambda/Syntax.hs - front-end language defintion
- Lambda/GrinCodeGenBoxed.hs - code generator from front-end language to grin
Simplifying Transformations
Transformation | Schema |
---|---|
vectorisation source code: Vectorisation2.hs |
![]() |
case simplification source code: CaseSimplification.hs |
![]() |
split fetch operation source code: SplitFetch.hs |
![]() |
right hoist fetch operation source code: RightHoistFetch2.hs |
![]() |
register introduction source code: RegisterIntroduction.hs |
![]() |