Giter Club home page Giter Club logo

Comments (10)

natefaubion avatar natefaubion commented on May 29, 2024 1

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.

natefaubion avatar natefaubion commented on May 29, 2024 1

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.

pete-murphy avatar pete-murphy commented on May 29, 2024

Oops, sorry didn't see that, should have searched closed issues!

from purescript-backend-optimizer.

pete-murphy avatar pete-murphy commented on May 29, 2024

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.

natefaubion avatar natefaubion commented on May 29, 2024

Can you post an example of the codegen of your main?

from purescript-backend-optimizer.

pete-murphy avatar pete-murphy commented on May 29, 2024

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.

pete-murphy avatar pete-murphy commented on May 29, 2024

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.

natefaubion avatar natefaubion commented on May 29, 2024

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.

natefaubion avatar natefaubion commented on May 29, 2024

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.

pete-murphy avatar pete-murphy commented on May 29, 2024

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)

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.