Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For those who understand networking: the Mirage TCP/IP networking stack [1] in pure OCaml is a must. It's an object of extreme beauty, and possibly the most eloquent argument for types, types inference and algebraic data types I can think of. The TCP state machine is mostly specified at type level [2], preventing numerous potential bugs in one fell swoop.

Reading this code is probably most enlightening if you have already written networking protocols.

NB: this has nothing to do with OCaml, other comparable languages with ADTs (Scala, Rust, Haskell, F#) would be similarly suitable.

[1] https://github.com/mirage/mirage-tcpip

[2] https://github.com/mirage/mirage-tcpip/blob/master/lib/tcp/s...



Only looked at link [2], but wow. That state machine is brilliant.

Don't know OCaml but am learning Rust and I see what you mean about the universality of how types make this possible.

Thanks for pointing this out.


Thank you. I haven't written networking protocols, yet. But hopefully I can still benefit from these.


Thanks!

I've been looking for something beyond basic tutorial apps to get a real feel for OCaml.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: