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

webpack css loader with reason-react

I am struggling to get webpack working with my reason app. I have installed webpack using the following command : npm install --save-dev webpack I have installed style-loader and css-loader using the following command : npm install --save-dev…
espern
  • 659
  • 6
  • 14
0
votes
1 answer

Bs.deriving Abstract getter function returns undefined when using capital names

In the bucklescript doc example for bs.deriving abstract, you can get the property on you created object with nameGet() This works: @bs.deriving abstract] type person = { name: string, age: int, job: string, }; let joe = person(~name="Joe",…
armand
  • 693
  • 9
  • 29
0
votes
0 answers

Reasonml map not pure?

I have a string map like this: let table = Belt.Map.String.fromArray([|("A", 1), ("B", 1), ("C", 3)|]); When I compile this single line, BuckleScript JS output says that table is not a pure module. From my understanding of the Map, when you do a…
PKK
  • 753
  • 2
  • 7
  • 18
0
votes
1 answer

How do I include untyped-JavaScript, from an adjacent file, in ReasonML bindings?

While trying to get started with Reason, in one JavaScript project, I've got an extremely light file that tries to be a Reason-typed interface to the existing, heavy, library: /* TheLibrary.re */ type engine external addEngine : string -> engine ->…
ELLIOTTCABLE
  • 17,185
  • 12
  • 62
  • 78
0
votes
2 answers

OCaml Non-Literals in Match

Match against non-literal values I in Ocaml (reasonml), I'm able to to match against integer values like, switch (x) { | 0 | 1 => "small" | _ => "large" } However, say I now switch my number type to something like Zarith. How do I match against…
0
votes
1 answer

How to use process.env variables in reason with webpack

Here's the deal: with webpack you can provide environment variables (via DefinePlugin or EnvironmentPlugin) so they can be consumed by the code like process.env.MY_VAR. It works that they'll be inlined with real values at the build time. But I'm…
Saito
  • 694
  • 7
  • 25
0
votes
0 answers

Transitioning between three states with a mix react life cycle events

I have an ReasonReact overlay component with three states of fade. The first is visible at full opacity, the second is visible at almost entirely transparent, and the third is display none. Is there a way to use lifecycle events to avoid polling to…
wegry
  • 7,046
  • 6
  • 39
  • 59
0
votes
0 answers

bs.as and unicode strings

Does bs.as work with unicode strings? [@bs.deriving jsConverter] type filterable = [ | `Material | [@bs.as {js|üüüüü|js}] `Umlaut ]; is giving me Unused BuckleScript attribute: bs.as Some fatal warnings were triggered (1 occurrences)
wegry
  • 7,046
  • 6
  • 39
  • 59
0
votes
0 answers

Is there a way to represent JS template literals in Bucklescript type annotations?

I’m using an internationalization library in JS (https://github.com/format-message/format-message) which contains a function that takes a template literal and an object. The template literals don’t have any interpolated JS variables, but the text…
Ashok Bhaskar
  • 361
  • 2
  • 16
0
votes
1 answer

Binding to window.navigator.getUserMedia

[@bs.module] external navigator: unit = "window.navigator"; giving following error Module not found: Can't resolve 'window.navigator' How to access the windows.navigator in ReasonML?
Nimish Gupta
  • 971
  • 7
  • 17
0
votes
1 answer

Handling children in ReasonReact

I am trying to build my own component where the user passes in their own
0
votes
1 answer

Full namespacing requires recompilation

Say I have two files: foo.re bar.re Say I now have, at the top of bar.re open MyProject.Foo; This fails to compile with: This module is not a structure; it has type (module MyProject.Foo) If I rerun compilation, everything works fine If I…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
0
votes
1 answer

Unable to Type in

Given: LoginUsername.re let component = ReasonReact.statelessComponent("LoginUsername"); let make = (~value: string, _children) => { ...component, render: (_) =>
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
1 answer

ReasonML javascript record field

Say I have the following Bucklescript types: type amqp; [@bs.val] external amqpLib: amqp = "Amqp"; [@bs.module] external amqplib : amqp = ""; class type amqpConnectionT = [@bs] { pub createChannel: unit => unit; pub close: unit =>…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
0
votes
1 answer

reason react how to handle event better?

I managed to get the event to update, using snippet of the web, I am having a really hard time to understand. Here is the entire snippet: type state = { login: string, password: string }; type action = | SetLogin(string) |…
Adam
  • 3,415
  • 4
  • 30
  • 49