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

ReasonML vs Elm

I saw this ReasonML vs TypeScript question here at StackOverflow, now I'm wondering how ReasonML and Elm compare to each other. What are their similarities and differences? Which one should I use when? What's the advantage of one over the other?
John Paul Ada
  • 537
  • 5
  • 9
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
14
votes
2 answers

How do I declare a map type in Reason ML?

One advantage of Reason ML over JavaScript is that it provides a Map type that uses structural equality rather than reference equality. However, I cannot find usage examples of this. For example, how would I declare a type scores that is a map of…
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
12
votes
1 answer

What's the difference between Jane Street's ‘Base’, ‘Core’ and 'Core_kernel'?

I'm new to OCaml, and I it's often suggested that I use Jane Street's standard-library instead of the one that ships with the compiler. However, there seem to even be several of those, and I don't know which I should be using: Base, Core, and…
ELLIOTTCABLE
  • 17,185
  • 12
  • 62
  • 78
9
votes
1 answer

OOP - How does one create a class in ReasonML

I know that in OCaml, one can create a class doing the following: class stack_of_ints = object (self) val mutable the_list = ( [] : int list ) (* instance variable *) method push x = (* push method *) the_list…
Charlie-Greenman
  • 1,469
  • 1
  • 16
  • 36
8
votes
1 answer

Does ReasonML have an equivalent of F#'s Computation Expressions?

In F# we have Computation Expressions, which can reduce boiler-plate and nesting when working in various computational contexts (async, optionals and so on). Does ReasonML have an equivalent of this? If so, what is the syntax?
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
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
2 answers

how to represent a non-empty list type

I'm a big fan of creating data structures that make representing invalid states impossible, so I wanted to ask how I could represent a non empty list in reasonml? Since it's possible to pattern match on lists like [] and [head, ...rest] I thought it…
hesxenon
  • 501
  • 3
  • 12
7
votes
3 answers

Join array of strings?

In JavaScript you can join an array of strings, e.g.: fruits = ["orange", "apple", "banana"]; joined = fruits.join(", "); console.log(joined) // "orange, apple, banana" How do you do this in ReasonML?
Rotareti
  • 49,483
  • 23
  • 112
  • 108
7
votes
1 answer

ReasonML vs Scala.js

So by reading the reasons why facebook choose OCaml to create Reason, I couldn't stop noting that Scala met all the requirements too. I'm not biased whatsoever, I know Scala, but I'm not a die hard scala advocate. I just like a nice type system, so…
caeus
  • 3,084
  • 1
  • 22
  • 36
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
7
votes
3 answers

How to use Jane Street's Core with Reason?

I'm new to OCaml and I'm trying to try (:P) Facebook Reason syntax. I cannot find a way to make this compile because if cannot find the Core module (already installed with opam). I'm trying to compile a sample program from Real World OCaml open…
David Pelaez
  • 1,374
  • 1
  • 13
  • 16
1
2 3
23 24