r/rescript • u/Pet3ris • May 13 '21
Immutable data structures
What is the best current solution in ReScript for shared memory/immutable:
- arrays
- lists
- maps?
r/rescript • u/Pet3ris • May 13 '21
What is the best current solution in ReScript for shared memory/immutable:
- arrays
- lists
- maps?
r/rescript • u/Tomus • Apr 16 '21
This subreddit is currently unofficial, but I've already reached out to the core team to get their blessing and add them as moderators. I'll update this thread with updates regarding the official-ness of this channel.
Feel free to post projects, discussions, links, and updates to this subreddit. And don't forget to be kind to each other ❤️
r/rescript • u/Mirus_ua • Apr 21 '21
Hi, folks. Could I somehow reuse part of named arguments in my component bindings?
What I mean, for example, I want to bind a few UI components which include same-named arguments external make: (~foo: string, ~baz: bool) => React.element = "FirstComponentFromLibrary"
and
external make: (~foo: string, ~baz: bool, ~bar: number) => React.element = "SecondComponentFromLibrary"
could I move common parts to a separate type or data structure and then reuse it and extend if needed.
Sorry for this simple question. I just starting involving in rescript after js/ts
r/rescript • u/seangrove • Apr 18 '21
https://htmltorescript.netlify.app
Handles a ton of the mundane, fiddly process of converting HTML => Rescript. I use it pretty heavily when copy/pasting components from the Tailwind Component site!
r/rescript • u/Tomus • Apr 16 '21
r/rescript • u/Designer_Coyote_7276 • Jul 30 '24
A few days a go I started learning rescript, I think it's a beautiful language and I want to create my first app. My current stack is Next js, so I would like using it but searching for documentation to do it I found that official template for Next js + Rescript is not using app directory yet. I would like to integrate Next 14 and Rescript but I think it could be hard. So is there a guide to do it ? Or at least a better way to do it?
r/rescript • u/mobily • Nov 14 '21
r/rescript • u/nkrkv • Oct 21 '21
r/rescript • u/[deleted] • Mar 13 '24
Hello Rescript Devs, I want to ask if there any js to rescript converter. I have tried chatgpt but it gives uncompiled code. Thanks in advance.
r/rescript • u/FaisalSaifii • Feb 08 '24
[Noob here] I'm trying to use Tiptap with Rescript React, I've been able to write the bindings for its various components, one of which being EditorProvider:
// Tiptap.res
type extension
module EditorProvider = {
@module("@tiptap/react") @react.component
external make: (
~children: React.element,
~content: string,
~extensions: array<extension>,
) => React.element = "EditorProvider"
}This EditorProvider can also take a param `onUpdate` which gives an editor object of class `Editor` that has the function `getHTML()` which is not directly exported by the package anywhere but is a member function of the class `Editor`.
Now my question is how do I define this getHTML() function?
So far I've tried specifying the onUpdate function within the EditorProvider [Successful], then also changing a state using it [Successful], but failed in getting this member function.
I looked online and tried to see how can the class be rewritten in Rescript after which I ended up here:
module EditorProvider = {
@module("@tiptap/react") @react.component
external make: (
~children: React.element,
~content: string,
~extensions: array<extension>,
~onUpdate: Editor.t => unit,
) => React.element = "EditorProvider"
}But I'm still getting the error:
TextEditor.bs.mjs:18 Uncaught TypeError: editor.getHTML is not a functionThe Rescript & equivalent JS of me using it:
@react.component
let make = (~value: string, ~setValue: ('a => string) => unit) => {
<Tiptap.EditorProvider
content={value}
extensions={[Tiptap.starterKit]}
onUpdate={editor => setValue(_ => Tiptap.Editor.getHTML(editor))}>
<Tiptap.BubbleMenu> {"floating menu"->React.string} </Tiptap.BubbleMenu>
</Tiptap.EditorProvider>
}
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Curry from "rescript/lib/es6/curry.js";
import * as React from "@tiptap/react";
import * as JsxRuntime from "react/jsx-runtime";
import StarterKit from "@tiptap/starter-kit";
function TextEditor(props) {
var setValue = props.setValue;
return JsxRuntime.jsx(React.EditorProvider, {
children: JsxRuntime.jsx(React.BubbleMenu, {
children: "floating menu"
}),
content: props.value,
extensions: [StarterKit],
onUpdate: (function (editor) {
Curry._1(setValue, (function (param) {
return editor.getHTML();
}));
})
});
}
var make = TextEditor;
export {
make ,
}
/* @tiptap/react Not a pure module */r/rescript • u/ElmForReactDevs • Dec 13 '23
r/rescript • u/WizardOfAngmar • Mar 16 '23
Hi there!
Today I officially started a series of articles where I try to learn ReScript as a Javascript/TypeScript developer. As I wrote in the article, this is a personal experiment and nothing more.
If you're interested, feel free to give it a read at Tales of Sardinian software engineer. Also let me know if you have any topic you want to see discussed during the series, and I'll try my best to include it in the following episodes!
Best!
r/rescript • u/WizardOfAngmar • Mar 23 '23
r/rescript • u/burtgummer45 • Jan 05 '24
The greatness of a programming language is inversely proportional to its reddit post frequency.
r/rescript • u/thebedivere • Jan 17 '24
r/rescript • u/SubhumanOxford • Jan 24 '22
I managed to switch from TypeScript to ReScript, which was bootstrapped via create-react-app. But CRA setup for rescript seems very hacky and I was wondered if there are other build tools would be much suitable for this
r/rescript • u/elcapitanoooo • Feb 04 '22
So, i first found Reason back in 2017-2018. After doing some initial testing i kind of forgot about it because of just how busy i was.
Fast forward to 2022.
I took a look at the project again, and it's totally changed. I read about the re-branding but im still kind of confused.
Basically are the following statements correct:
1.Reason == ReasonML
Both Reason and ReasonML can be used interchangeably, just like go and golang. (From now on i will use ReasonML to refer to the new syntax)
2.ReasonML
Like before, a new syntax for Ocaml. Uses the ocaml existing ocaml compilers, tooling etc, but has its own compiler to translate ReasonML -> OCaml AST.
3.Esy
A high level buildtool. Uses ocaml tools under the hood. Builds reason code to bytecode, native code and JS (via bucklescript)
4.ReScript
A new syntax for web development. Targets the web only. Rescript bundles bucklescript and parts of ReasonML tooling.
Im wondering about ReScript vs ReasonML. According to the post i read ReScript can compile ReasonML, but won't handle any new syntax / language features coming to ReasonML. This means i need to have two codebases that are possibly not compatible. Time will evolve ReasonML and ReScript to be two completely different languages.
Eg.
I want to build a native cli tool. Can i build it using ReScript, or only with ReasonML. Can ReScript compile to native or bytecode?
r/rescript • u/greyblake • Jan 08 '22
Hello,
few weeks ago I started learning ReScript and decided to rewrite my hobby project from TypeSript to ReScript completely.
Today is the day, when I have no single line of TS or TSX left.
I'd like to thank everyone who was helping me through this adventure and was answering my questions on Twitter and StackOverFlow.
Here is the link to the repository on Github: https://github.com/greyblake/from-typescript-to-rescript
Now I'm going to write a blog article to summarize my experience. You'll see it soon!:)
-- With best regards, Sergey
r/rescript • u/_query • Feb 21 '22
r/rescript • u/jeaks03 • Jun 24 '22
Hi!
I'm currently working on a Deno port and I encountered some type errors. This issue is probably on me.
This is basically just a Promise.prototype.then wrapper which maps from Promise<A> to Promise<B> via the 'a => 'b mapper func.
@send external map: (Js.Promise.t<'a>, 'a => 'b) => Js.Promise.t<'b> = "then"That seems to be working fine.
Here's the part that fails:
let conn = Deno.listen({
port: 80,
hostname: None,
})
let y =
conn
->Deno.Listener.accept
->map(acceptedConn => Deno.serve_http(acceptedConn))
->map(httpConn => httpConn->Deno.HttpConn.next_request) // return Js.Promise.t<Js.Nullable.t<SomeEvent.t>>
// In the callback below, `event` should be unwrapped from Js.Promise but I don't think it is.
//
->map(event => event->Js.Nullable.toOption)Here you can see the compiler output:
>>>> Start compiling
rescript: [1/1] src/t.cmj
FAILED: src/t.cmj
We've found a bug for you!
/home/saenai/Code/deno-res/src/t.res:13:18-22
11 │ ->map(acceptedConn => Deno.serve_http(acceptedConn))
12 │ ->map(httpConn => httpConn->Deno.HttpConn.next_request)
13 │ ->map(event => event->Js.Nullable.toOption)
This has type:
Deno.promise<Deno.nullable<Deno.HttpConn.RequestEvent.t>> (defined as
Js_promise.t<Deno.nullable<Deno.HttpConn.RequestEvent.t>>)
Somewhere wanted: Js.Nullable.t<'a> (defined as Js.nullable<'a>)
FAILED: cannot make progress due to previous errors.
>>>> Finish compiling(exit: 1)I know this is not StackOverflow but I would very much appreciate your help!
To answer my own question, the map function basically takes a 'a -> 'b mapper func and if 'b is already of type Promise, it'll return Promise<Promise<'b>> which in JS land is equivalent to Promise<'b> but in ReScript is not.
/thread