Comments (7)
We wanted to improve the user experience for the trampoline
function by giving the user hints when you're trampolining the wrong expression in your code. Turns out it's not a good idea according to this bug report.
If you would like a contribution opportunity, the fix to this is just removing the following lines in the runtime system:
https://github.com/typelead/eta/blob/master/rts/src/main/java/eta/runtime/stg/Stg.java#L82-L88
If not, we'll get around to fixing this by the next release.
from eta-hackage.
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.
from eta-hackage.
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 Thunk
like normal functions
from eta-hackage.
@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 mentioned - if you use the trampoline
function wrong (try to trampoline a function directly that's not a thunk), it can throw 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 valueseta.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 Formeta.runtime.stg.DataCon
- The superclass of all ADTseta.runtime.apply.Function
- The superclass of all functionseta.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 mentioned.
So I think the true fix has to be a better if
condition. Perhaps if (!(closure instanceof Thunk) && !(closure instanceof DataCon))
.
from eta-hackage.
from eta-hackage.
Great. Btw, if you have successfully source installed the master
version of Eta, a fast way to test changes to the runtime can be done with:
stack exec eta-build -- rts-clean
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 ~/.gradle/caches/etlas
before doing that step).
from eta-hackage.
Should be resolved after typelead/eta#896 submitted by the OP.
from eta-hackage.
Related Issues (20)
- dhall-to-etlas doesn't build due to ansi-terminal dependency HOT 2
- Issue with compiling language-javascript HOT 1
- Patch cborg-0.2.0.0 HOT 1
- cryptohash-md5 and cryptohash-sha1 large input test HOT 1
- Patch for cql-io HOT 1
- Patch for pandoc 2.5 HOT 2
- failure on Text.Regex.mkRegex HOT 3
- Patch needed to install Reflex? Dependency on haskell-src-exts-1.20.3 HOT 2
- Get Duckling to work HOT 9
- "regex-compat" package behavior is inconsistent with GHCi
- Temporary library -- creation of temp files does not work on windows platform HOT 3
- request: Patch pretty-show-1.6.16 HOT 1
- Patch the Cabal library HOT 1
- directory-1.3.1.0 fix createDirectoryIfMissing HOT 4
- Patch megaparsec package to avoid StackOverflowException's HOT 14
- Patch criterion + support for JMH HOT 12
- Request: patch cryptohash-md5 and cryptohash-sha1 HOT 2
- [Patch Request] MissingH-1.4.0.1 HOT 3
- Patch text-show-3.7.3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eta-hackage.