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

What are the Implications of Different ReasonML External Declarations?

In the examples below, both external declarations achieve the same functionality with slightly different ReasonML function structures. Does external declaration style impact anything (e.g. performance) beyond ReasonML function structure? Also, does…
Ari
  • 4,121
  • 8
  • 40
  • 56
0
votes
1 answer

Using ReasonML FFI

I'm trying to understand ReasonML's FFI (i.e. external) usage. To that end, I put together the following code (see Try ReasonML and Sketch.sh) type dom; type element; [@bs.val] external dom: dom = "document"; [@bs.send.pipe : dom] external…
Ari
  • 4,121
  • 8
  • 40
  • 56
0
votes
1 answer

How does fillStyle work in bs-webapi Canvas2d

I'm wondering how to create a and set a fill style using bs-webapi and Canvas2d interface in ReasonML. I think the definition I might need is this: let fillStyle = (ctx: t) => ctx |> fillStyle |> reifyStyle; But I'm having trouble understanding…
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
0
votes
1 answer

How to ignore sources in bsconfig.json file (reasonml)?

I want to use the "subdirs": true option in sources of my bsconfig.json file, but ignore a specific folder. (rather than doing the opposite and adding each subfolder to sources besides the one I want to ignore) Extra info (if you wondering why I am…
JasoonS
  • 1,432
  • 3
  • 13
  • 26
0
votes
1 answer

reasonml type higher order function

given the following module the compiler raises an error 41 │ }; 42 │ 43 │ module TestB = { 44 │ let minFn = (a, b) => a < b ? a : b; . │ ... 54 │ let max = reduceList(maxFn); 55 │ }; 56 │ 57 │ // module Number = { The…
hesxenon
  • 501
  • 3
  • 12
0
votes
1 answer

How to read the value of a ReactNative.Style.t property with reason-react-native?

I would like to do the following: let marginTop = if (itemInfo##index == 0) { Style.viewStyle(~marginTop=style##paddingTop, ()); } else { Style.viewStyle(); } But I get the following error: This has type: ReactNative.Style.t…
Natim
  • 17,274
  • 23
  • 92
  • 150
0
votes
1 answer

How I can get the current year with the Js module of bucklescript?

I'm working on a ReasonReact project and I need to get the current year with the Js.Date module I created a function to get a range between two years, so I need to pass the current year as the second parameter let rangeYears = (startedYear,…
0
votes
1 answer

How to handle the result of a list of future with ReasonML?

I am trying to go over a list of items, cache the URL and then update the URL in the list before drawing it. However I don't seems to be able to do so. Any idea? external cache: option(string) => Js.Promise.t({. "uri": string, "filePath": string })…
Natim
  • 17,274
  • 23
  • 92
  • 150
0
votes
0 answers

Can't create reasonML project on Windows

I just started learning reasonML and I want to create my first project. I installed bs-platform globally with npm install -g bs-platform. I want to create the first project with the command bsb -init my-new-project -theme basic-reason but…
bonheury
  • 362
  • 1
  • 5
  • 14
0
votes
1 answer

How do you generically convert values of variant types to strings?

Say I have a sum type consisting of the following data constructors... type Entity = | Student | Staff | Classes Is there a way of polymorphically converting values from a given sum type into values of type string which does not resort to the…
therewillbecode
  • 7,090
  • 4
  • 35
  • 42
0
votes
1 answer

This expression has type ... but an expression was expected of type

I am using bs-material-ui-icon binding, but I am given type error when try to use it component. module Cell = { type status = | Empty | Tick | Cross; /* let icon = React.createElement(MaterialUIIcons.AccessAlarm); */ …
Jack Ng
  • 473
  • 7
  • 14
0
votes
2 answers

ReasonML, side effecting call on x if option is Some(x)

I have let intervalId = option(Js.Global.intervalId) I would like a succinct way to do the side effecting call to Js.Global.clearInterval if the option has a value (ie. is Some(id) and not None) Maybe the Belt.Option.map function is the answer, but…
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
0
votes
1 answer

Not able to understand complex type and destructure it - reasonml

I use reason-apollo to fetch data from server. It returns me data of type (vscode shows me this type): option( Js.t( < count : int; rows : [ `User of < firstName : string; id : string; lastName : string; userName…
0
votes
1 answer

How are BuckleScript library names generated?

Where do libraries get the name we use in for example open BsReactNavigation? For example, there is no module in bs-react-navigation named BsReactNavigation? So how does reason know what we are referring to when we say open BsReactNavigation in a…
armand
  • 693
  • 9
  • 29
0
votes
1 answer

Implementation of construction + view pattern example

Was working through an example of a design pattern called Constructor + View by the author that was explained through types but was having trouble figuring out the implementation. This is the module signature: module User : { type t; type view =…
franky
  • 1,323
  • 1
  • 12
  • 13