官术网_书友最值得收藏!

Using Try Reason

Reason provides a fantastic resource for learners: an online Reason-to-JavaScript compiler and evaluator. To access it, go to the Reason website and click Try in the navigation bar at the top. You can use it to quickly try out different ideas.

Let's run through a quick example using Try Reason to get our bearings. Type in the example code from src/Ch01/Ch01_Demo.re into the Reason section of the Try Reason web app. Now add the following line after that:

let bob = makePerson(1, "Bob");

Now if you examine the output JS, you should see that the following changes have been made:

  • Types have been stripped away
  • Records have been transformed into arrays without field names (records are roughly like C structs or JavaScript objects)
  • Every declared value is explicitly exported (made public)

Note that we have purposely introduced very little actual Reason syntax in this chapter. If you are curious to explore the syntax (which is very similar to JavaScript at its core), it's best if you explore the excellent Reason website documentation. Since the focus of this book is type-driven development, in the upcoming chapters we will introduce all the syntax we will need and discuss its impact on our understanding of the code.

主站蜘蛛池模板: 丰宁| 体育| 米脂县| 静海县| 棋牌| 扎囊县| 驻马店市| 汉源县| 阜新| 静海县| 乐山市| 托克逊县| 车致| 乐山市| 柘荣县| 闽清县| 济阳县| 太仓市| 托里县| 和田县| 澄江县| 兴文县| 繁昌县| 溧阳市| 岚皋县| 吉首市| 遂川县| 乌拉特前旗| 东源县| 奉化市| 八宿县| 股票| 西安市| 丘北县| 驻马店市| 全椒县| 黑龙江省| 徐水县| 保靖县| 黔西县| 马山县|