[{"data":1,"prerenderedAt":282},["ShallowReactive",2],{"project-40478175":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":35,"aspects":36,"strip":40,"post_text":41,"what":42,"said":58,"maker_in_thread":112,"shape":114,"grid":119,"attempts":242,"same_week":243,"maker_shows":32,"maker_hidden":274,"reader_version":275,"card":276},"40478175","sumtype.h","Sum (algebraic) types for C in one 100 line header","title","Show HN: Sum (algebraic) types for C in one 100 line header","https:\u002F\u002Fgithub.com\u002Fgrego\u002Fsumtype.h","github.com","marosgrego",1716674300,2024,92,43,893,3515,26,"notable","languages","c header library","library",[24,25,26,27],"c sum types","tagged union","c99 macro","algebraic data types","roasted",-0.313,{"positive":31,"neutral":32,"mixed":33,"critical":34},0,2,1,3,6,{"docs":37,"idea":38,"execution":39},{"positive":31,"critical":33},{"positive":31,"critical":33},{"positive":31,"critical":33},[33,31,31,34,34,33,34,31,31,31,31,31,31,33,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31],null,{"problem":41,"audience":41,"pricing":41,"motivation":41,"time_to_build":41,"stack":43,"openness":56,"stage":57,"team_size":57},[44],{"value":45,"source":46,"evidence":47},"C99 macros","commenter",[48,52],{"id":49,"by":50,"text":51},"40498233","feb","Nice system built with only a couple of C99 macros. That small header also achieves matching for specific C types over the \"sum types\". In the context of C99, isn't tagged union…",{"id":53,"by":54,"text":55},"40502446","ackfoobar","Saw the title and thought \"Didn't I just see C sum types in HN recently?\" https:\u002F\u002Fnews.ycombinator.com\u002Fitem?id=40307098 > Inspired by datatype99, but consisting of one small…","open_source","unknown",{"praise":59,"objections":65,"requests":80,"questions":88,"alternatives":100},[60],{"value":61,"source":46,"evidence":62},"Nice small standard-conforming C99 header, fast to compile",[63,64],{"id":49,"by":50,"text":51},{"id":53,"by":54,"text":55},[66,73],{"value":67,"source":46,"evidence":68},"Not very practical without type variables; misses generics of Haskell-style ADTs",[69],{"id":70,"by":71,"text":72},"40501048","chongli","It's interesting but not very practical. It's an \"algebra of types\" with only constants, no variables, since C does not have type variables. Thus it misses much of the point of…",{"value":74,"source":46,"evidence":75},"Preprocessor macros cause messy compiler errors and warnings",[76],{"id":77,"by":78,"text":79},"40499791","xurukefi","It's a nice idea, but I don't think it adds enough clarity to the code to justify the messy compiler warnings and errors that this kind of preprocessor abuse will eventually cause.",[81],{"value":82,"source":46,"evidence":83},"Add type variables to C",[84],{"id":85,"by":86,"text":87},"40505663","Gibbon1","I got to say adding type variables to C would be super duper. And to me actually feels rather C like as well.",[89,96],{"value":90,"source":46,"evidence":91},"Why link to GitHub rather than the SourceHut repository",[92],{"id":93,"by":94,"text":95},"40502230","danielspace23","I know it's a minor thing, but why does this link to GitHub? The repository is described only as being a mirror of a SourceHut repo, and the user's profile has a banner telling…",{"value":97,"source":46,"evidence":98},"Isn't tagged union the more usual name than sum type in C",[99],{"id":49,"by":50,"text":51},[101,105],{"value":102,"source":46,"evidence":103},"datatype99 C99 macro header",[104],{"id":53,"by":54,"text":55},{"value":106,"source":46,"evidence":107},"std::variant in C++",[108],{"id":109,"by":110,"text":111},"40501279","tempodox","+1. It cannot possibly be worse than the C++ `std::variant` blunder.",{"comments":31,"answered":31,"key":113},[],{"commenters":115,"max_depth":116,"maker_replies":31,"first_comment_mins":117,"lifespan_hours":118},39,5,3408,71,[120,122,126,129,131,132,134,138,140,142,145,148,152,155,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204,207,210,212,214,217,219,222,225,228,231,234,237,239],[93,31,33,121,94,31],"maker\u002Fcritical\u002Fdocs",[123,31,31,124,125,31],"40503262","commenter\u002Fneutral\u002Fnone","beryilma",[127,31,31,124,128,31],"40503641","tpoacher",[53,33,34,130,54,31],"project\u002Fneutral\u002Fidea",[49,32,34,130,50,31],[70,32,33,133,71,31],"project\u002Fcritical\u002Fidea",[135,32,34,136,137,31],"40501791","project\u002Fmixed\u002Fidea","Hirrolot",[85,32,31,139,86,31],"other\u002Fneutral\u002Fidea",[109,34,31,141,110,31],"other\u002Fneutral\u002Fnone",[143,34,31,141,144,31],"40502137","jjdisn",[146,34,31,124,147,31],"40502310","TwentyPosts",[149,34,31,150,151,31],"40503681","other\u002Fneutral\u002Fperformance","OskarS",[153,34,31,150,154,31],"40505289","bidune",[156,34,31,157,158,31],"40503274","other\u002Fneutral\u002Fdesign","rwbt",[77,160,33,161,78,31],4,"project\u002Fcritical\u002Fexecution",[163,116,31,141,164,31],"40500402","natsucks",[166,116,31,141,167,31],"40500636","Q6T46nT668w6i3m",[169,116,31,141,170,31],"40500663","eknkc",[172,116,31,141,173,31],"40500724","bluetomcat",[175,116,31,141,176,31],"40500850","jerf",[178,116,31,141,179,31],"40502138","kstrauser",[181,116,31,141,182,31],"40501265","ajross",[184,116,31,124,185,31],"40501495","MisterTea",[187,116,31,124,188,31],"40501968","throwaway17_17",[190,116,31,124,191,31],"40502063","carbonatom",[193,116,31,141,194,31],"40501416","hedora",[196,116,31,141,197,31],"40501552","wolfspaw",[199,116,31,124,200,31],"40502162","KerrAvon",[202,116,31,141,203,31],"40502366","Joker_vD",[205,116,31,124,206,31],"40502374","short_sells_poo",[208,116,31,124,209,31],"40502809","b3orn",[211,116,31,124,164,31],"40503058",[213,116,31,141,158,31],"40503325",[215,116,31,141,216,31],"40505003","samatman",[218,116,31,124,158,31],"40505154",[220,116,31,141,221,31],"40501583","PaulDavisThe1st",[223,116,31,141,224,31],"40501666","vineyardlabs",[226,116,31,141,227,31],"40503655","truckerbill",[229,116,31,141,230,31],"40503848","ironman1478",[232,116,31,141,233,31],"40503887","hgs3",[235,35,31,141,236,31],"40498030","3dworldrunner",[238,35,31,139,203,31],"40500435",[240,35,31,139,241,31],"40500689","frutiger",[],[244,249,254,259,264,269],{"id":245,"name":246,"points":247,"category":248},"40456236","Dataherald",464,"data",{"id":250,"name":251,"points":252,"category":253},"40501021","Grooved",452,"hardware",{"id":255,"name":256,"points":257,"category":258},"40455478","PaperTalk",319,"productivity",{"id":260,"name":261,"points":262,"category":263},"40502956","Openkoda",318,"web_saas",{"id":265,"name":266,"points":267,"category":268},"40469592","Spot",309,"dev_tools",{"id":270,"name":271,"points":272,"category":273},"40456959","Porter Cloud",258,"infrastructure",false,"v2",{"id":277,"name":5,"line":6,"ai":274,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":278,"top":18,"kw":279,"maker":11,"domain":10,"tier":19,"attempts":31,"strip":280,"url":9,"mix":281,"praise":61,"objection":67,"sub":21},40478175,-0.31,[24,25,26,27],"1003313000000100000000000000000000000000",[31,32,33,34],1794036655306]