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

Write type constraint for polymorphic variants with generic type parameters

Background: I was trying to create something as described in the paper, Data Type à la Carte - but trying to see if OCaml's polymorphic variants could lead to a clean ReasonML implementation. My code here is in ReasonML syntax, but the question is…
Pete
  • 12,206
  • 8
  • 54
  • 70
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

Can ReasonML be used to make native iOS apps?

By this I mean truly native, and only iOS threads, not one that has native and JavaScript threads.
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

action has wrong type in ReasonReact reducer

I'm trying to create a simple todo app, this is an input component and I need a reducer to update the state of the input. This code is throwing the error - This pattern matches values of type action but a pattern was expected which matches values of…
coops22
  • 401
  • 7
  • 15
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
2 answers

Is it possible to create a polymorphic variant type dynamically using modules?

I'm trying to organzine and reuse my reasonML code. I have model module types that look like the following: module Diet = { type schemaType = [`DietSchema]; type idType = [`DietId(UUID.t)]; let schema = `DietSchema; type idAsType('a) = [>…
GTDev
  • 5,488
  • 9
  • 49
  • 84
3
votes
1 answer

How to conditionally set HTML attributes in JSX using reason-react?

I want to render an HTML checkbox whose checked state is controlled by data. Give a stateless component that receives an item type { label: string, checked: bool}, Like so: let component = ReasonReact.statelessComponent("TodoItem"); let make =…
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
3
votes
1 answer

ReasonML sample web server with a db

I've been taking a look at ReasonML (https://reasonml.github.io/) and in general, as a 'loyal' ;) functional programmer, I like the idea. However, I believe there's a missing part in my reasoning about the project. In particular I'm a bit confused…
LA.27
  • 1,888
  • 19
  • 35