glennsl / reason-syntax-guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reason-syntax-guide

This guide aims to quickly answer two questions you might get when you encounter unfamiliar syntax in Reason: What is this And where can I learn more? If it doesn't, please make an issue or a PR.

The guide is divided into these sections

Keywords

Keyword Usage What is this? Where can I learn more?
as { foo, bar } as record Binds the item being destructured to a name RWO - OCaml Manual
as array 'a as 'this A type alias OCaml Manual
fun
let
mutable
type
switch
rec
in
to
downto
module
module type
ref
true
false
if
else
for
while
open
exception

Operators and symbols

Operator/Symbol Usage What is this? Where can I learn more?
+., *., etc. 3.1 +. 2.3 Floating point operators
^ "Hello " ^ "world" String concatenation
## obj##property Object (not record) property access
` >` `"hello" > print_string`
@@
=>
` `
'
`
::
{..}
...
;
==
===
!=
!==
_
land
lor
lxor
lnot
lsl
lsr
not
&&
` `
:=

Common user-defined operators

>>= !?

Constructs

Syntax Usage What is this? Where can I learn more?
[a, b, ...c] let a = [1, 2, ...nums] Immutable list append
[_, _, ..._] let [b, c, rest] = a List destructuring
`type _ = _ _`
fun ⁔ => ...
`switch { => ...`
{..}
{. ⁔ }
{ "<x>": <y> }
`[ , ]`
[@@...]
[%...]
/* ...*/
<x> ? <y> : <z>
(<x>, <y>)
module <X> (<Y>: <Z>) => ...
<..>

About