💻 My personal website blog.kacaii.dev/
blog gleam lustre

use rumdl instead of prettier

kacaii.dev 36f81a4f 3b16e211

verified
+45 -26
-1
.prettierignore
··· 1 - posts/
+17
.rumdl.toml
··· 1 + [global] 2 + disable = ["MD041", "MD049", "MD036"] 3 + 4 + exclude = [ 5 + ".git", 6 + ".github", 7 + "node_modules", 8 + "vendor", 9 + "dist", 10 + "build", 11 + "posts", 12 + 13 + "CHANGELOG.md", 14 + "LICENSE.md", 15 + ] 16 + 17 + respect-gitignore = true
+26 -24
priv/posts/building-my-college-project-with-gleam.md
··· 8 8 9 9 ## Picking a language 10 10 11 - Every semester my college assigns us a major project. This usually meant coming up 12 - with a startup concept or designing a website in Figma, but we never got to 13 - actually put our ideas _into practice_. This semester was different. 11 + Every semester my college assigns us a major project. This usually meant 12 + coming up with a startup concept or designing a website in Figma, but we never 13 + got to actually put our ideas _into practice_. This semester was different. 14 14 15 - Our task was to build a project aimed at helping firefighters handle a *large volume* of incidents. 16 - Being responsible for the backend _mostly_ by myself, I was a bit insecure. 17 - I needed something reliable and built for getting things done _fast_. 15 + Our task was to build a project aimed at helping firefighters handle a 16 + *large volume* of incidents. Being responsible for the backend _mostly_ by 17 + myself, I was a bit insecure. I needed something reliable and built for getting 18 + things done _fast_. 18 19 19 20 The rest of the class went with safer, popular choices like Python, TypeScript 20 21 and Java. They're great for building an API, but I couldn't imagine doing ··· 35 36 36 37 ### Errors as values 37 38 38 - One of the main reasons why I went with Gleam was their approach to *error handling*. 39 - Errors in Gleam are treated as _values_ you can return from any function. 40 - And the best part, *you can see if a function can fail by looking at its return type*. 39 + One of the main reasons why I went with Gleam was their approach 40 + to *error handling*. Errors in Gleam are treated as _values_ you can return 41 + from any function. And the best part, *you can see if a function can fail 42 + by looking at its return type*. 41 43 42 44 ```gleam 43 45 fn do_work() -> Result(String, MyCustomError) { ··· 61 63 ### Pattern matching 62 64 63 65 Being able to build custom error types pairs really well with 64 - Gleam's *pattern matching*. You can define it at the top level scope and easily `switch` 65 - on all possible values. 66 + Gleam's *pattern matching*. You can define it at the top level scope and easily 67 + `switch` on all possible values. 66 68 67 69 ```gleam 68 70 case err { ··· 127 129 ## Working with SQL 128 130 129 131 I'm really not a fan of using regular strings to store SQL queries, 130 - there's no *autocomplete*, no *syntax highlighting*, no *linting* from my editor. 131 - Luckily there's a package that takes care of all that for us! 132 + there's no *autocomplete*, no *syntax highlighting*, no *linting* 133 + from my editor. Luckily there's a package that takes care of all that for us! 132 134 133 135 [Squirrel](https://hexdocs.pm/squirrel) finds all database queries in your project 134 136 written in actual `.sql` files, and generates modules, decoders and ··· 154 156 ``` 155 157 156 158 We can then query our database simply by calling a function. 157 - There's no need to set up an ORM, build complicated decoders or do anything fancy. 158 - One thing you'll hear a lot from the Gleam community is that 159 - [all you need is data and functions.](https://mckayla.blog/posts/all-you-need-is-data-and-functions.html) 159 + There's no need to set up an ORM, build complicated decoders 160 + or do anything fancy. One thing you'll hear a lot from the Gleam community 161 + is that [all you need is data and functions.](https://mckayla.blog/posts/all-you-need-is-data-and-functions.html) 160 162 161 163 ```gleam 162 164 // Querying a database might fail, so it returns a `Result`! ··· 170 172 171 173 The returned results can easily be encoded into Json and sent to the client 172 174 through the response body. There's even a LSP code action for it! 173 - Just mouse over the type you want to generate an encoder for, and trigger the code 174 - action selector by using your IDE. 175 + Just mouse over the type you want to generate an encoder for, 176 + and trigger the code action selector by using your IDE. 175 177 176 178 ```gleam 177 179 import gleam/json ··· 193 195 194 196 ## Conclusion 195 197 196 - This was my first time building a backend project, and if it didn't work as expected, 197 - the whole group would be affected. Thankfully we ran into zero runtime errors so far, 198 - and all endpoints behaved as intended. 198 + This was my first time building a backend project, and if it didn't work 199 + as expected, the whole group would be affected. Thankfully we ran into zero 200 + runtime errors so far, and all endpoints behaved as intended. 199 201 200 - Errors were explicit, data had clear shapes and most error messages felt more like guidance 201 - than of a bunch of scrambled text. If you ever need a reliable backend API, I trully 202 - recommend you [give Gleam a try](https://gleam.run/). 202 + Errors were explicit, data had clear shapes and most error messages felt more 203 + like guidance than of a bunch of scrambled text. If you ever need a reliable 204 + backend API, I trully recommend you [give Gleam a try](https://gleam.run/).
+2 -1
priv/posts/uses.md
··· 38 38 ### Version Control 39 39 40 40 - [󰳆 ]{.nf aria-hidden=true} [Tangled][]: I recently moved away 41 - from Github, tangled feels like breath of fresh air. All data is stored in my PDS[^pds] 41 + from Github, tangled feels like breath of fresh air. All data is stored in my 42 + PDS[^pds] 42 43 - [ ]{.nf aria-hidden=true} [Jujutsu][]: Feels more flexible and intuitive 43 44 than Git, also tangled has support for it! 44 45