https://github.com/bagnalla/hakan
A functional programming language with algebraic datatypes and typeclasses
https://github.com/bagnalla/hakan
Last synced: 3 months ago
JSON representation
A functional programming language with algebraic datatypes and typeclasses
- Host: GitHub
- URL: https://github.com/bagnalla/hakan
- Owner: bagnalla
- License: mit
- Created: 2018-08-03T07:21:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-25T14:49:54.000Z (about 2 years ago)
- Last Synced: 2025-01-21T10:50:57.492Z (5 months ago)
- Language: C
- Homepage:
- Size: 7.1 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hakan
A statically typed functional programming language with parametric
polymorphism and type inference.See monad.hk for an example program that uses typeclasses, and base.hk
and prelude.hk for more example code. The other .hk files are probably
out of date.## Instructions
To build hakan and run the interpreter on a test program:
`stack build && stack exec hakan-exe hk/monad.hk`
## Compilation to JavaScript
[src/JS.hs](src/JS.hs) implements straightforward compilation to JavaScript. Try it out with:
`./compileJS.sh hk/monad.hk`
## Compilation to C
[src/C.hs](src/C.hs) implements compilation to C. It is less straightforward than the JS backend because of C's lack of innate support for higher-order functions / closures, and lack of garbage collection. Compilation proceeds by lambda-lifting all functions to top-level "supercombinators" which are then compiled to individual C functions. Currently doesn't support the use of typeclasses. The resulting executable is hooked up to Boehm GC.
`./compileC.sh hk/ctest9.hk`