LoginSignup
7
6

More than 5 years have passed since last update.

ELMはじめの一歩

Posted at

ELMでHello Worldを出すまで。

環境:よせみて 10.10.5
ELMのバージョン:0.15.1

Elm Platformのインストール

公式からインストーラーをダウンロードして、インストールしましょう。
クリックを連打しておけばとりあえず大丈夫です。たぶん

スクリーンショット 2015-11-10 16.38.01.png

elmとターミナルで叩いて以下で出ればインストールできています。

Elm Platform 0.15.1 - a way to run all Elm tools

Usage: elm <command> [<args>]

Available commands include:

  make      Compile an Elm file or project into JS or HTML
  package   Manage packages from <http://package.elm-lang.org>
  reactor   Develop with compile-on-refresh and time-travel debugging
  repl      A REPL for running individual expressions

You can learn more about a specific command by running things like:

  elm make --help
  elm package --help
  elm <command> --help

In all these cases we are simply running 'elm-<command>' so if you create an
executable named 'elm-foobar' you will be able to run it as 'elm foobar' as
long as it appears on your PATH.

ファイルの作成

ELMはelmファイルをコンパイルするとhtml(またはJS)を吐きます。
なのでhello.elmを作成します。
中身はExampleのhello world!を貼っつけます。

hello.elm
import Html exposing (text)

main =
  text "Hello, World!"

ビルド

elm-make hello.elm --output=hello.html

でhello.htmlが作成されます。

 QiitaHelloWorld.png

こんな感じです。これでスタートラインに立てました。

エラー

Error when searching for modules imported by module 'Main':
    Could not find module 'Html'

Potential problems could be:
  * Misspelled the module name
  * Need to add a source directory or new dependency to elm-package.json

と怒られれたら、パッケージが足りていないので公式から持ってきましょう。
elm-package install evancz/elm-html

参考

  1. http://codezine.jp/article/detail/8986
  2. http://doloopwhile.hatenablog.com/entry/2014/12/02/200000
7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6