Skip to content

Commit

Permalink
Examples of GHC compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hrutvik committed Jul 6, 2023
1 parent 2751040 commit e842bcc
Show file tree
Hide file tree
Showing 2 changed files with 714 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,16 @@ Graphs produced by [`benchmark.py`](benchmark/benchmark.py) therefore show the i
Run `benchmark.py -h` for usage information.
By default, it will read/write `data.{csv,pdf}` - you can change this with e.g. `benchmark.py --filestem foo` to read/write `foo.{csv,pdf}`.
To compile all benchmarks specified in [`bench.config`](benchmark/bench.config) *without* running them, use `benchmark.py --mode compile`.

## Compiling programs with GHC

PureLang resembles a subset of Haskell, so PureLang programs are accepted by GHC with minimal changes.
The diff [`ghc.patch`](./ghc.patch) demonstrates these changes on some examples, and can be applied as follows:
```
git apply ghc.patch
```
The changes mostly:
- reconcile PureLang/GHC I/O and monads, including converting PureLang's `Array` to GHC's `IOArray`
- adapt PureLang primitives to GHC - including appropriate casts between `Int`/`Integer`
- use functions from GHC's `Prelude` rather than manually defining them

Loading

0 comments on commit e842bcc

Please sign in to comment.