mirror of
https://github.com/wezm/wezm.net.git
synced 2024-12-18 10:19:54 +00:00
Add Gleam syntax highlighting
This commit is contained in:
parent
c5f5be6abe
commit
c191d6efd9
4 changed files with 44 additions and 3 deletions
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "v2/syntaxes/gleam"]
|
||||
path = v2/syntaxes/gleam
|
||||
url = https://github.com/digitalcora/sublime-text-gleam.git
|
|
@ -19,6 +19,7 @@ build_search_index = false
|
|||
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
|
||||
highlight_code = true
|
||||
smart_punctuation = true
|
||||
extra_syntaxes_and_themes = ["syntaxes/gleam"]
|
||||
|
||||
[extra]
|
||||
author = "Wesley Moore"
|
||||
|
|
|
@ -35,10 +35,46 @@ maintained Elm without the restrictions on interop with existing JavaScript
|
|||
code.
|
||||
|
||||
To get started here's some Gleam code that demonstrates a decent chunk of the
|
||||
language. My blog doesn't highlight Gleam code at the moment so what's shown
|
||||
below is a picture. See [example.gleam](example.gleam) for the source file:
|
||||
language:
|
||||
|
||||
<img src="gleam-example.png" width="378" alt="">
|
||||
```gleam
|
||||
import gleam/io
|
||||
import gleam/list
|
||||
import gleam/int
|
||||
|
||||
pub type Temperature {
|
||||
F(Float)
|
||||
C(Float)
|
||||
}
|
||||
|
||||
pub type Celcius {
|
||||
Celcius(Float)
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let temps = [C(22.0), C(-5.0), F(0.0), C(0.0), F(32.0)]
|
||||
io.debug(avg(temps))
|
||||
}
|
||||
|
||||
pub fn avg(measurements: List(Temperature)) -> Celcius {
|
||||
let sum =
|
||||
list.fold(measurements, 0.0, fn(sum, val) {
|
||||
let Celcius(c) = to_c(val)
|
||||
sum +. c
|
||||
})
|
||||
let length =
|
||||
list.length(measurements)
|
||||
|> int.to_float
|
||||
Celcius(sum /. length)
|
||||
}
|
||||
|
||||
fn to_c(temp: Temperature) -> Celcius {
|
||||
case temp {
|
||||
C(c) -> Celcius(c)
|
||||
F(f) -> Celcius({ f -. 32.0 } /. 1.8)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When run it outputs:
|
||||
|
||||
|
|
1
v2/syntaxes/gleam
Submodule
1
v2/syntaxes/gleam
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 6c2080bf6039aa4c844086953d5aca49a7cd5ab6
|
Loading…
Reference in a new issue