[chore] add numbering for haskell-tooling post
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
mangoiv 2024-06-23 14:08:06 +02:00
parent 986bdc025a
commit daca65f952
Signed by: mangoiv
SSH key fingerprint: SHA256:JlsRe4zkmS13EG6gMFNjv13Lw5rtoMPu3Lq69ZQTKF8
2 changed files with 47 additions and 41 deletions

View file

@ -10,7 +10,7 @@ This is especially well-suite for beginners who need to get an overview. Every p
If you have corrections or additional tools that I should list, please contact me at [contact@mangoiv.com](mailto:contact@mangoiv.com).
## compilers
## 1. compilers
The de-facto standard to compile Haskell programs is the [Glorious Glasgow Haskell Compiler (`GHC`)](https://downloads.haskell.org/ghc/latest/docs/users_guide/) it not only supports the most features,
it also produces the most optimized code, the best error messages and has the most features.
@ -20,23 +20,23 @@ If you, for some reason, require a compiler with a less complicated bootstrappin
Documentation on how to use the `GHC`, can be found in the [user's guide](https://downloads.haskell.org/ghc/latest/docs/users_guide/).
## build systems
## 2. build systems
### cabal
### 2.1 cabal
While ghc supports `make`, the ubiquitous build tool for haskell programs is [`cabal`](https://cabal.readthedocs.io/en/stable/). Most Haskell
software is packaged with `cabal`. You can recognise this from the presence of the `*.cabal` file in the project.
NB: `cabal` consists of two things: the `Cabal` library and the `cabal-install` command line tool, which provides all the commands you want.
### stack
### 2.2 stack
There are multiple build tools wrapping `cabal`. The most well-known one is probably [`stack`](https://docs.haskellstack.org/en/stable/). While it reaches out to `cabal` to build the
actual projects, it uses a different way of resolving your dependencies. instead of respecting the version bounds set by packages and then
"solving" (in the sense of SAT-solving) your package set, it uses [`stackage`](https://www.stackage.org/) to provide snapshots of a large part
of the available (cabal) packages in the haskell ecosystem which then already have versions that at least build together.
### nixpkgs
### 2.3 nixpkgs
[`nixpkgs`](https://github.com/nixos/nixpkgs) provides infrastructure for building haskell packges. Documentation for this can be found in the
[nixpkgs manual](https://nixos.org/manual/nixpkgs/unstable/#haskell). If you already use nix or if you want to build a complex project that involves multiple
@ -44,7 +44,7 @@ languages, then `nixpkgs` is a popular choice.
There are also stackage-like package sets that can be used with the nixpkgs haskell infrastructure provided by [the horizon haskell project](https://horizon-haskell.net/).
### others
### 2.4 others
An alternative way of building haskell packages with nix is [`haskell.nix`](https://input-output-hk.github.io/haskell.nix/). There are tradeoffs compared to the nixpkgs
infrastructure but the general takeaway is that you should probably not use it if you don't already know why.
@ -54,9 +54,9 @@ but it brings a large amount of complexity which you probably don't want to opt-
Haskell projects can also be built with `make`. You should probably not do that though, if you don't have good reasons.
## installers for haskell tooling
## 3. installers for haskell tooling
### ghcup
### 3.1 ghcup
[`ghcup`](https://www.haskell.org/ghcup/) is *the* go-to installer for haskell related tools. It installs
@ -68,25 +68,25 @@ Haskell projects can also be built with `make`. You should probably not do that
Follow their instructions on how to get it, it already comes with its own extensive documentation.
### nixpkgs
### 3.2 nixpkgs
`nixpkgs` also packages all of the above. Refer to the documentation for [`shellFor`](https://nixos.org/manual/nixpkgs/unstable/#haskell-development-environments) for how to use it.
There are also quick-start tools like [`haskell-flake`](https://flake.parts/options/haskell-flake) that use the same machinery beneath a convenience interface.
(NB: consider whether you have enough sanity left for joining the community associated with that particular project, you have been warned.)
### stack
### 3.3 stack
stack provides ways to install various tools, including `ghc`. Nowadays, `ghcup` is strictly preferred.
### others
### 3.4 others
`haskell.nix` packages its own GHCs. [`ghcs-nix`](https://gitlab.haskell.org/bgamari/ghcs-nix) provides a large number of ghcs packaged. Additionally you can
always download binary distributions directly from the respective repositories/ download pages.
## development tools
## 4. development tools
### haskell-language-server
### 4.1 haskell-language-server
[`haskell-language-server`](https://github.com/haskell/haskell-language-server) is the most mature implementation of the language server protocol
for haskell. It provides various plugins that can do many things from semantic highlighting to executing code directly from the source files (the eval plugin).
@ -102,43 +102,43 @@ It is supported basically by all editors which can talk the language server prot
...and many more.
### cabal repl
### 4.2 cabal repl
Firing up a `GHCi` repl is one of the nicest ways of interacting with the compiler. `cabal` provides a tool that can do that for your entire cabal project:
just run `cabal repl` in your `cabal` project.
### ghcid
### 4.3 ghcid
[`ghcid`](https://github.com/ndmitchell/ghcid) provides capabilities for automatically reloading your `cabal` projects or single haskell files. It can be
installed via the `cabal install ghcid` but also with `stack` and `nixpkgs`.
### ghciwatch
### 4.4 ghciwatch
[`ghciwatch`](https://github.com/MercuryTechnologies/ghciwatch) is a relatively new alternative to `ghcid` writtin in rust (embarassing), check it out!
### static-ls
### 4.5 static-ls
[`static-ls`](https://github.com/josephsumabat/static-ls) is a language-server protocol implementation for very large projects where `hls` would struggle.
I have not personally used it, but I recommend checking it out if you have problems with resource usage of haskell-language-server on your PC.
## linters
## 5. linters
### hlint
### 5.1 hlint
[`hlint`](https://github.com/ndmitchell/hlint) is a linter for haskell files. It can find common issues with haskell code and give you stylistic hints to
improve your code. You can adjust its hints and `haskell-language-server` can show you the hints.
### stan
### 5.2 stan
[`stan`](https://github.com/kowainik/stan) is a static analyzer for haskell code. While the idea of having one is good, most of the hints are low quality
and are quite verbose. I don't recommend enabling this plugin to be run on your project continuously or as part of `haskell-language-server`, but
it might be good to check it every now and then.
## formatters
## 6. formatters
### for `.hs` files
### 6.1. for `.hs` files
#### ormolu
#### 6.1.2 ormolu
[`ormolu`](https://github.com/tweag/ormolu) is an opinionated code formatter for haskell files written by tweag, the two main ideas are
- produce diffs that are as small as possible by normalizing haskell code as strongly as possible
@ -146,12 +146,12 @@ it might be good to check it every now and then.
`ormolu` is one of the best maintained haskell formatters and is generally quite stable and a good choice.
#### fourmolu
#### 6.1.3 fourmolu
[`fourmolu`](https://github.com/fourmolu/fourmolu) is a fork of `ormolu` that allows you to pass configuration options. You can adjust all sorts of formatting
preferences. It's my go-to formatter. It's equally stable as `ormolu` and works very well in most cases.
#### stylish-haskell
#### 6.1.4 stylish-haskell
[stylish-haskell](https://github.com/haskell/stylish-haskell) is a formatter which has a less modern look than `ormolu` and `fourmolu` and it does things
like formatting imports such that they're aligned which you might recognise if you read some older haskell code out there.
@ -159,64 +159,69 @@ like formatting imports such that they're aligned which you might recognise if y
I had some problems with `stylish-haskell` not being able to format some code that uses some of the more recent language extensions but I don't
konw if they have fixed that since.
#### hindent
#### 6.1.5 hindent
[`hindent`](https://github.com/mihaimaruseac/hindent) is another source code formatter. I don't have anything to say about it because I never used it.
#### weeder
#### 6.1.6 weeder
[`weeder`](https://github.com/ndmitchell/weeder) is a haskell tool that can detect dead code for you.
### for `.cabal` files
### 6.2. for `.cabal` files
#### cabal-fmt
#### 6.2.1 cabal-fmt
[`cabal-fmt`](https://github.com/phadej/cabal-fmt) is the quasi-standard in `.cabal` file formatting. It is well-maintained and it brings some nice-to-haves
like automatic source file detection (by the use of special comments) and insertion into your `.cabal` file.
#### cabal format
#### 6.2.2 cabal-gild
[cabal-gild](https://github.com/tfausak/cabal-gild) is a `cabal` file formatter similar to `cabal-fmt` and with similar maximes to
`ormolu`.
#### 6.2.3 cabal format
`cabal format` is the formatting tool built into `cabal`. It is not very well maintained and I generally recommend against using it. It will probably
break your `.cabal` file.
### for other files
### 6.3. for other files
#### hpack
#### 6.3.1 hpack
[`hpack`](https://github.com/sol/hpack) is a tool that provides capabilities for using an alternative package stanza format written out as `yaml` files
that can replace `.cabal` files. It is used by `stack` but can also be used standalone if you dislike the `.cabal` file format.
## tooling that supports GHC
## 7. tooling that supports GHC
### the haskell error message index
### 7.1 the haskell error message index
If you run ghc version >= 9.6 you might have seen that error messages are annoated with a unique numbers. Chances are, that, if you find an error confusing
you will find it [in the haskell error message index](https://github.com/haskellfoundation/error-message-index). They also
[have a nice website](https://errors.haskell.org/).
### profiling
### 7.2. profiling
GHC can profile your program. To refer to what options are available, refer to
[the ghc user's guide](https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html).
#### eventlog2html
#### 7.2.1 eventlog2html
[eventlog2html](https://mpickering.github.io/eventlog2html/) can convert your profiles in eventlog format to pretty graphs.
#### speedscope
#### 7.2.2 speedscope
[speedscope](https://www.speedscope.app/) can likewise turn your profiling output into flame graphs. An example of how to do it
[can be found in this well-typed blogpost](https://well-typed.com/blog/2023/03/prof-late/).
## security tooling
## 8. security tooling
### the haskell security advisories database
### 8.1 the haskell security advisories database
[The haskell security advisories database](https://github.com/haskell/security-advisories) maintains a list of packages vulnerable to security issues.
It is maintained by the haskell security working group. They also [have a website](https://haskell.github.io/security-advisories/) that lists all
advisories.
### cabal-audit
### 8.2 cabal-audit
[`cabal-audit`](https://github.com/MangoIV/cabal-audit/) is a tool that can query your haskell project agains the haskell security advisories database.

View file

@ -7,6 +7,7 @@ import Data.ByteString.Lazy qualified as BS
import Hakyll
import Skylighting.Styles
import Text.Pandoc.Highlighting
import Text.Pandoc.Options
--------------------------------------------------------------------------------
main :: IO ()
@ -69,7 +70,7 @@ main = do
match "posts/*" do
route $ setExtension "html"
compile $
pandocCompiler
pandocCompilerWith defaultHakyllReaderOptions {readerExtensions = pandocExtensions} defaultHakyllWriterOptions
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls