-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type-based compilation of everything + fix for #264 #304
Conversation
…Var`, instead only check where needed
We only call `compileType` on terms whose type compiles to a Haskell type, so if we encounter a lambda it is safe to erase it.
… foralls - removed old and buggy `compileTopLevelType` function - new possible output `DomForall` of `compileDomType`, which is produced for type arguments coming from the module telescope - new `compilingLocal` field in `CompileEnv` keeps track of whether the function we are currently compiling is a local function (e.g. where function or extended lambda) - `compileFun'` now always starts in the top-level context and then introduces module parameters for local functions
One current limitation is that you cannot have module _ {a : Set} where
f1 : a → a
f1 x = f2 id
where module _ {b : Set} where
f2 : (a → b) → b
f2 g = f3 (g x)
where module _ {c : Set} where
f3 : c → c
f3 x = x
{-# COMPILE AGDA2HS f1 #-} is compiled to the rather sad f1 : forall a . a -> a
f1 x = f2 id The reason why the definitions of agda2hs/src/Agda2Hs/AgdaUtils.hs Lines 41 to 42 in 0611268
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I have more questions than remarks really, have yet to think of more tests to add.
This was a regression introduced by agda#304 that went unnoticed due to a lack of a (failing) test case
This was a regression introduced by agda#304 that went unnoticed due to a lack of a (failing) test case
This was a regression introduced by agda#304 that went unnoticed due to a lack of a (failing) test case
This was a regression introduced by #304 that went unnoticed due to a lack of a (failing) test case
This PR continues on the path that @flupe has started with #270 and pushes type-based compilation to every corner of
agda2hs
. It also fixes #264 by removing the horriblecompileTopLevelType
function and introducing a better way to handle explicitforall
s.Ignoring a number of refactorings, this PR makes the following semantic changes to
agda2hs
:Level
,Size
, and any type inProp
are now allowed (and dropped during compilation).forall
s to each top-level function in the module, while other parameters are compiled as normal arguments.The test suite passes and I have added some minimal extra tests, but it could definitely still use some more testing, so please let me know if you have any examples you'd like me to try.