New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter: A first look at ReasonML’s syntax #5

Open
rauschma opened this Issue Feb 7, 2018 · 15 comments

Comments

Projects
None yet
9 participants
@nhducit

This comment has been minimized.

nhducit commented Feb 8, 2018

type tree('a) =
  | Empty
  | Node('a, tree('a), tree('a));

I come from JS. what is 'a mean? Can you explain it?

@rauschma

This comment has been minimized.

Owner

rauschma commented Feb 8, 2018

tree is a variant, 'a is a type variable (similar to a generic class Tree<A> in Java). Explained here: http://reasonmlhub.com/exploring-reasonml/ch_variants.html

The point of the example was to give a first taste of the syntax. No worries if you don’t understand it (yet)! I’ll clarify that in the text.

@approots

This comment has been minimized.

approots commented Feb 8, 2018

For me, it's too early in the book to introduce that concept. I'm likely to write-off Reason as too complex for now.

@nhducit

This comment has been minimized.

nhducit commented Feb 9, 2018

I mean at least we should mention it, and point to the explanation in further chapter

@dp-1a

This comment has been minimized.

dp-1a commented Feb 9, 2018

Probably a typo in the code example in the chapter "Most things are expressions"?

let myBool = true; /* should be myBook? */
let print(if (myBook) "yes" else "no");
@rauschma

This comment has been minimized.

Owner

rauschma commented Feb 9, 2018

@dp-1a “myBook” is the typo. It’ll be fixed in the next release. Thanks!

@craigglennie

This comment has been minimized.

craigglennie commented Feb 9, 2018

ReasonML is based on OCaml, which uses snake-casing for lowercase names (create_resource) and camel-casing for uppercase names (StringUtilities).

That’s why you’ll occasionally see camel-cased names. But all new ReasonML code is camel-cased (StringUtilities, createResource).

I think "That’s why you’ll occasionally see camel-cased names" should be "That’s why you’ll occasionally see snake-cased names"?

@rauschma

This comment has been minimized.

Owner

rauschma commented Feb 11, 2018

@approots @nhducit Thanks for your feedback! I’ve updated the chapter: http://reasonmlhub.com/exploring-reasonml/ch_syntax-overview.html

@rauschma

This comment has been minimized.

Owner

rauschma commented Feb 11, 2018

@craigglennie True! It’ll be fixed in the next release. Thanks!

@bhongy

This comment has been minimized.

bhongy commented Feb 12, 2018

I'm going through the book and found it's very easy to digest and concise. Thank you for writing it!

Possibly typo in one of the examples on this page (won't compile):

/* A function that switches over a variant type */
let stringOfColor(c: color) =>
  switch (c) {
  | Red => "Red"
  | Green => "Green"
  | Blue => "Blue"
  };

Should the line with let binding be?:

let stringOfColor = (c: color) =>
@idkjs

This comment has been minimized.

idkjs commented Mar 21, 2018

Probably a typo in the code example in the chapter "Most things are expressions"?

let myBool = true;
let print = if (myBool) {"yes"} else {"no"}; /* print = /*

@rauschma

This comment has been minimized.

Owner

rauschma commented Apr 8, 2018

@bhongy & @idkjs: Those were typos and are fixed now. Thanks for the feedback!

@mars0i

This comment has been minimized.

mars0i commented May 18, 2018

There are many Initial_uppercase_and_then_snake module names in OCaml.

I don't think of x' in math or OCaml as meaning "changed x". I think of it as nothing more than "another x".

Thanks for making the book available online!

@osenvosem

This comment has been minimized.

osenvosem commented Jun 5, 2018

This syntax at the end of the chapter seems to be deprecated:

let len(arr: array('a)) = Array.length(arr);

refmt changes it to:

let len = (arr: array('a)) => Array.length(arr);

rtop accepts and executes it, though.

@rauschma

This comment has been minimized.

Owner

rauschma commented Jun 10, 2018

@osenvosem Good catch! Fixed now, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment