-
Notifications
You must be signed in to change notification settings - Fork 31
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
lens-aeson examples throw IllegalStateExceptions #120
Comments
We wanted to improve the user experience for the If you would like a contribution opportunity, the fix to this is just removing the following lines in the runtime system: If not, we'll get around to fixing this by the next release. |
Thanks @rahulmutt! I see that it is trying to trampoline via an Eta Hackage patch here, but I'm not sure why it would fail in this specific case: https://github.com/typelead/eta-hackage/blob/master/patches/aeson-1.2.4.0.patch. As you said, maybe the aeson patch is trampolining on the wrong expression. I'll pull down the eta compiler repo and see if I can get it to compile, because this looks like it would be educational. |
If i remember correctly i got that error when using trampoline in a class instance method impl, so it seems internally it is not represented by a |
@mmisamore Actually, the The The basic hierarchy for Eta values:
The The problem here is that So I think the true fix has to be a better |
Awesome write-up! I'll see if I can fix it soon based on your suggestion.
…On Wed, Oct 24, 2018, 10:23 PM Rahul Muttineni ***@***.***> wrote:
@mmisamore <https://github.com/mmisamore> Actually, the aeson package is
trampolining on the *right* expression, it's that the change in the
trampolining implementation that I highlighted *thinks* that it's a wrong
expression. That change was added very recently and I think we didn't test
against an example like lens-aeson. We should probably add this example
to the test suite to catch future regressions.
The if condition that determines whether an exception should be thrown
was added because of what @jneira <https://github.com/jneira> mentioned -
if you use the trampoline function wrong (try to trampoline a function
directly that's not a thunk), it can thrown really nasty exceptions that
are less readable than the one you got.
The basic hierarchy for Eta values:
- eta.runtime.stg.Closure - The superclass of all Eta values
- eta.runtime.thunk.Thunk - The superclass of all yet-to-be
evaluated expressions.
- eta.runtime.stg.Value - The superclass of all thunks that have
been evaluated to Weak Head Normal Form
- eta.runtime.stg.DataCon - The superclass of all ADTs
- eta.runtime.apply.Function - The superclass of all functions
- eta.runtime.apply.PAP - Stores "pending arguments" for curried
functions and can be thought of as a function itself, though the hierarchy
doesn't reflect it (yet).
The trampoline function calls the enter method of the Closure that is
passed to it. The enter method for subclasses of Value *other* than
Function and PAP simply returns itself because they don't have any code
attached to them. For Function and PAP, enter will execute the code of
the respective function and retrieves the argument(s) from the ubiquitous
StgContext object (the object that stores the runtime state for the
particular thread of execution).
The problem here is that trampoline does not pass any arguments! So when
you try to trampoline against a function directly and not a thunk that
*evaluates* a function, it will cause nasty errors that @jneira
<https://github.com/jneira> mentioned.
So I think the true fix has to be a better if condition. Perhaps if
(!(closure instanceof Thunk) && !(closure instanceof DataCon)).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#120 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGJUygetd6B1k662GNby_cjIkTAYrLqHks5uoSCDgaJpZM4X0bl_>
.
|
Great. Btw, if you have successfully source installed the
All future Eta project compilations will use the new version of the runtime with your changes (unless you're using Gradle to compile your Eta projects, in which case you should wipe out |
Should be resolved after typelead/eta#896 submitted by the OP. |
Description
lens-aeson examples are throwing runtime exceptions.
Steps to Reproduce
or
"42" ^? _Integer
Expected
Just 1.0
or
Just 42
Actual
Environment
etlas version 1.5.0.0
compiled using version 2.1.0.0 of the etlas-cabal library
The text was updated successfully, but these errors were encountered: