GithubHelp home page GithubHelp logo

leostera / reason-workshop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ryyppy/reason-workshop

0.0 2.0 0.0 38 KB

Workshop materials and exercise

License: GNU General Public License v3.0

OCaml 100.00%

reason-workshop's Introduction

reason-workshop

This repository contains all the code snippets & examples used in the presentation slides.

For the accompanied exercise repository for ReasonReact, clone and npm install reason-workshop-exercise.

Important Links:

Setup

This section explains how to set up your editor and how to build / compile the examples. After completing all steps, you should be able to see type-errors / autocompletion in your editor. If there are any troubles, please ask your workshop instructor for support.

Cleanup for older Reason installations

If you have been using Reason a while ago, especially with VSCode, please uninstall any Reason / OCaml related plugins from your VSCode installation first.

Please make sure to uninstall any existing reason-cli installations via npm:

  • npm -g ls reason-cli
  • If the command above delivered results, please run: npm -g remove reason-cli

Editor

You can find a more descriptive article on my development workflow with VSCode right here.

Building the project

Make sure to run npm install before trying to build the source.

# For a single build run
npm run bs:build

# For watch mode building (recommended to run in your VSCode terminal so
# it's easier to see the compiler output next to the code)
npm run bs:watch

Note: If you don't do an initial build before using your editor, you will see a lot of error messages. This is because there aren't any build artifacts to inspect for the plugin. So make sure to run the watch mode before coding.

Extra: Install BuckleScript CLI

BuckleScript also offers a CLI, called bsb. You can install it via npm:

npm install -g bs-platform

Later on for this workshop we need this tool to add BS to an existing JS project... in every project you are required to add bs-platform as a devDependency, so usually it's not really necessary to actually have it installed globally.

Overview

  • The examples used in the slides can be found in src/examples
  • Exercise files should be put in src directly

Glossar

  • BuckleScript - The Reason-to-JS compiler platform used in this workshop
  • refmt - The Reason pretty-printer used for reformatting code in your editor ("Prettier for reason")
  • Interop - This refers to the interoperability layer in BuckleScript

Tips & Tricks

Bucklescript builds the code without any warnings, but my editor still complains about type errors

Sometimes it happens that VSCode gets out of sync with the backing Language Server process and it reports type errors which are actually not there (e.g. caused by moving files around etc).

Always check the output of your BuckleScript process first. If BuckleScript doesn't yield any errors, then try closing tabs / saving all relevant files and reopen them to sync up the error reporting.

I get really confusing type errors and I don't know what to do

Having a type-system with strong type inference is usually very confusing in the beginning. Always check out the output of your BuckleScript process in your terminal, since it uses a plugin which shows you more human-friendly errors and offers ways to fix them (especially for common ReasonReact related errors).

reason-workshop's People

Contributors

ryyppy avatar nikgraf avatar

Watchers

Leandro Ostera avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.