Giter Club home page Giter Club logo

elm-for-js's Introduction

elm-for-js

Community driven Elm guide for JS people

This guide will augment the official Elm docs as needed, for a smooth transitions for people coming from JavaScript.

Getting started

  1. Try the Hello World online
  2. Install Elm via npm or the installer.
  3. Get Hello World running locally
  4. Work through the architecture examples. Type manually, look in examples/ for help.

Getting Hello World running locally

  1. Install Elm
  2. Create a new file Main.elm in a new folder.
  3. $ elm package install to set up elm-package.json and elm-stuff/ for deps (similar to node).
  4. Paste the source from the Hello World example to your local Main.elm file.
  5. $ elm package install evancz/elm-html to install the missing package dependency.
  6. $ elm-reactor to get the dev server running at http://0.0.0.0:8000/.
  7. Success!
  8. For a standalone file you can run $ elm make Main.elm --output=main.html (default is a JS file).

Type Annotations

Writing them is optional, but highly encouraged. Type annotations improve code by helping you think about what the function should be doing, and serve as compiler-verified documentation. In addition, if you ever want to publish a third-party library, you need type annotations.

-- A variable of type Int.
answer : Int
answer = 42

-- An update function that takes 2 params (Action, Model) and returns a Model (last).
update : Action -> Model -> Model
-- could also be written as
update : (Action, Model) -> Model

In JavaScript, params are handled at the same time. In Elm, they are curried. For example:

-- Update is a function that will take an Action param, and return a function that will take a Model param. THAT fn will return a Model.
update : Action -> Model -> Model

Great elm articles

If you see mistakes, or something you want covered, open an issue or a PR.

TODO:

Add sections for

  • Package management (compare to node_modules, npm)
  • Type Annotations
  • Data types (try not to duplicate official docs)
  • Basic Syntax
  • Program structure and flow
  • How to read the API docs
  • Package catalog link.

elm-for-js's People

Contributors

davidsiefert avatar franklinchen avatar jamischarles avatar jimt avatar mgold avatar robinpokorny avatar xjamundx avatar

Watchers

 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.