Created
May 27, 2018 20:27
-
-
Save mareksuscak/1d67ff4fa0813db0eb4b1fc261ebe128 to your computer and use it in GitHub Desktop.
ReasonDojo issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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>, | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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