mutable y: int} {x: 30, y: 20} Same point.x Same point.y = 30; Same {...point, x: 30} Same Object/Record JavaScript ReScript [1, 2, 3] Same myArray[1] = 10 Same [1, "Bob", true] (1, "Bob", true) Array 型があるのでタプル JavaScript ReScript for (let i = 0; i <= 10; i++) {...} for i in 0 to 10 {...} for (let i = 10; i >= 0; i--) {...} for i in 10 downto 0 {...} while (true) {...} while true {...} Loop JavaScript ReScript if (a) {b} else {c} if a {b} else {c} * a ? b : c Same switch pattern matching! If-else 式なので返される型は 同じでないといけない 基本的な構文はJSとほぼ同じ
@send external cyEdgeField : (cyEdgesT,string) => string = "data" ele.data( name ) Get a particular data field for the element. name The name of the field to get. let msg1 = %raw(" (a) => a.content ") let msg2:string => string = %raw(“ (a) => a ++ “AA” ") ReScript Cytoscape Node(アイコン)とEdge(線)で タイプが異なるので2つ定義 CytoscapeのAPI JSの関数をそのまま記述 引数の型も帰り値の型も不定 型を記述 JSの処理を生で記述