# Another super basic question (Syntax)

**URL:** <https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334>\
**Category:** Learn\
**Created:** [March 15, 2019, 2:41pm UTC](https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334 "2019-03-15T14:41:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![smalkasian](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/smalkasian/32/1913_2.png) [@smalkasian](https://discourse.elm-lang.org/u/smalkasian)\
**Post date:** [March 15, 2019, 2:41pm UTC](https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334/1 "2019-03-15T14:41:43Z")

</div>

One thing I am struggling through is I have no programming experience so every symbol confuses me. I am doing a lot of external research but there are a number I still wonder about. I am a fast learner, but I get held up by small stuff like that. I’ve been reading through the syntax lists, but they are not comprehensive for _all_ the syntax.  
Thanks Elm Community.

-Samuel

---

<div class="post-metadata">

**Author:** ![glennsl](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/glennsl/32/1496_2.png) [@glennsl](https://discourse.elm-lang.org/u/glennsl)\
**Post date:** [March 15, 2019, 3:42pm UTC](https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334/2 "2019-03-15T15:42:55Z")

</div>

I think perhaps you forgot the question? Which symbols are confusing you?

---

<div class="post-metadata">

**Author:** ![smalkasian](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/smalkasian/32/1913_2.png) [@smalkasian](https://discourse.elm-lang.org/u/smalkasian)\
**Post date:** [March 15, 2019, 4:31pm UTC](https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334/3 "2019-03-15T16:31:30Z")

</div>

I suppose I was asking more for resource lists if anyone knows. But yes, you make fair point… 😉 I am looking for explanation in how they function and why.

Symbols:  
(bar or pipe): |  
(arrow): -\>  
(colon) :  
(meaning) div  
(or just this symbol(s)) []

---

<div class="post-metadata">

**Author:** ![glennsl](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/glennsl/32/1496_2.png) [@glennsl](https://discourse.elm-lang.org/u/glennsl)\
**Post date:** [March 15, 2019, 6:03pm UTC](https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334/4 "2019-03-15T18:03:39Z")

</div>

I don’t know of any comprehensive resources for this other than [the official syntax reference](https://elm-lang.org/docs/syntax). I actually started on [a syntax guide for Reason](https://github.com/glennsl/reason-syntax-guide) once, before promptly forgetting about it, but I think something like that for Elm would be a great idea that _someone_ should do 😉

I can at least try to explain these symbols though.

Most of these symbols don’t have any deep meaning in themselves, but are just used as separators in various syntactic patterns. The reason they are different are usually to avoid ambiguous syntax where it’s difficult for both humans, but especially for computers to determine what kind of syntactic construct a symbol belongs to without taking into account a bigger context, which is often computationally expensive. The choice of each specific symbol is often historical, but also tend to work very well for humans in the contexts they are used.

- The pipe, `|`, is used in a couple of places, with different meanings. Most importantly to separate the variants of [custom types](https://guide.elm-lang.org/types/custom_types.html): `type Foo = A | B`. But it’s also used in the [record update](https://elm-lang.org/docs/records#updating-records) syntax to separate the name of the record to be updated from the field names: `{ oldRecord | aField = 2 }`

- The arrow, `->` is also used in several places with different meanings. In [type annotations](https://guide.elm-lang.org/types/reading_types.html#functions) it separates the argument of a function from its return type: `Int -> Float`. In anonymous functions it separates the argument list from its body: `\n m -> n + m`. And in [case expressions](https://guide.elm-lang.org/types/pattern_matching.html#case) it separates the pattern from the body of each branch: `case foo of pattern -> expression`.

- colon, `:`, has only a single use I think: to separate a name from its [type annotation](https://guide.elm-lang.org/types/reading_types.html): `someNumber : Int`

- square brackets, `[]`, are just the delimiters of a list, marking where it begins and ends: `[1, 2, 3]`. If there’s nothing in between the delimiters, `[]`, it’s just an empty list.

- Lastly, `div` is just a name like any other. and you can assign whatever you want to it. But odds are that the example you’re looking at imports it from [the `Html` module](https://package.elm-lang.org/packages/elm/html/latest/Html) where it is a function that returns an `Html` value representing an [HTML element](https://en.wikipedia.org/wiki/HTML_element) that is also conveniently named [`div`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div). HTML is what you’d use to create an HTML document and make exciting things happen in your web browser.

I hope that helps, but please let me know if you still have questions.

---

<div class="post-metadata">

**Author:** ![smalkasian](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/smalkasian/32/1913_2.png) [@smalkasian](https://discourse.elm-lang.org/u/smalkasian)\
**Post date:** [March 15, 2019, 6:05pm UTC](https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334/5 "2019-03-15T18:05:30Z")

</div>

Thank you so much for your time and help. You are a sir; cheers.

---

<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:** [March 25, 2019, 6:05pm UTC](https://discourse.elm-lang.org/t/another-super-basic-question-syntax/3334/6 "2019-03-25T18:05:31Z")

</div>

Closed on March 25, 2019, 6:05pm UTC

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