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
64
votes
6 answers

ReasonML vs TypeScript

What are the tradeoffs between ReasonML (https://reasonml.github.io/) and TypeScript (https://www.typescriptlang.org/)?
nobody
  • 7,803
  • 11
  • 56
  • 91
20
votes
1 answer

How to use npm packages with ReasonML?

I'm quite experienced with ReactJS and now I'm trying to learn ReasonML. But one thing that I've been struggling to understand, is how to import npm packages with React/Reason. The instructions on the website are kinda unclear to me…
KadoBOT
  • 2,944
  • 4
  • 16
  • 34
18
votes
2 answers

What's the difference between -> and |> in reasonml?

A period of intense googling provided me with some examples where people use both types of operators in one code, but generally they look just like two ways of doing one thing, they even have the same name
Crysknight
  • 291
  • 2
  • 8
8
votes
4 answers

How to add a copyright symbol in reason-react component?

I’m new to reason-react. I’m trying to put a copyright symbol in a react-reason component. I've tried (ReasonReact.stringToElement("©")) but this doesn’t give me the © symbol.
bonheury
  • 362
  • 1
  • 5
  • 14
7
votes
1 answer

How can I parse a string to an integer with Reasonml/Bucklescript?

I'm learning Reasonml, and I can't find any function in the standard library to do so, neither of the Bucklescript Js modules. Is there any better option than using raw javascript? Right now I'm achieving it with this function: let parseint: string…
gabrielperales
  • 6,935
  • 1
  • 20
  • 19
7
votes
2 answers

How to target subdirectories in BuckleScript bsconfig.json

I have the following folder structure --| button --|--| button.re main.re In my bsconfig.json, using the quickstart guide found here. I have in my config the following key/value: "sources": [ "src/" ] It is only targeting the main.re file. I…
Charlie-Greenman
  • 1,469
  • 1
  • 16
  • 36
5
votes
1 answer

How to bind to and use a higher-order component in ReasonReact

Let's say I have a higher-order component, something like the following trivial definition, exported from the JavaScript module ./hoc.js: export const withStrong = Component => props => Assuming I have…
glennsl
  • 28,186
  • 12
  • 57
  • 75
5
votes
1 answer

How to write reasonml binding for a union type

I am trying to write bindings for https://github.com/oblador/react-native-keychain/blob/master/typings/react-native-keychain.d.ts#L76 getGenericPassword returns false if an error, else an object (credentials). I am not sure this union type can be…
bsr
  • 57,282
  • 86
  • 216
  • 316
5
votes
1 answer

Shebang support in reasonML

I'm trying to write a command line tool in reasonML. So I inserted a shebang(#! /usr/bin/env node) at the first line, but the compiler failed to compile it. How do I add a shebang to the compiled output?
Jian
  • 3,118
  • 2
  • 22
  • 36
5
votes
1 answer

Compiling Reason source files to the same directory as the source files

I'm writing a node application, where I would like to mix Reason and raw JavaScript. This section in the bucklescript documentation describes it When user has an existing JS project, it makes sense to output the JS file in the same directory as…
Pete
  • 12,206
  • 8
  • 54
  • 70
5
votes
1 answer

How can I parse this JSON to a record type?

I have some data I'll be fetching at runtime: /* {id: 1, name: 'brad', age: 27, address: { city: 'city1', state: 'state1' } } */ let data = "{\"id\":1,\"name\":\"brad\",\"age\":27,\"address\":{\"city\":\"city1\",\"state\":\"state1\"}}"; Using…
Bradford
  • 4,143
  • 2
  • 34
  • 44
4
votes
1 answer

ReasonML Type mismatch with same type

I'm receiving a type mismatch even though I'm using the same type in ReasonML. The error is: [1] We've found a bug for you! [1] /Users/gt/work/real-and-open/frontend/src/domain/classroom/views/RosterLayoutHeader.re 42:10-70 [1] [1] 40 ┆…
GTDev
  • 5,488
  • 9
  • 49
  • 84
4
votes
1 answer

Using bs-json to Decode object with dynamic keys in root

I am trying to decode the following JSON object into a Reason object. {"AAPL":{"price":217.36}} The key in the root of the object is dynamic. The following general example works when the key is not in the root. How would I change it so it works for…
Sepehr Sobhani
  • 862
  • 3
  • 12
  • 29
4
votes
1 answer

ReasonML performance against imperative vanilla JavaScript

Disclaimer: I am ReasonML beginner. I have started playing with ReasonML lately and I have noticed a big difference in performance in contrast to vanilla JavaScript. Here's my examples against a simple puzzle solving function (puzzle taken from:…
skay-
  • 1,546
  • 3
  • 16
  • 26
4
votes
2 answers

Deploying a ReasonML function to Google Cloud Functions

I am trying to write a deployment process for taking a ReasonML .bs.js output and deploying it as a Google Cloud function. Here is the ReasonML code: /*! * My first ReasonML Google cloud function. * Hadil G. Sabbagh */ open Express; let…
1
2 3
12 13