frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Monoid-Augmented FIFOs, Deamortised

https://pvk.ca/Blog/2025/08/19/monoid-augmented-fifos/
21•todsacerdoti•6h ago

Comments

seanhunter•5h ago
For people who haven’t done abstract algebra, don’t be put off by the word “monoid”. A monoid in algebra is just a set with some associative binary operation and an identity element. Mathematicians in the 19th and 20th centuries realised you can study these types of structures and prove things which are true for all of them rather than having to do each one separately, and that led to “abstract algebra”.

So for example, if I have the integers and multiplication, this is a monoid[1]. The identity element is zero, which is an integer, and multiplication is an associative binary operation. It takes two integers and returns an integer.

Once you realise you have a monoid, if you do maths that only relies on the monoid properties then it applies to all monoids, so you could drop a different monoid in there and everything would still work. This ends up being very much like how typeclasses work in Haskell or traits in Rust.

[1] For the curious, it’s not a “group” because the integers don’t have multiplicative inverses. If I have x=2, there is no integer that I can multiply that by to get 1. Integers with addition on the other hand is a group, which is a monoid with the additional property that inverses are present.

bern4444•5h ago
> The identity element is zero

I think the identity element would be 1 for integers and multiplication, right?

0 would be the identity element for integers and addition.

aranchelk•5h ago
That and also why start with multiplication? String concatenation, addition, list concatenation all make more intuitive sense to a working programmer.

What's a straightforward way to combine a bunch of numbers? Just keep multiplying them to get a resulting volume in an ever-higher dimensional space.

seanhunter•2h ago
Yes. Sorry I edited my original to change the operation.
xeonmc•3h ago

    For the curious, it’s not a “group” because the integers don’t have multiplicative inverses. If I have x=2, there is no integer that I can multiply that by to get 1. Integers with addition on the other hand is a group, which is a monoid with the additional property that inverses are present.
Would one be correct to say that square matrices are an example of monoids, since they have an identity element and are associative, but might not necessarily have inverses if their determinant is zero?
Jaxan•2h ago
Yes
sd9•30m ago
The operation is important too. Square matrices over integers with matrix multiplication is (just) a monoid. Square matrices with addition are a monoid too (but also a group, because there is an additive inverse).

Put it all together and it’s called a ring

IngoBlechschmid•3h ago
Somebody asked in a now-deleted comment: 'Right, and what does it mean in the context of "A monad is just a monoid in the category of endofunctors"?'

Here is an answer to this question:

What the parent poster referred to are "monoids in the category of sets". You can recognize this as they have introduced the carrier as (just a) set.

But the notion can be generalized. For instance, a "monoid in the category of datatypes" would not be given by a mathematical set and a mathematical binary operation, but by a datatype and a computable binary operation. (To make this precise, I would need to fix which "category of datatypes" I have in mind. It could be the category of Haskell types and Haskell functions, for instance; but C types and functions would work just as well. I could also go all the way to the effective topos, which contains lots of types which most mainstream programming languages are missing such as true quotient types.)

Finally, a "monoid in the category of endofunctors" is given by an endofunctor and a natural transformation. Endofunctors can be pictured as container kinds (e.g. ordered lists, unordered lists, Maybe/Optional, trees, vectors of length n, pairs, ...) and the additional datum of the natural transformation is what singles out those container kinds which support a "flattening operation" from those which don't. For instance, we can flatten a list of lists into one (long) list, but we cannot flatten a pair of pairs into one pair (we would need to drop two of the four elements).

Just as it is quite convenient that many results about integers or lists also hold for all monoids in the category of sets, it is quite nice that many results about monoids in the category of sets also hold for all monoids in all categories and hence in particular to monads.

renox•2h ago
Interesting topic, too bad I didn't know about this a few years ago..

AGENTS.md – Open format for guiding coding agents

https://agents.md/
530•ghuntley•10h ago•236 comments

How to Think About GPUs

https://jax-ml.github.io/scaling-book/gpus/
121•alphabetting•1d ago•27 comments

Ask HN: Why does the US Visa application website do a port-scan of my network?

172•mbix77•4h ago•73 comments

Modern CI is too complex and misdirected (2021)

