Questions tagged [reason]

Reason is a syntax and toolchain powered by OCaml. Use with [tag:ocaml] for questions relating to the semantics of the language, and with [tag:bucklescript] for questions relating to the JavaScript workflow.

Reason is a new syntax and toolchain powered by . It gives OCaml a familiar syntax geared toward JavaScript programmers, and caters to the existing / workflow folks already know.

Reason is tightly associated and usually used in conjunction with to target JavaScript, but can also compile to native code using the standard OCaml compiler.

Reason is an open source community project initiated and led by Facebook.

Useful resources

Related tags

360 questions
0
votes
1 answer

How to switch the type of an item in my type signature?

I'm sorry if my vernacular is wrong here. I'm very new to coding. I have created two records. I want my program to take in these two records. However, in the type signature both of the items are classified as the second record. I'm not sure how…
M Rudy
  • 27
  • 2
0
votes
1 answer

Reasonml syntax meaning |

What does this symbol mean in ReasonML | E.g type something = | SomeFunc() | AnotherFunc() I couldnt really find an answer on the ReasonML docs
hnhl
  • 127
  • 8
0
votes
1 answer

How do I add an OCaml library reference to a Reason code file?

Just began with Reason and OCaml today. I've started with the https://github.com/esy-ocaml/hello-reason sample. I want to make a HTTP API call so I've installed ocaml-cohttp with: esy add @opam/cohttp-lwt. Now I want to use that library (or any that…
Michael Mainer
  • 3,387
  • 1
  • 13
  • 32
0
votes
1 answer

How do I do regex substitutions with multiple capture groups?

I'm trying to allow users to filter strings of text using a glob pattern whose only control character is *. Under the hood, I figured the easiest thing to filter the list strings would be to use…
Jamie
  • 7,075
  • 12
  • 56
  • 86
0
votes
0 answers

How can decode similar JSON structures?

I'm using @glennsl's bs-json module to decode some JSON responses, but all the JSON responses have some common fields in addition to their unique payload. Furthermore, the JSON responses (via XMLHTTPRequest) are different depending on whether…
Jamie
  • 7,075
  • 12
  • 56
  • 86
0
votes
2 answers

How to define an abstract (opaque) interface for a polymorphic object type?

ReasonML module type T = { type t('a); // Does not work type b; // Works }; module A: T = { type t('a) = {.. b: bool} as 'a; type b = bool; }; module B: T = { type t('a) = {.. c: int} as 'a; type b = int; }; Ocaml module type T = sig …
Chris
  • 988
  • 3
  • 18
  • 30
0
votes
3 answers

How to do document.createElement in ReScript

ReScript seems to be a better way to write JS code, but I am not able to find what should be a simple single line of docs. How do I call functions like document.createElement()? I tried Js.document, Dom.document, by looking at this page:…
0
votes
1 answer

Why can't I assign a 64bit integer to this field?

Is there a numeric suffix I should be using to assign a numerical constant value to an int64 type? A moderately editted version of the error is: We've found a bug for you! {file}.re:321:20-31 321 │ let (rsid:int64) = 180785985722; This has type:…
Jamie
  • 7,075
  • 12
  • 56
  • 86
0
votes
1 answer

Is there a way to encode integer values that are larger than 32 bits using bs-json?

I've been using strings to represent decoded JSON integers larger than 32 bits. It seems the string_of_int is capable of dealing with large integer inputs. So a decoder, written (in the Json.Decode namespace): id: json |> field("id", int) |>…
Jamie
  • 7,075
  • 12
  • 56
  • 86
0
votes
1 answer

Rescript Capitalised Component

From the Rescript Documentation, it is suggested spread can be used to enable passing a pre-existing list to a component. I am confused what exactly MyComponentis in Rescript as I cannot find a way to initialise a component, which can be done with a…
heiheihang
  • 82
  • 9
0
votes
0 answers

Is it possible to partially compile a Reason+React application?

I was thinking of making the dev experience as smooth as possible and the feedback loop as short as possible when compiling the Reason+React application. If I use import React from 'react'; in a file, does that mean I have to bundle React with the…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
0
votes
1 answer

understanding module syntax defined at top of reasonml file

I am having difficulties finding an answer to the following syntax in reasonml module A = B; This is defined at the top of the .re file and I do not know where B is coming from. EDIT: When I try to log both A and B, with Js.log I get an error with…
hnhl
  • 127
  • 8
0
votes
1 answer

How to set a dynamic value as a Js.t key in ReScript?

Is there a way to set a dynamic value as a Js.t key in ReScript?
Siraj Kakeh
  • 741
  • 6
  • 20
0
votes
1 answer

How to convert a Js.Dict.t to Js.t in ReScript?

Is there a straight forward way to convert a Js.Dict.t like this one Js.Dict.fromArray([ ("bigKey", Js.Dict.fromArray([("smallKey", "value")])) ]) to Js.t like this one: { "bigKey": { "smallKey": "value" } }
Siraj Kakeh
  • 741
  • 6
  • 20
0
votes
0 answers

Can I use a compiled ReasonReact component together with the CDN version of React?

As the title states, I'd like to compile a small web component using Reason and React, and embed it on in web app that uses React via CDN, meaning no build step at all. Possible?
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57