Comments (10)
This is a duplicate of #29
You should be able to upgrade to https://github.com/purescript-node/purescript-node-fs/releases/tag/v8.1.1 for a fix.
from purescript-backend-optimizer.
If that worked, then I don't think this is a backend-es issue. In Stats.purs, the various functions are using an FFI statsMethod
to invoke the methods, so I suspect it's an issue with preserving the this
context on the JS object. I don't think a Stats object is actually a pure record that preserves PureScript semantics for records.
from purescript-backend-optimizer.
Oops, sorry didn't see that, should have searched closed issues!
from purescript-backend-optimizer.
Still seeing an error for the Async.stat
example after updating node-fs
to 8.1.1
. I think this is still likely an issue with node-fs
though, since Node.FS.Stats.StatsObj.isDirectory
(among other functions) is still typed as Fn0
(guessing it needs to be Effect
?). I'll open an issue there, and see if I can figure this out locally.
from purescript-backend-optimizer.
Can you post an example of the codegen of your main?
from purescript-backend-optimizer.
Sure, this is output-es/Main/index.js
import * as $runtime from "../runtime.js";
import * as Data$dFunction$dUncurried from "../Data.Function.Uncurried/index.js";
import * as Data$dUnit from "../Data.Unit/index.js";
import * as Effect$dConsole from "../Effect.Console/index.js";
import * as Node$dFS$dAsync from "../Node.FS.Async/index.js";
import * as Node$dFS$dStats from "../Node.FS.Stats/index.js";
import * as Node$dFS$dSync from "../Node.FS.Sync/index.js";
const main = () => {
const a$p = Node$dFS$dSync.statSyncImpl(".");
(() => {
if (Node$dFS$dStats.statsMethod("isFile", a$p)) { return Effect$dConsole.log("File."); }
return Effect$dConsole.log("Not a file.");
})()();
return Node$dFS$dAsync.stat(".")(v => {
if (v.tag === "Right") {
if (Data$dFunction$dUncurried.runFn0(v._1._1.isDirectory)) { return Effect$dConsole.log("Directory."); }
return Effect$dConsole.log("Not a directory.");
}
return () => Data$dUnit.unit;
})();
};
export {main};
Let me know if anything else would be useful.
from purescript-backend-optimizer.
I went ahead and checked all of output-es
into Git if that's helpful: https://github.com/ptrfrncsmrph/purs-backend-es-bug/tree/main/output-es
from purescript-backend-optimizer.
I'm not sure I see anything immediately obvious as codegen related, but I haven't run it or traced the error. What version of node are you using? If it's cutting edge, has anything changed in the node APIs? Can you easily try an older version?
from purescript-backend-optimizer.
Also, I don't think you are supposed to pattern match on Stats, and call runFn0 directly. I think you should use the exported isDirectory function. Can you try that? I think it's likely a mistake that the constructor is exported.
from purescript-backend-optimizer.
What version of node are you using? If it's cutting edge, has anything changed in the node APIs? Can you easily try an older version?
I was on v16.15.0, FWIW, I could still try different versions if that's still useful
I think you should use the exported isDirectory function
Yeah, that worked 🎉 . I'll open an issue about hiding the constructor Fn0
methods 👍
from purescript-backend-optimizer.
Related Issues (20)
- Highly compactable output example HOT 2
- Name clash between module and constructor name HOT 1
- spawn esbuild ENOENT HOT 1
- TCO can fail to trigger on Boolean yielding branches
- Case expressions with partial record binders incomplete HOT 2
- Bindings order differs from source file's order HOT 2
- Optimizer crashes when inline annotation on value declaration is used with `never`
- CI currently crashes on Windows HOT 1
- Add tracer to optimizer to see how original expression is transformed to optimized expression HOT 1
- Inline method calls via a directive HOT 3
- Data accessors don't add a module dependency HOT 2
- Add inline annotation for data types
- Propagate constructor refinements in branches HOT 2
- Build with source maps? HOT 3
- Optimize redundant if-else default branching HOT 4
- Add option to remove pattern match failure assertions
- Benchmark alternative Map operation implementations
- `unsafeThaw` inlining breaks Array.length checks with new SemRef handling.
- SemRef handling of PrimOp OpBooleanNot causes excessive inlining
- Issue in codegen for effect loops results in unintended fallthrough
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 purescript-backend-optimizer.