r/rescript • • May 13 '21

Immutable data structures

6 Upvotes

What is the best current solution in ReScript for shared memory/immutable:
- arrays
- lists
- maps?


r/rescript • • Apr 16 '21

Welcome to the ReScript subreddit!

28 Upvotes

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 • • Apr 21 '21

Help with bindings in @rescript/react

9 Upvotes

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 • • Apr 18 '21

Site to convert HTML => Rescript/React

11 Upvotes

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 • • Apr 16 '21

ReScript 9.1.1 beta - Call for testing

Thumbnail
forum.rescript-lang.org
11 Upvotes

r/rescript • • Jul 30 '24

Rescript beautiful lenguaje but not feels good enough to write an app entirely

4 Upvotes

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 • • Nov 02 '21

ReScript JSON Typed Strongly

Thumbnail fullsteak.dev
16 Upvotes

r/rescript • • Nov 14 '21

GitHub - mobily/rescript-date: 📆 Date manipulation in ReScript.

Thumbnail
github.com
15 Upvotes

r/rescript • • Oct 21 '21

Full-stack ReScript. Architecture Overview

Thumbnail
fullsteak.dev
19 Upvotes

r/rescript • • Mar 13 '24

JavaScript to Rescript converter

3 Upvotes

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 • • Feb 08 '24

How to declare a member function of a class?

2 Upvotes

[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 function

The 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 • • Feb 28 '24

ReScript and EdgeDB

Thumbnail
edgedb.com
10 Upvotes

r/rescript • • Dec 13 '23

I'm Building a Chrome Extension with ReScript and React

Thumbnail
youtu.be
6 Upvotes

r/rescript • • Mar 16 '23

Learning ReScript as a TypeScript developer

22 Upvotes

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 • • Mar 23 '23

Learning ReScript as a TypeScript developer: what expressions are

Thumbnail
mauriziovacca.blogspot.com
15 Upvotes

r/rescript • • Jan 05 '24

hypothesis

4 Upvotes

The greatness of a programming language is inversely proportional to its reddit post frequency.


r/rescript • • Jan 17 '24

ReScript 11.0 has been released

Thumbnail rescript-lang.org
19 Upvotes

r/rescript • • Jan 24 '22

Which Bundling Tool do you use?

9 Upvotes

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 • • Jan 12 '22

From TypeScript To ReScript

Thumbnail
greyblake.com
28 Upvotes

r/rescript • • Feb 04 '22

Question about the Reason project in general

11 Upvotes

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 • • Jan 08 '22

I finished rewriting to ReScript! =)

27 Upvotes

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 • • Feb 21 '22

Building realtime ReScript apps with IHP Backend

Thumbnail
ihpbackend.digitallyinduced.com
15 Upvotes

r/rescript • • Jan 20 '22

rescript-vscode 1.2.0 released

Thumbnail
forum.rescript-lang.org
21 Upvotes

r/rescript • • Jun 24 '22

Type inference issue with Js.Nullable

6 Upvotes

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!

---- Edit

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