Comments (7)
I'd bet it's node-fs
.
from purescript-backend-optimizer.
Can you post the full codegen for your repro?
from purescript-backend-optimizer.
Yep - here ya go.
// output-es/Effect.Console/foreign.js
var log = function(s) {
return function() {
console.log(s);
};
};
// output-es/Foreign/foreign.js
var isArray = Array.isArray || function(value) {
return Object.prototype.toString.call(value) === "[object Array]";
};
// output-es/Node.FS.Stats/foreign.js
function statsMethod(m, s) {
return s[m]();
}
// output-es/Data.Bounded/foreign.js
var topChar = String.fromCharCode(65535);
var bottomChar = String.fromCharCode(0);
var topNumber = Number.POSITIVE_INFINITY;
var bottomNumber = Number.NEGATIVE_INFINITY;
// output-es/Data.String.CodePoints/foreign.js
var hasArrayFrom = typeof Array.from === "function";
var hasStringIterator = typeof Symbol !== "undefined" && Symbol != null && typeof Symbol.iterator !== "undefined" && typeof String.prototype[Symbol.iterator] === "function";
var hasFromCodePoint = typeof String.prototype.fromCodePoint === "function";
var hasCodePointAt = typeof String.prototype.codePointAt === "function";
// output-es/Node.FS.Sync/foreign.js
import {
renameSync,
truncateSync,
chownSync,
chmodSync,
statSync,
lstatSync,
linkSync,
symlinkSync,
readlinkSync,
realpathSync,
unlinkSync,
rmdirSync,
rmSync,
mkdirSync,
readdirSync,
utimesSync,
readFileSync,
writeFileSync,
appendFileSync,
existsSync,
openSync,
readSync,
writeSync,
fsyncSync,
closeSync
} from "fs";
// output-es/Main/index.js
var main = () => {
const a$p = (v) => statSync("spago.dhall")();
if (statsMethod("isFile", a$p)) {
return log("File.")();
}
return log("Not file.")();
};
// <stdin>
main();
from purescript-backend-optimizer.
Ah, I see. The associativity of
(v) => statSync("spago.dhall")();
Is intended to be
((v) => statSync("spago.dhall"))();
The reason I don't handle it is that there is no language semantics that defines a PureScript function as being an Effect. Effect is necessarily foreign, and Effect binding on a PureScript function does not make sense semantically. My opinion is that node-fs is just wrong, and probably was written before EffectFn was introduced. EffectFn solves the use case of JavaScript function calling convention. Alternatively, mkEffect
could be foreign instead of unsafeCoerce
.
from purescript-backend-optimizer.
That makes sense - thanks for confirming.
I'll go ahead and close this & move the conversation over there.
from purescript-backend-optimizer.
Note, I think it's the case that codegen should probably still be fixed, because at a syntactic level it's an issue of incorrect precedence, and I think that will be fixed by #9. But I think the implementation of node-fs is still just wrong.
from purescript-backend-optimizer.
Aha, this was already logged against node-fs
: purescript-node/purescript-node-fs#28
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.