joyride

pez 2022-05-25T13:32:01.424459Z

Looking at the REPL evaluation API of Calva here. I have it working. But there's a thing around how the promises resolve that I don't quite understand. Wonder if someone here might have some time to look at it with me so that I can get the docs right. Opening a huddle here a while and anyone can just join. 😃

pez 2022-05-26T07:45:26.944529Z

Does this look right to you, @alpox?

type Result = {
  result: string;
  ns: string;
  output: string;
  errorOutput: string;
};

export async function evaluateCode(
  sessionKey: 'clj' | 'cljs',
  code: string,
  output?: {
    stdout: (m: string) => void;
    stderr: (m: string) => void;
  }
): Promise<Result> {
  const session = replSession.getSession(sessionKey);
  if (!session) {
    throw new Error(`Can't retrieve REPL session for session key: ${sessionKey}.`);
  }
  const stdout = output
    ? output.stdout
    : (m: string) => {
        state.outputChannel().append(m);
      };
  const stderr = output
    ? output.stdout
    : (m: string) => {
        state.outputChannel().append(`Error: ${m}`);
      };
  const evaluation = session.eval(code, undefined, {
    stdout: stdout,
    stderr: stderr,
    pprintOptions: printer.disabledPrettyPrinter,
  });
  return {
    result: await evaluation.value,
    ns: evaluation.ns,
    output: evaluation.outPut,
    errorOutput: evaluation.errorOutput,
  };
}

👍 1
alpox 2022-05-26T07:58:25.995669Z

Yes, this looks fine to me

🙏 1
pez 2022-05-25T14:03:36.133939Z

Spoke too early about having it working. I can right now only get it to work if I am connected to the Joyride REPL. Very strange. But it is also super hard to keep track of which REPL is supposed to do what in this dance...

pez 2022-05-25T14:10:16.516989Z

Huddle off for now. I'll be a bit afk now and then. Holler if you wanna huddle. 😃

alpox 2022-05-25T16:46:26.717379Z

I have some promises experience. May find some time for huddling around 19:00 UTC if you still want to by then

pez 2022-05-25T17:18:25.314089Z

Thanks for the offer! I want, but can't be online until about 21-22 CET.

alpox 2022-05-25T17:20:25.098729Z

That should work for me as well :-) you can ping me when you are available and Ill try to jump in

pez 2022-05-25T19:44:51.993769Z

I'm back in the twilight zone between REPLs.

pez 2022-05-25T21:03:06.393119Z

Thanks for that session, @alpox! Super fun and very important feedback on the API.

alpox 2022-05-25T21:10:10.897659Z

Thanks as well for the fun session. Always happy to help.

alpox 2022-05-25T21:30:17.422069Z

@pez I just took a peek again in the nrepl evaluation code (setHandler) - while for the reader its not directly obvious I don't see a possibility/case for it to go wrong, so its surely nothing to worry about.

🙏 1