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
2
votes
1 answer

ReasonML cycle dependency

I'm working on a bucklescript binding to leafletjs based on this project . With leaflet a Map has a function to add layer and a Layer has a function to add itself to a map. This is what I would like to achieve with ReasonML : module Map = { type…
Yvain
  • 882
  • 1
  • 10
  • 27
2
votes
1 answer

An example of how to use Belt.Set in ReasonML?

I have a simple variant. say: type fooVariant = | Foo | Bar | Baz; And I want an efficient, type safe, immutable set. I'm thinking that Belt.Set sounds like what I wan't. However, being at the start of my ReasonML learning I can't quickly…
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
2
votes
1 answer

Reason-react rendering list of items from json

I'm learning reason react and am having trouble rendering a list of items I'm fetching from a json api. let url = region => { "https://api.openbrewerydb.org/breweries?by_state=" ++ Js.String.replaceByRe([%re "/\\s/g"], "_",…
2
votes
2 answers

ReasonML Signature Mismatch

I'm getting a signature mismatch in ReasonML between a type I defined which resolves to type mutationFunctionType = (~id: UUID.t, ~classroomId: UUID.t, unit) => unit; and 'a which I'm expecting. (seen below). [1] Signature mismatch: [1] ... [1]…
GTDev
  • 5,488
  • 9
  • 49
  • 84
2
votes
1 answer

How to pass a reserved keyword as a prop in reason-react

I am trying to use the rimble-ui ui-library, and one of the props that a button takes is called "as". This is unfortunately a reserved word in reason. So I don't know how to use this component in my reason-react app. Here are the docs for the…
JasoonS
  • 1,432
  • 3
  • 13
  • 26
2
votes
1 answer

How can I curry a function with optional parameters that generates Js.t objects in ReasionML/BuckleScript?

I have the following function [@bs.obj] external route: ( ~_method: string, ~path: string, ~action: list(string) => unit, ~options: Js.t({..})=?, unit ) => _ = ""; Since functions can be partially applied, I expect to be…
fhdhsni
  • 1,529
  • 1
  • 13
  • 21
2
votes
1 answer

module name is shadowing global name used in binding

tl;dr: How to change the following binding to be able to write Intl.DateTimeFormat.make() instead of Intl_.DateTimeFormat.make()? type dateTimeFormat; [@bs.deriving abstract] type formatOptions = { [@bs.optional] weekday: string, …
kamituel
  • 34,606
  • 6
  • 81
  • 98
2
votes
1 answer

How to extend JavaScript HTMLElement class in ReasonML for web component?

For the following JavaScript code, how can I write it in ReasonML? class HelloWorld extends HTMLElement { constructor() { super(); // Attach a shadow root to the element. let shadowRoot = this.attachShadow({mode: 'open'}); …
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
2
votes
1 answer

How to use a bucklescript library with rtop in an esy project?

I am attempting to use rtop as repl on an esy project. In order to do so, I have added "@esy-ocaml/rtop":"*" to the devDependencies section of my package.json file, and tried to start rtop with esy rtop: { ..., "dependencies": { "react":…
Pedro Rolo
  • 28,273
  • 12
  • 60
  • 94
2
votes
1 answer

Having trouble getting event data from event listener in ReasonReact

I'm trying to implement dynamic column resizing on a table (like in Excel or Google Sheets). In my render function I use the handle callback when the user clicks mouse down on my resize control:
Homan
  • 25,618
  • 22
  • 70
  • 107
2
votes
1 answer

ReasonML access JS record field

Say I have a global object called Example, which has a constructor such that new Example() returns an object with a key called "Messaging" Say I have the following Reason/Bucklescript Code: [@bs.deriving abstract] type example = { [@bs.as…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
2
votes
0 answers

JEST in package.json

I have a question about MatchTest in package.json I have a file call EventSourceMock.bs.js which is a library to mock event source. Plus I have other files like CalculatorTest.bs.js Then my package MatchTest is set to this…
2
votes
1 answer

Untagged union from a javascript binding going down the wrong path

I am attempting to write a reasonml binding for the amqplib npm package: http://www.squaremobius.net/amqp.node/ In particular this function: http://www.squaremobius.net/amqp.node/channel_api.html#channel_get class type amqpMessageT = [@bs] { pub…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
2
votes
1 answer

reasonml record vs JS object

Say I define the following types: type queueParams = { durable: bool }; class type amqpChannelT = [@bs] { pub assertQueue: string => queueParams => Js.Promise.t(unit); }; Then calling the following: channel##assertQueue("exampleQueue",…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
2
votes
2 answers

Record field notes can't be found

I'm trying define a variable with mutually recursive module, let's say a Todo can have many Note and a Note can belongs to a Todo: module Sig = { module type NoteSig = {type t;}; module type TodoSig = {type t;}; }; /* same file */ module Same =…
Quang Linh Le
  • 751
  • 1
  • 7
  • 16