Study procedures that people who want to study elm really need

I heard that the SPA on the front is safe for the elm type, but I don't know where to start.

Let's display what was hello world with elm from a clean state in the browser.

install

First is install. The people who wrote the articles described later probably thought that the basics such as install were "no need to write it." Certainly officially. However, there is a decent amount of documentation, and when it comes to "reading all this before starting", I can't feel free to touch it. Look around here to find what you need.

elm install

https://guide.elm-lang.org/install/elm.html Ignore the fact that sublime text is written in the editor (does anyone still use it?) And insert the elm binary. Follow the instructions according to your OS. Since I am linux, I decompressed it after getting it with the curl command, ignored the README, placed it in ~ / bin, and put it in the PATH. It seems that pkg for mac and exe for win are crashing.

Now you can use the elm command.

$ elm
Hi, thank you for trying out Elm 0.19.1. I hope you like it!

-------------------------------------------------------------------------------
I highly recommend working through <https://guide.elm-lang.org> to get started.
It teaches many important concepts, including how to use `elm` in the terminal.
-------------------------------------------------------------------------------

The most common commands are:

    elm repl
        Open up an interactive programming session. Type in Elm expressions like
        (2 + 2) or (String.length "test") and see if they equal four!
    
    elm init
        Start an Elm project. It creates a starter elm.json file and provides a
        link explaining what to do from there.
    
    elm reactor
        Compile code with a click. It opens a file viewer in your browser, and
        when you click on an Elm file, it compiles and you see the result.

There are a bunch of other commands as well though. Here is a full list:

    elm repl    --help
    elm init    --help
    elm reactor --help
    elm make    --help
    elm install --help
    elm bump    --help
    elm diff    --help
    elm publish --help

Adding the --help flag gives a bunch of additional details about each one.

Be sure to ask on the Elm slack if you run into trouble! Folks are friendly and
happy to help out. They hang out there because it is fun, so be kind to get the
best results!

first step to run elm

For the time being, find a sample of hello world and type it in

$ elm 01hello.elm 
There is no 01hello.elm command.

Run `elm` with no arguments to get more hints.

I tried as such, but I get angry if there is no such command. When I stared at help, it would be ʻelm init`. That's why I'll try it.

$ elm init

The elm.json and src directories have been created. It seems that index.html is created by putting Main.elm in src and elm build.

$ tree

├── elm.json
├── elm-stuff
│   └── 0.19.1
│       ├── d.dat
│       ├── i.dat
│       ├── lock
│       ├── Main.elmi
│       ├── Main.elmo
│       └── o.dat
├── index.html
└── src
    └── Main.elm

Ignore elm-stuff for the time being. Write the following in src / Main.elm.

https://github.com/bryanjenningz/25-elm-examples/blob/master/01-hello-world.elm More excerpt

module Main exposing (main) 
import Html exposing (text) 

 main = 
     text "Hello, World!" 

here

$ elm src/Main.elm

Then, ʻindex.html` is created. You can go with this. exaple02 just seems to declare a type for this. At 03,04, you can add a class attribute to div Doug.

Ah, I feel like I can go through here in order. I'm tired of reading English, so I'm reading it as needed. Please point out any omissions.

02 Access counter implementation

I feel that the difficulty level suddenly increased from 05 counter. Is sandbox like a ReAct State? Icrement is just an identifier of msg, and the update msg model determines whether the received msg is Increment and increments the model. The child whose screen display is updated with this is a Reactive View template. Convenient.

I'd like to add a little more, but that's all for today. I will consider whether to add it to this article or make it a separate article.

I hope this frees you from the front-end package manager hell hell and the AltJS language all-type information. (Since it is updated irregularly, there is no idea when and how much it will be made.)

Motivation for writing this article

I read the following article to get started with elm, but I didn't know how to get started.

Qiita article

-Who can't recommend Elm in 2020? -First page read by Elm beginners --Only goats come in ――No technical information, just an emo story

--Wai's Elm debut [Part 1] [Part 1] ――The text is interesting and there is an implementation, but suddenly I am writing the elm code ――I don't know how to convert it to html and display it in the browser.

-Fun experience of functional languages with Elm ――The content of the article seems to be the most serious, but after all I suddenly wrote the Elm code and the preparation is not written. How can I execute the code written here?

bonus

The size of the elm command is close to 30MB. Linux Elm 0.19.1. Even if you look at ldd, there is no ld link, and I wonder if I do everything by myself without relying on libstd, I see ...

References

Recommended Posts

Study procedures that people who want to study elm really need
I want to analyze the emotions of people who want to meet and tremble
To people who are "recruiting but not recruiting"