https://gregoryszorc.com/blog/2021/04/07/modern-ci-is-too-complex-and-misdirected/
86•thundergolfer•7h ago•37 comments

How to Draw a Space Invader

https://muffinman.io/blog/invaders/
324•abdusco•11h ago•36 comments

Copilot broke audit logs, but Microsoft won't tell customers

https://pistachioapp.com/blog/copilot-broke-your-audit-log
516•Sayrus•10h ago•175 comments

How we exploited CodeRabbit: From simple PR to RCE and write access on 1M repos

https://research.kudelskisecurity.com/2025/08/19/how-we-exploited-coderabbit-from-a-simple-pr-to-rce-and-write-access-on-1m-repositories/
603•spiridow•18h ago•201 comments

D2 (text to diagram tool) now supports ASCII renders

https://d2lang.com/blog/ascii/
321•alixanderwang•16h ago•52 comments

Tiny microbe challenges the definition of cellular life

https://nautil.us/a-rogue-new-life-form-1232095/
101•jnord•11h ago•25 comments

Type-machine

https://arthi-chaud.github.io/posts/type-machine/
23•todsacerdoti•5h ago•5 comments

How I Made Ruby Faster Than Ruby

https://noteflakes.com/articles/2025-08-18-how-to-make-ruby-faster
43•ciconia•1d ago•9 comments

The Value of Hitting the HN Front Page

https://www.mooreds.com/wordpress/archives/3530
95•mooreds•8h ago•40 comments

Gaussian Processes for Machine Learning [pdf]

https://gaussianprocess.org/gpml/chapters/RW.pdf
28•susam•1d ago•5 comments

Fast and observable background job processing for .NET

https://github.com/mikasjp/BusyBee
17•mikasjp•2d ago•5 comments

Show HN: I've made an easy to extend and flexible JavaScript logger

https://github.com/inshinrei/halua
4•inshinrei•21h ago•3 comments

Emacs as your video-trimming tool

https://xenodium.com/emacs-as-your-video-trimming-tool
244•xenodium•18h ago•124 comments

Customizing Lisp REPLs

https://aartaka.me/customize-repl.html
17•nemoniac•1d ago•3 comments

Candle Flame Oscillations as a Clock

https://cpldcpu.com/2025/08/13/candle-flame-oscillations-as-a-clock/
292•cpldcpu•4d ago•65 comments

Without the futex, it's futile

https://h4x0r.org/futex/
270•eatonphil•20h ago•124 comments

Rails Charts Using ECharts from Apache

https://github.com/railsjazz/rails_charts
45•amalinovic•2d ago•4 comments

Intel Foundry Demonstrates First Arm-Based Chip on 18A Node

https://hothardware.com/news/intel-foundry-demos-deer-creek-falls-reference-soc
46•rbanffy•1d ago•21 comments

CRDT: Text Buffer

https://madebyevan.com/algos/crdt-text-buffer/
123•skadamat•14h ago•6 comments

AnduinOS

https://www.anduinos.com/
129•TheFreim•15h ago•162 comments

Drunken Bishop (2023)

https://re.factorcode.org/2023/08/drunken-bishop.html
67•todsacerdoti•12h ago•12 comments

How Figma’s multiplayer technology works (2019)

https://www.figma.com/blog/how-figmas-multiplayer-technology-works/
151•redbell•3d ago•48 comments

We’re Not So Special: A new book challenges human exceptionalism

https://democracyjournal.org/magazine/78/were-not-so-special/
77•nobet•8h ago•150 comments

Show HN: OpenAI/reflect – Physical AI Assistant that illuminates your life

https://github.com/openai/openai-reflect
77•Sean-Der•14h ago•29 comments

Custom telescope mount using harmonic drives and ESP32

https://www.svendewaerhert.com/blog/telescope-mount/
287•waerhert•1d ago•105 comments

Why Semantic Layers Matter (and how to build one with DuckDB)

https://motherduck.com/blog/semantic-layer-duckdb-tutorial/
133•secondrow•17h ago•29 comments

Show HN: Hanaco Weather – A poetic weather SNS from the OS Yamato project

https://github.com/osyamato/os-yamato
13•tsuyoshi_k•6h ago•5 comments