Skip to content

Instantly share code, notes, and snippets.

@mareksuscak
Created May 27, 2018 20:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mareksuscak/1d67ff4fa0813db0eb4b1fc261ebe128 to your computer and use it in GitHub Desktop.
ReasonDojo issues
let a = 1;
/**
* Results in "Error. The value a is not an instance variable"
* But what if the person is just learning about Reason and has no idea what an instance variable is?
* Perhaps saying it's immutable would be a better idea? IDK
*/
a = 2;
/* The following two notations were confusing to people. "Why do we suddenly need to wrap it twice?" */
/* I assume that the first one was more puzzling than the other, although it took some time to grasp the implicit return concept */
let make = (~name, _children) => {
...component,
render: _self => <button></button>,
};
let make = (~name, _children) => {
let data = 10;
{
...component,
render: _self => <button></button>,
};
};
/* Reason implicitly infers the type based on the structure but doesn't treat two types having same structure as equal. */
type person = {
age: int,
name: string
};
type person1 = {
age: int,
name: string
};
let fn = (p: person) => {}
/* This line creates an instance of person1 */
{age: 10, name: "marek"}
/* This surprisingly works fine, it creates an instance of the correct type person */
fn({age: 10, name: "marek"})
let p: person1 = {age: 10, name: "marek"};
/* This line throws an error due to the type mismatch even though, structurally they're the same */
fn(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment