{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiepqt5s4wknh56nvtm5ljuumv5e3twbjn7akiedd6bnhbj2iax3jy",
"uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mlfboroaltn2"
},
"path": "/t/ann-today-is-doomsday-0-1/14061#post_1",
"publishedAt": "2026-05-09T01:16:18.000Z",
"site": "https://discourse.haskell.org",
"tags": [
"github.com",
"GitHub - xsebek/doomsday-hs: Algorithm for computing day of the week mentally.",
"Conway’s Doomsday algorithm"
],
"textContent": "Hi everyone,\n\nI wanted to share a small command line program I made to train calculating day of the week:\n\ngithub.com\n\n### GitHub - xsebek/doomsday-hs: Algorithm for computing day of the week mentally.\n\nAlgorithm for computing day of the week mentally.\n\nIt is based on Conway’s Doomsday algorithm, to mentally calculate year “anchor” (this year it’s Saturday) and then use mnemonics for each month’s “doomsday” (select Saturdays from which to count).\n\nLike today “working 9-to-5”, which also works for September 5th:\n\n\nIt has a REPL made with Haskeline and can show statistics using Granite:\n\nBut the fun part was implementing the core logic without depending on external libraries.\nThe result is an eDSL to create an explanation template for either Conway’s or alternative versions:\n\n\n findYearAnchorNakai =\n part \"Find the year anchor.\" $ startingWithYear 'Y' $ \\y -> do\n c1 <- stepI \"first take the century digits\" $ 'C' := y `div` 100\n c2 <- stepI \"and remainder dividing by four\" $ 'C' := c1 `mod` 4\n d1 <- stepI \"then take the last two digits\" $ 'D' := y `mod` 100\n d2 <- stepI \"and remainder dividing by four\" $ 'E' := d1 `mod` 4\n step \"add together to get\" $ 'W' := 5 * (c2 + d2 - 1) + 10 * d1\n\n\nThis may look daunting, but after adding each number modulo 7 a weekday pops out.\n\nFrom technical perspective, I really liked splitting the explanation, evaluation and pretty-printing.\nYears ago I tried simplifying the math manually in Swift in string interpolation and it was buggy and inconsistent.\nSo I decided to do it right() in Haskell!\n\nI hope some of you find this fun and can use it to amaze your friends and colleagues.",
"title": "[ANN] Today is Doomsday! (0.1)"
}