tvl-depot/users/Profpatsch/my-prelude
Profpatsch 80e04da5d4 docs(users/Profpatsch): Add small README to most subdirs
Change-Id: I2912e32fe1b2d3d3aff7bafba809634ec4c9adb6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8470
Autosubmit: Profpatsch <mail@profpatsch.de>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
2023-04-08 12:25:07 +00:00
..
Data/Error feat(users/Profpatsch/mailbox-org): list & update filters 2023-01-02 02:14:55 +00:00
Aeson.hs feat(users/Profpatsch/mailbox-org): list & update filters 2023-01-02 02:14:55 +00:00
default.nix feat(users/Profpatsch/my-prelude): Add Test.hs 2023-01-07 14:28:37 +00:00
Label.hs feat(users/Profpatsch/mailbox-org): prepare adjusting filter config 2023-01-05 22:10:20 +00:00
my-prelude.cabal feat(users/Profpatsch/netencode): Add initial Haskell parser 2023-01-08 23:10:28 +00:00
MyPrelude.hs feat(users/Profpatsch/netencode): Add initial Haskell parser 2023-01-08 23:10:28 +00:00
Pretty.hs feat(users/Profpatsch/mailbox-org): init 2023-01-01 22:02:25 +00:00
README.md docs(users/Profpatsch): Add small README to most subdirs 2023-04-08 12:25:07 +00:00
Test.hs feat(users/Profpatsch/my-prelude): Add Test.hs 2023-01-07 14:28:37 +00:00

My Haskell Prelude

Contains various modules Ive 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.