Questions tagged [bucklescript]

BuckleScript was previously known as a compiler for compiling OCaml to efficient JavaScript code. It has now evolved into the ReScript language. Use the [rescript] tag instead.

BuckleScript was previously known as a back-end for which emits readable, modular and highly performant JavaScript.

On July 2020, BuckleScript (and some parts of the ReasonML syntax) evolved into the ReScript language platform. The term "BuckleScript" is therefore deprecated. Use the tag for BuckleScript specific questions instead.

Useful resources

Related tags

181 questions
4
votes
1 answer

Circular dependency reasonml

Let's say that I have a 1 -> n relation: one todo can has many (or zero) notes and a note can have zero or one todo. How can I achieve this relation in ReasonML? (binding for an external lib) Here is what I have come with at the moment (which is of…
Quang Linh Le
  • 751
  • 1
  • 7
  • 16
4
votes
1 answer

Is it possible to not export a module in BuckleScript?

Is it possible to not export certain internal modules that should not be used directly by package consumers?
norvana
  • 45
  • 3
4
votes
2 answers

How to define a binding that accepts multiple types in the function signature using reason-react?

When defining a reason-react binding and I want to know how I can determine a binding that accepts multiple types. For example, I have an argument ~value that should accept: string, number, array(string) or array(number). At the moment I am using…
user465374
  • 1,521
  • 4
  • 20
  • 39
4
votes
1 answer

How to extend JS class in ReasonML

For example, I have an es6-like class: class Foo {...} And I want to extend it: class Bar extends Foo {...} In reason-react documentation I found examples, but I'm not sure that it's appropriate for me: let component = ReasonReact.reducerComponent…
S. Zobov
  • 154
  • 2
  • 15
4
votes
1 answer

Reasonml type with multiple arguments, Error exception Failure("nth")

I have got Error while compiling the following code type shape = | Circle int | Square int | Rectangle int int; let myShape = Circle 10; let area = switch myShape { | Circle r => float_of_int (r * r) *. 3.14 | Square w => float_of_int…
kkpoon
  • 1,939
  • 13
  • 23
3
votes
1 answer

How do I implement hash functions for arbitrary record types in ReScript?

I'm exploring ReScript for the first time. I want to build a hashmap using a record type as my key type, and I'm looking for guidance on implementing the hash function. Here's my ReScript code: type pointer = { id: string, table: string, spaceId:…
Just Jake
  • 4,698
  • 4
  • 28
  • 33
3
votes
1 answer

What does the following warning mean?

What does the following warning mean and how can I fix its cause? Warning: Unimplemented primitive used:removeEventListener in [@bs.val] external addEventListener: (string, unit => unit) => unit = "addEventListener"; external removeEventListener:…
Raphael Rafatpanah
  • 19,082
  • 25
  • 92
  • 158
3
votes
1 answer

How to display emojis with ReasonReact?

Is there an easy way to insert emojis with ReasonReact? In ReactJS, you can simply type the emoji and it renders as expected, but that doesn't seem to be the case in Reason. If you try this: {React.string("")}…
user11305879
3
votes
3 answers

ReasonML binding function with config having fixed string values

Lets say, that I have this function in Javascript which can generate string based on proper configuration: function func(config) { // ... } also, let's assume, that the config variable has structure as below (all of these can be not given to…
Jazi
  • 6,569
  • 13
  • 60
  • 92
3
votes
2 answers

Compile error using fast pipe operator after pipe last in ReasonML

The way that the "fast pipe" operator is compared to the "pipe last" in many places implies that they are drop-in replacements for each other. Want to send a value in as the last parameter to a function? Use pipe last (|>). Want to send it as the…
Julian Suggate
  • 627
  • 1
  • 6
  • 14
3
votes
1 answer

Accessors name conflict trying to create a binding

I'm trying to create a binding for an existing javascript library but I'm getting an error when I try to use the property access function. [@bs.deriving abstract] type objA = { prop1: string, prop2: string, prop3: string, }; [@bs.deriving…
Diullei
  • 11,420
  • 2
  • 27
  • 31
3
votes
1 answer

Understanding Js.Promise.resolve(. ) dot syntax in ReasonML

I'm trying to understand the docs: https://reasonml.github.io/docs/en/promise In the usage section there is: let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2)); Why is there is dot before the 2? What does it mean and what does it…
Homan
  • 25,618
  • 22
  • 70
  • 107
3
votes
1 answer

What does Json.Decode.{} mean? The dot curly braces part

I'm trying to learn ReasonML and following the example for bs-json we can decode raw json into a type like this: type point = { x: float, y: float }; module Decode = { let point = json => Json.Decode.{ x: json |> field("x",…
Homan
  • 25,618
  • 22
  • 70
  • 107
3
votes
1 answer

What is the simplest way to split a string into a list of characters?

This appears to be covered by the Str module in the api documentation but according to this issue opened this is an oversight.
Tony
  • 395
  • 3
  • 10
3
votes
1 answer

How to get innerHTML of each element in a node list

Say I have the following html:
one
two
three
I would like to log the innerHTML for each element. I have tried the following: document |> Document.querySelectorAll(".item") |>…
Sam Houston
  • 3,413
  • 2
  • 30
  • 46
1
2
3
12 13