# First 24 hours with Elm

**URL:** <https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663>\
**Category:** Learn\
**Created:** [April 28, 2020, 2:28am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663 "2020-04-28T02:28:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotnetCarpenter](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dotnetcarpenter/32/3216_2.png) [@dotnetCarpenter](https://discourse.elm-lang.org/u/dotnetCarpenter)\
**Post date:** [April 28, 2020, 2:28am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/1 "2020-04-28T02:28:38Z")

</div>

Late last night (or very early morning), I began learning Elm. A few days ago I read [The Syntax Cliff](https://elm-lang.org/news/the-syntax-cliff) and got persuaded to learn Elm. After a few hours I began to document questions I had while learning.

My main motivation, for learning Elm, is to learn how to structure Functional JS in larger projects. My attempts so far has quickly turned into an organized mess.

While I have only written down _“pain points”_ and confusion, I want to assure you all, that I’m thrilled to be here and that, overall, learning Elm is a very pleasant experience. I hit a bump the last few hours. The issue, I found out, was a simple Bool value that I got wrong. But without being able to use `Debug.log` for Bool value and added my confusion with learning a new language, it took me 4 hours to solve!

My notes are in [the README](https://github.com/dotnetcarpenter/elmtut#day-1) in my [dotnetcarpenter/elmtut](https://github.com/dotnetcarpenter/elmtut) repository, along with all the code I wrote and copied from [guide.elm-lang.org](http://guide.elm-lang.org). So far (Day 1) I have read until the [Forms](https://guide.elm-lang.org/architecture/forms.html) chapter.

If anyone, who are working on making Elm more accessible, has any questions, I am happy to answer them here or in the [repository issue list](https://github.com/dotnetcarpenter/elmtut/issues). I will keep a close eye on the list and here, the next few days.

I hope this can shed some light on how Elm is for a completely new comer to the language.

---

<div class="post-metadata">

**Author:** ![Lucas\_Payr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/lucas_payr/32/4993_2.png) [@Lucas\_Payr](https://discourse.elm-lang.org/u/Lucas_Payr)\
**Post date:** [April 28, 2020, 4:51am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/2 "2020-04-28T04:51:11Z")

</div>

Your Questions are very interesting.

Here are some answers:

- `True |> Debug.log "My Bool Value"`

- when using lambda expressions, you need to wrap them in brackets:  
`list |> List.map (\x -> 2 * x)`.  
Else the parser reads the line like this:  
`list |> (List.map) (\x) (->) (2 * x)` and gets confused.  
This does not only happen for lambda expressions but for `let in`, `case of` and `if then else`. ( I hope I haven’t forgotten something)

If you have some questions, please feel free to ask them here on discourse. We love to help.

---

<div class="post-metadata">

**Author:** ![malaire](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@malaire](https://discourse.elm-lang.org/u/malaire)\
**Post date:** [April 28, 2020, 9:18am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/3 "2020-04-28T09:18:15Z")

</div>

The bootstrap code `var app = Elm.Main.init({ node: document.getElementById("elm") })` is mentioned in guide at [JavaScript Interop](https://guide.elm-lang.org/interop/) chapter, which is quite late.

---

<div class="post-metadata">

**Author:** ![dotnetCarpenter](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dotnetcarpenter/32/3216_2.png) [@dotnetCarpenter](https://discourse.elm-lang.org/u/dotnetCarpenter)\
**Post date:** [April 28, 2020, 2:20pm UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/4 "2020-04-28T14:20:12Z")

</div>

Thank you.

Just so I understand you `Debug.log` answer. If I want to log the result of a function called `no` with 2 arguments, I can insert `no pw Char.isAlphaNum |> Debug.log "no pw Char.isAlphaNum"` where `no pw Char.isAlphaNum` is suppose to be and get the same result as if there was no `Debug.log` and still get printed _no pw Char.isAlphaNum: True_ to the devtools console.

But if I try to debug several calls to `no` in OR expressions, then the compiler will not allow it.

```elm
weakPassword : String -> Bool
weakPassword pw =
  no pw Char.isLower |> Debug.log "no pw Char.isLower"
  || no pw Char.isUpper |> Debug.log "no pw Char.isUpper"
  || no pw Char.isDigit |> Debug.log "no pw Char.isDigit"

```

Ok. I have to set parenthesis around expressions, like so:

```elm
weakPassword pw =
  (no pw Char.isLower |> Debug.log "no pw Char.isLower")
  || (no pw Char.isUpper |> Debug.log "no pw Char.isUpper")
  || no pw Char.isDigit |> Debug.log "no pw Char.isDigit"

```

---

<div class="post-metadata">

**Author:** ![dotnetCarpenter](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dotnetcarpenter/32/3216_2.png) [@dotnetCarpenter](https://discourse.elm-lang.org/u/dotnetCarpenter)\
**Post date:** [April 28, 2020, 2:27pm UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/5 "2020-04-28T14:27:05Z")

</div>

Yes, you are right. I might have gotten ahead of myself. I would not have considered trying to figure it out, had it not been because I was surprised by the size of the framework and that `elm make --optimize` did nothing measurable to shrink the size. I am still not sure that I have not done something wrong in my optimization setup but it almost looks like a bug. Why else would the Elm compiler output [functions called something like `_Utils_Tuple2_UNUSED`](https://github.com/dotnetcarpenter/elmtut#dead-code-elimination) and not just remove them?

---

<div class="post-metadata">

**Author:** ![dotnetCarpenter](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dotnetcarpenter/32/3216_2.png) [@dotnetCarpenter](https://discourse.elm-lang.org/u/dotnetCarpenter)\
**Post date:** [April 28, 2020, 3:10pm UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/6 "2020-04-28T15:10:51Z")

</div>

> when using lambda expressions, you need to wrap them in brackets:

Thank you for clarifying. I did try to wrap the lambda expression but today, I tried the same thing and I can not for the life in me reproduce the errors I got yesterday. Perhaps I was tired…

@lydell gave me the same advice on the [elm/error-message-catalog bug tracker](https://github.com/elm/error-message-catalog/issues/336#issuecomment-620428100).

Thank you all for responding to all my questions. The Elm community feels like a warm and good place to be 🙂

---

<div class="post-metadata">

**Author:** ![dotnetCarpenter](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dotnetcarpenter/32/3216_2.png) [@dotnetCarpenter](https://discourse.elm-lang.org/u/dotnetCarpenter)\
**Post date:** [April 28, 2020, 6:53pm UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/7 "2020-04-28T18:53:21Z")

</div>

This community is so nice!  
@pdamoc created an [issue Regarding the Dead Code Elimination](https://github.com/dotnetCarpenter/elmtut/issues/1) and pointed me to [https://dev.to/skinney/improving-elm-s-compiler-output-5e1h](https://dev.to/skinney/improving-elm-s-compiler-output-5e1h)

I feel that no question goes unanswered here! This is the first community where I have felt so attended to.

A big THANK YOU

---

<div class="post-metadata">

**Author:** ![dmy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dmy/32/702_2.png) [@dmy](https://discourse.elm-lang.org/u/dmy)\
**Post date:** [April 28, 2020, 10:09pm UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/8 "2020-04-28T22:09:49Z")

</div>

> 1. `elm` CLI does not have tab completion for commands or flags

If you use an sh derived shell, see [GitHub - dmy/elm-sh-completion: Bash or Zsh shell completion script for Elm binary and tools](https://github.com/dmy/elm-sh-completion).

> Normal anchor (hash) links does not work in the Guide. While headings do have IDs, the following [Reading Types · An Introduction to Elm](https://guide.elm-lang.org/types/reading_types.html#type-annotations) does not scroll to `<h2 id="type-annotations">Type Annotations</h2>` . I think it is because Elm apps are dynamic rendered and the browser can not scroll to an element that does not exist yet. A `scrollTo` function might be considered…

Most elm-lang web sites are Elm apps, but the guide uses gitbook, also dynamically rendered though. Other elm-lang web sites implemented in Elm do have indeed a `scrollTo` function most of the time, for example this [scrollIfNeeded](https://github.com/elm/package.elm-lang.org/blob/6e004897f23ffeb71b5d283f1d0042b64ff20a41/src/frontend/Page/Docs.elm#L122).

---

<div class="post-metadata">

**Author:** ![Chadtech](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/chadtech/32/609_2.png) [@Chadtech](https://discourse.elm-lang.org/u/Chadtech)\
**Post date:** [April 29, 2020, 1:24am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/9 "2020-04-29T01:24:05Z")

</div>

Thanks for posting here. I think that as a new comer, your impression and experience is super valuable.

I did find it surprising and a little implausible that the compiler wasnt eliminating dead code. Maybe the elm compiler doesnt eliminate unused code from core, such as the tuple functions in your readme example?

I just checked in my own project to verify that dead code elimination was working:

- I added an unused value called `xyz` and compiled my code, and sure enough, it was not in the compiled JS.
- In my project, I am using elm-css, but I know I am not using the `float` function from it. Sure enough, there were plenty of values from elm-css, but no instance of `float`.

---

<div class="post-metadata">

**Author:** ![dotnetCarpenter](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dotnetcarpenter/32/3216_2.png) [@dotnetCarpenter](https://discourse.elm-lang.org/u/dotnetCarpenter)\
**Post date:** [April 29, 2020, 10:09am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/10 "2020-04-29T10:09:36Z")

</div>

> [@Chadtech](#):
>
> I did find it surprising and a little implausible that the compiler wasnt eliminating dead code. Maybe the elm compiler doesnt eliminate unused code from core, such as the tuple functions in your readme example?

Yes, that is exactly what is happening. @pdamoc explains it very well here: [Regarding the Dead Code Elimination · Issue #1 · dotnetCarpenter/elmtut · GitHub](https://github.com/dotnetCarpenter/elmtut/issues/1#issue-608064913)

---

<div class="post-metadata">

**Author:** ![dotnetCarpenter](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dotnetcarpenter/32/3216_2.png) [@dotnetCarpenter](https://discourse.elm-lang.org/u/dotnetCarpenter)\
**Post date:** [April 29, 2020, 10:16am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/11 "2020-04-29T10:16:47Z")

</div>

> [@dmy](#):
>
> If you use an sh derived shell, see [GitHub - dmy/elm-sh-completion: Bash or Zsh shell completion script for Elm binary and tools](https://github.com/dmy/elm-sh-completion)

Thank you! I’ve added it to my bash completion and it works perfectly. 😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [May 9, 2020, 10:16am UTC](https://discourse.elm-lang.org/t/first-24-hours-with-elm/5663/12 "2020-05-09T10:16:48Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
