Giter Club home page Giter Club logo

Comments (7)

JordanMartinez avatar JordanMartinez commented on May 29, 2024 1

I'd bet it's node-fs.

from purescript-backend-optimizer.

natefaubion avatar natefaubion commented on May 29, 2024

Can you post the full codegen for your repro?

from purescript-backend-optimizer.

colinwahl avatar colinwahl commented on May 29, 2024

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.

natefaubion avatar natefaubion commented on May 29, 2024

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.

colinwahl avatar colinwahl commented on May 29, 2024

That makes sense - thanks for confirming.

I'll go ahead and close this & move the conversation over there.

from purescript-backend-optimizer.

natefaubion avatar natefaubion commented on May 29, 2024

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.

colinwahl avatar colinwahl commented on May 29, 2024

Aha, this was already logged against node-fs: purescript-node/purescript-node-fs#28

from purescript-backend-optimizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.