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

ReasonML way of returning various types from a single switch statement

I have predefined types that goes, type objA = {name: string} type objB = {age: int} and I want to have a variant type that goes, type test = | Atype(objA) | Btype(objB) and ultimately use pattern-matching to properly return the values of what…
Sanghyun Kim
  • 161
  • 1
  • 12
0
votes
1 answer

Is it possible to use ReasonReact to build a single component?

I'm investigating the possibility to use Reason and React in an old (first commit 2003) legacy project. The approach has to be evolutionary and step-by-step. Does ReasonReact cover this use-case? Or is it mostly used to build apps from scratch? I'm…
Olle Härstedt
  • 3,799
  • 1
  • 24
  • 57
0
votes
1 answer

Proper way of ReasonML record pattern-matching

I have a record type that goes, type person = { name: string, gender: string, age: int } and have lots of records that fit with the type. What I want to do is to extract only [name, age] from the person and make a new record. To do so, I…
Sanghyun Kim
  • 161
  • 1
  • 12
0
votes
1 answer

variable is not an instance variable

I made this factorial solver but all it outputs is: We've found a bug for you! 6| let factorialNumber = 0; 7| Js.log(factorial(factorialNumber)); (error here)8| factorialNumber = factorialNumber + 1; 9|} The value factorialNumber is not an…
JonDoeBeep
  • 41
  • 6
0
votes
1 answer

How to make requests from back-end to another server on user’s localhost

I’ve got a standard client-server set-up with ReScript (ReasonML) on the front-end and a Python server on the back-end. The user is running a separate process on localhost:2000 that I’m connecting to from the browser (UI). I can send requests to…
Peteris
  • 3,548
  • 4
  • 28
  • 44
0
votes
1 answer

How to port following hook to reasonml

I have following custom hook function useConstant(fn) { const ref = React.useRef() if (!ref.current) { ref.current = fn() } return ref.current } and it seems quite hard to port this to reasonml, I have to use type cast twice, what's…
Austaras
  • 901
  • 8
  • 24
0
votes
1 answer

How to send a persistent data structure and its changes over time using GraphQL?

I have a recurring problem that I have to track a data structure over time and pass it via GraphQL, for example, this could be a timeline of a list and its changes: [] [1] [1 2] [-1 1 2] [-1 2] [2] [] I'm looking for a library that allows me to…
Peteris
  • 3,548
  • 4
  • 28
  • 44
0
votes
1 answer

How to declare functional parameters in OCaml/ReasonML?

There are two functions; funA and funB, respectively. a.i, a.o, ah, w, c are arrays in the function funA. The function funA shall be passed as a functional parameter to the function funB and the arrays should be able to be accessed by the function…
madeinQuant
  • 1,721
  • 1
  • 18
  • 29
0
votes
1 answer

How to correctly setup a local ReasonMl / Bucklescript dependencies

New to ReasonML, and I probably don't understand the bucklescript documentation for setting up a module as a dependency. ReasonML project, compiles correctly, with the file MyUtils.re in directory ~/ml/myutils/src. second ReasonML project in…
gash
  • 65
  • 7
0
votes
2 answers

Remove Strings That Appear in one Array from second list if they exist in OCaml/ReasonML

I have to arrays of dates that look like this: let slots = [| "2014-08-11T10:00:00-04:00", "2014-08-11T10:30:00-04:00", "2014-08-11T11:00:00-04:00", "2014-08-11T11:30:00-04:00", "2014-08-11T12:00:00-04:00", "2014-08-11T12:30:00-04:00", …
armand
  • 693
  • 9
  • 29
0
votes
1 answer

String unicode with functions

I am trying to archive that a function is returning a unicode string and I want to log it into the console. But it just either displays the information about the function or just not a unicode string. let test = () =>…
0
votes
1 answer

Can I apply CPS (continuation passing style) in numeric analysis/method?

Using functional continuation in ReasonML, can I apply CPS in numeric analysis/method? e.g. euler method, finite difference method. let factorial3 = n => { let rec cont = (n, func) => if (n <= 1) { func(); } else { cont(n - 1,…
madeinQuant
  • 1,721
  • 1
  • 18
  • 29
0
votes
1 answer

How to use reasonml rtop with src files

How do I allow rtop to discover my src file directory? I found an option -I and hoped that rtop -I src would load my src files in rtop but it still isn't able to find them. eg. src/lib.re: let foo = 1; Run command: rtop -I src Reason # open…
aqui8
  • 511
  • 3
  • 11
0
votes
1 answer

JavaScript constructor behaviour in ReasonML using BuckleScript

I want to generate javascript function called Publisher from ReasonML so that i can use it in other files as for example: const publisher = new Publisher("Prasad", "email@email.com", "team@email.com", "rill") const req = Publisher.toAPI(publisher)…
REDDY PRASAD
  • 1,309
  • 2
  • 14
  • 29
0
votes
0 answers

Whats the difference between `type a = { someType:someType }` and `type a = A(someType)`

Like for simple team and game types type team = | Team(string); type game1 = | Game(team, team); type game2 = { team1: team, team2: team, }; What is the difference between game1 and game2? In real world when to declare type game like…
amitdigga
  • 6,550
  • 4
  • 26
  • 31