This is kind of a chonker because I went into so many rabbit holes. Foremost this implements a simple “Refresh Artist” button that fetches current artist torrent groups. BUG: the `artist` endpoint torrent struct is shite, it’s missing most info that we get in the `search` endpoint torrent struct, plus it’s organized differently (e.g. the `artists` thingy is in the torrent_group not the torrent). I should switch everything over to fetching the `torrent_group.id`s first and then going through and slowly fetching every torrent group separately … however that might time out very quickly. ugh. There doesn’t seem to be a way of fetching multiple torrent groups. Random other shit & improvements: * intersperse for builders * fix json errors so that the structs don’t get too big (`restrictJson`) * show error messages as json so jaeger displays it with nested UI * color pretty-printed json outpt on command line * add some important integral functions to MyPrelude * add `sintersperse` and `mintersperse` to MyPrelude Change-Id: If8bfcd68dc5c905e118ad86d50d7416962bf55d4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12960 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de> |
||
|---|---|---|
| .. | ||
| src | ||
| default.nix | ||
| my-prelude.cabal | ||
| README.md | ||
My Haskell Prelude
Contains various modules I’ve found useful when writing Haskell.
Contents
A short overview:
MyPrelude.hs
A collection of re-exports and extra functions. This does not replace the Prelude module from base, but rather should be imported in addition to Prelude.
Stuff like bad functions from prelude (partial stuff, or plain horrible stuff) are handled by a custom .hlint file, which you can find in ../.hlint.yaml.
The common style of haskell they try to enable is what I call “left-to-right Haskell”,
where one mostly prefers forward-chaining operators like &/<&>/>>= to backwards operators like $/<$>/<=<. In addition, all transformation function should follow the scheme of aToB instead of B.fromA, e.g. Text.unpack/Text.pack -> textToString/stringToText. Includes a bunch of text conversion functions one needs all the time, in the same style.
These have been battle-tested in a production codebase of ~30k lines of Haskell.
Label.hs
A very useful collection of anonymous labbeled tuples and enums of size 2 and 3. Assumes GHC >9.2 for RecordDotSyntax support.
Pretty.hs
Colorful multiline pretty-printing of Haskell values.
Test.hs
A wrapper around hspec which produces colorful test diffs.
Aeson.hs
Helpers around Json parsing.
Data.Error.Tree
Collect errors (from Data.Error) into a tree, then display them in a nested fashion. Super useful for e.g. collecting and displaying nested parsing errors.
RunCommand.hs
A module wrapping the process API with some helpful defaults for executing commands and printing what is executed to stderr.