<commit_before>
import Website.Skeleton
import Website.ColorScheme

intro = [markdown|

<h1><div style="text-align:center">The Syntax of Elm
<div style="font-size:0.5em;font-weight:normal">*A Quick Tour*</div></div>
</h1>

<style type="text/css">
h3 { padding-top: 1em; }
pre {
 background-color: rgb(245,245,245);
 margin: 0 30px;
 padding: 4px 10px;
 border-left: solid 2px rgb(96,181,204);
}
</style>

This document lists all possible Elm syntax.

- [Comments](#comments)
- [Literals](#literals)
- [Lists](#lists)
- [Conditionals](#conditionals)
- [Algebraic Data Types](#algebraic-data-types)
- [Records](#records)
- [Functions](#functions)
- [Let Expressions](#let-expressions)
- [Applying Functions](#applying-functions)
- [Lifting with (<~) and (~)](#lifting)
- [Modules](#modules)
- [JavaScript FFI](#javascript-ffi)
- [Things *not* in Elm](#things-not-in-elm)

To learn about the libraries and semantics of Elm, check out the [Documentation][docs].

  [docs]: /Documentation.elm "Documentation"

### Comments

    -- a single line comment

    {- a multiline comment
       {- can be nested -}
    -}

Here's a handy trick that every Elm programmer should know:

    {--}
    add x y = x + y
    --}

Just add or remove the `}` on the first line and you'll toggle between commented and uncommented!

### Literals

The following shows all the different boolean literals and operators.

    True && not (True || False)

Character and string literals are defined as follows:

    'a'       -- Char
    "Hello!"  -- String

A `Number` can be interpreted as an `Int` or a `Float` depending on how it is used.

    42        -- Number
    3.14      -- Float

### Lists

Here are four things that are equivalent:

    [1,2,3,4]
    1 :: [2,3,4]
    1 :: 2 :: 3 :: 4 :: []
    [1..4]

Here are two things that are equivalent:

    ['a','b','c']
    "abc"

### Conditionals

    if conditional then trueBranch else falseBranch
    if powerLevel > 9000 then "OVER 9000!!!" else "meh"

Multi-way if-expressions make it easier
to have a bunch of different branches.
You can read the `|` as *where*.

    if | key == 40 -> n+1
       | key == 38 -> n-1
       | otherwise -> n

You can alse have conditional behavior based on the structure of algebraic
data types.

    case exp of
      Pattern1 -> exp1
      Pattern2 -> exp2
      _        -> exp3

    case xs of
      []    -> Nothing
      x::xs -> Just x

Each pattern is indentation sensitive, meaning that you have to align
all of your patterns for this to parse right.

If you think you can do a one liner, it might be useful to use the `{;;}`
separators for your case statement.

    case xs of { [] -> True ; _ -> False }

This kind of case-expression is not indentation sensitive.

### Algebraic Data Types

    data List = Nil | Cons Int List

Not sure what this means? [Read this.](/learn/Pattern-Matching.elm)

### Records

For more explanation of Elm&rsquo;s record system, see [this overview][exp],
the [initial announcement][v7], or [this academic paper][records].

  [exp]: /learn/Records.elm "Records in Elm"
  [v7]:  /blog/announce/version-0.7.elm "Elm version 0.7"
  [records]: http://research.microsoft.com/pubs/65409/scopedlabels.pdf "Extensible records with scoped labels"

    point = { x = 3, y = 4 }       -- create a record

    point.x                        -- access field
    map .x [point,{x=0,y=0}]       -- field access function

    { point - x }                  -- remove field
    { point | z = 12 }             -- add field
    { point - x | z = point.x }    -- rename field
    { point - x | x = 6 }          -- update field

    { point | x <- 6 }             -- nicer way to update a field
    { point | x <- point.x + 1
            , y <- point.x + 1 }   -- batch update fields

    dist {x,y} = sqrt (x^2 + y^2)  -- pattern matching on fields
    \\{x,y} -> (x,y)

    lib = { id x = x }             -- polymorphic fields
    (lib.id 42 == 42)
    (lib.id [] == [])

    data Located a = Located {line : Int, column : Int} a

### Functions

    f x = exp

You can pattern match in the declaration of any function.

    hypotenuse a b = sqrt (a^2 + b^2)
<commit_msg>Get syntax page working. Make a minor update in the records section.<commit_after>
import Website.Skeleton
import Website.ColorScheme
import Window as Window

intro = [markdown|

<h1><div style="text-align:center">The Syntax of Elm
<div style="font-size:0.5em;font-weight:normal">*A Quick Tour*</div></div>
</h1>

<style type="text/css">
h3 { padding-top: 1em; }
pre {
 background-color: rgb(245,245,245);
 margin: 0 30px;
 padding: 4px 10px;
 border-left: solid 2px rgb(96,181,204);
}
</style>

This document lists all possible Elm syntax.

- [Comments](#comments)
- [Literals](#literals)
- [Lists](#lists)
- [Conditionals](#conditionals)
- [Algebraic Data Types](#algebraic-data-types)
- [Records](#records)
- [Functions](#functions)
- [Let Expressions](#let-expressions)
- [Applying Functions](#applying-functions)
- [Lifting with (<~) and (~)](#lifting)
- [Modules](#modules)
- [JavaScript FFI](#javascript-ffi)
- [Things *not* in Elm](#things-not-in-elm)

To learn about the libraries and semantics of Elm, check out the [Documentation][docs].

  [docs]: /Documentation.elm "Documentation"

### Comments

    -- a single line comment

    {- a multiline comment
       {- can be nested -}
    -}

Here's a handy trick that every Elm programmer should know:

    {--}
    add x y = x + y
    --}

Just add or remove the `}` on the first line and you'll toggle between commented and uncommented!

### Literals

The following shows all the different boolean literals and operators.

    True && not (True || False)

Character and string literals are defined as follows:

    'a'       -- Char
    "Hello!"  -- String

A `Number` can be interpreted as an `Int` or a `Float` depending on how it is used.

    42        -- Number
    3.14      -- Float

### Lists

Here are four things that are equivalent:

    [1,2,3,4]
    1 :: [2,3,4]
    1 :: 2 :: 3 :: 4 :: []
    [1..4]

Here are two things that are equivalent:

    ['a','b','c']
    "abc"

### Conditionals

    if conditional then trueBranch else falseBranch
    if powerLevel > 9000 then "OVER 9000!!!" else "meh"

Multi-way if-expressions make it easier
to have a bunch of different branches.
You can read the `|` as *where*.

    if | key == 40 -> n+1
       | key == 38 -> n-1
       | otherwise -> n

You can alse have conditional behavior based on the structure of algebraic
data types.

    case exp of
      Pattern1 -> exp1
      Pattern2 -> exp2
      _        -> exp3

    case xs of
      []    -> Nothing
      x::xs -> Just x

Each pattern is indentation sensitive, meaning that you have to align
all of your patterns for this to parse right.

If you think you can do a one liner, it might be useful to use the `{;;}`
separators for your case statement.

    case xs of { [] -> True ; _ -> False }

This kind of case-expression is not indentation sensitive.

### Algebraic Data Types

    data List = Nil | Cons Int List

Not sure what this means? [Read this.](/learn/Pattern-Matching.elm)

### Records

For more explanation of Elm&rsquo;s record system, see [this overview][exp],
the [initial announcement][v7], or [this academic paper][records].

  [exp]: /learn/Records.elm "Records in Elm"
  [v7]:  /blog/announce/version-0.7.elm "Elm version 0.7"
  [records]: http://research.microsoft.com/pubs/65409/scopedlabels.pdf "Extensible records with scoped labels"

    point = { x = 3, y = 4 }       -- create a record

    point.x                        -- access field
    map .x [point,{x=0,y=0}]       -- field access function

    { point - x }                  -- remove field
    { point | z = 12 }             -- add field
    { point - x | z = point.x }    -- rename field
    { point - x | x = 6 }          -- update field

    { point | x <- 6 }             -- nicer way to update a field
    { point | x <- point.x + 1
            , y <- point.x + 1 }   -- batch update fields

    dist {x,y} = sqrt (x^2 + y^2)  -- pattern matching on fields
    \\{x,y} -> (x,y)

    lib = { id x = x }             -- polymorphic fields
    (lib.id 42 == 42)
    (lib.id [] == [])

    type Location = { line:Int, column:Int }

### Functions

    f x = exp

You can pattern match in the declaration of any function.

    hypotenuse a b = sqrt (a^2 + b^2)

{'fraction_non_alphanumeric': 0.1321880219518015, 'fraction_numerical': 0.023144834168456217, 'mean_word_length': 2.508999581414818, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6683305', 'n_tokens_mistral': 2887, 'n_tokens_neox': 2614, 'n_words': 972}