jespercockx / agda2scheme Goto Github PK
View Code? Open in Web Editor NEWCompiler backend for generating Scheme code
Compiler backend for generating Scheme code
In order to make the backend practically useable, it needs to have support for imports from other files.
One choice that needs to be made is whether we compile each Agda file to a separate Scheme file, or if we join all files together into a single master file. Since Chez Scheme does not do cross-module optimizations, the latter would have better performance, but it would mean we give up on separate compilation.
The following built-in types of Agda are not yet supported:
Note that by default, Scheme uses complex numbers, so we need to use the flo
-prefixed versions of operations on floats.
Currently Agda2Scheme compiles Agda definitions to Scheme definitions, but there is no way yet to indicate a main function.
One question here is whether we want something like the IO monad in Haskell to mediate basic input/output effects, or if we just use a more direct style of doing IO.
Currently constructors always store a tag, even when there is only a single option.
As a stretch goal, we could even skip the constructor tag if there are several constructors, as long as there is only a single constructor of each given arity. We can then just determine which constructor we have by looking at the length of the argument list.
Instead of matching, we could instead just project out the fields of the record directly.
Here is how I am running my benchmarks so far:
cd test
agda2scheme --lazy Triples.agda
echo '(display (test1)) (display "\n")' >> Triples.ss
echo '(compile-file "Triples.ss")' | chezscheme -q
time chezscheme --script Triples.so
It would definitely be good to automate this.
Hello,
Thank you for creating this repository. I am studying this to learn how to write backend in Agda!
I play around with adding CI support to this on my fork here lemastero#1, would it make sense to open such PR towards this repository?
It would be cool if we could detect automatically types that are sufficiently like natural numbers or integers, and represent them using actual integers in the compiled code. As a stretch goal, we could even try to detect that certain functions are just addition/subtraction/... and compile them to more efficient versions as well.
Currently compiling code with the --lazy
flag incurs a quite heavy performance overhead (e.g. the slowdown is over 10x on Triples.agda). If we could analyze which arguments are always used by a given function, then we could avoid creating delay
thunks for those arguments and instead evaluate them strictly. I started implementing this analysis in 2834874, but it is not yet clear to me how to do this analysis properly for mutually recursive functions.
Arrays give constant-time access to their elements so they might be more efficient, especially for record types with many fields.
We could also consider using arrays to represent argument lists for functions with a high arity.
Hello,
In test directory there are golden tests, but there is no code that actually illustrate how to run them.
Since this repo works as example how to build backend, it would be nice to have unit tests encoded in Haskell.
In order to support custom primitives for doing IO and such, it would be good to support FOREIGN
pragmas to include snippets of Scheme code into the Agda source.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.