Better HN
topnewbestaskshowjobs
Log inSign up

duckfan77

6 karma · joined Sep 14, 2025 (1y ago) · 2 submissions

Submissions

comment 1y ago · link · parent

The number of valid options is the sum of the valid option for each variant. This is also why product types are called product types.

If you have a struct (product type) containing an 8 bit integer and a boolean, the struct has 512 possible states. 256 for the integer, times 2 for each value of the boolean.

If you have a sum type where one variant is an 8 bit integer, and the other is a boolean, you have 258 possible states. 256 for when it's an integer, and 2 for when it's a boolean.

Sum types add the options of each variant, product types multiply the options for each item in it.

comment 1y ago · link · parent

My server sits next to my existing desktop, and I just move the keyboard cable from one to the other when I need to get at a local interface on the server. One of my monitors has two inputs, and so is always plugged into both, I can just change the input selected. Not the "cleanest" solution, but it works when I need to get at it, and the space it's in wasn't being used by anything else.