Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/irori/hs2lazy
Haskell -> Lazy K translator.
https://github.com/irori/hs2lazy
Last synced: 23 days ago
JSON representation
Haskell -> Lazy K translator.
- Host: GitHub
- URL: https://github.com/irori/hs2lazy
- Owner: irori
- License: other
- Created: 2012-07-28T08:25:27.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-05T02:06:33.000Z (over 10 years ago)
- Last Synced: 2024-08-04T02:09:14.236Z (3 months ago)
- Language: Haskell
- Size: 187 KB
- Stars: 13
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License.thih
Awesome Lists containing this project
- awesome-esoasm - hs2lazy - Haskell to Lazy K compiler (High level functional languages / Esoteric Haskell compilers)
README
hs2lazy -- Haskell to Lazy K compiler
=====================================## What is this?
This is a translator from a subset of Haskell to [Lazy K](http://homepages.cwi.nl/~tromp/cl/lazy-k.html).
## How to compile
You can build hs2lazy with GHC by following command:
ghc -o hs2lazy --make Main.hs
## How to use
hs2lazy [source files]
If multiple source files are given, they are concatenated in the order specified. Output Lazy K code is written to standard output.
Prelude module is not automatically loaded. So, you may specify examples/hs2lazy-prelude.hs first, like following:hs2lazy examples/hs2lazy-prelude.hs foo.hs >foo.lazy
## How to write source code
In Lazy K, input and output streams are represented as infinite lists of numbers (256 represents EOF). Hs2lazy programs handle I/O in similar way.
In Haskell, type of `main` function is `IO ()`. But in hs2lazy, that is:
main :: Stream -> Stream
The Stream type is defined in hs2lazy-prelude.hs as
data Stream = Stream Char Stream
The input is a infinite stream of characters. For example:
Stream 'f' $ Stream 'o' $ Stream 'o' $ Stream eof $ Stream eof ...
`eof` is defined as `(chr 256)`.
Streams can be converted to/from strings by `fromStream` and `toStream` defined in hs2lazy-prelude.hs. For example, following program reverses the input character-by-character.
main = toStream . reverse . fromStream
Or simply,
main = interact reverse
`interact` converts a String-to-String function to a Stream-to-Stream function.
## License
Type.hs is based on [Typing Haskell in Haskell](http://web.cecs.pdx.edu/~mpj/thih/). See Lisence.thih for the license of it.