Zohaib Rauf
zohaib.me · Personal blog · on HN since 2014
Zohaib Rauf writes programming tutorials, mostly on Elixir and Phoenix, plus some posts on LLM fine-tuning and AI-assisted coding.
What HN saysHN commenters point to his posts on Elixir monads and binary pattern matching as practical examples of those ideas in Elixir.
16HN people shared it
3linked it in comments
49stories submitted
737story points
4 months agolast shared
2014people per year2026
Most-shared posts
- 1Binary pattern matching in Elixir6 people · 106 points · first shared 2015 · 17 comments on HN
- 2Railway Oriented Programming in Elixir (2015)3 people · 30 points · first shared 2015 · 1 comments on HN
- 3Using LLMs and Cursor to finish side projects2 people · 171 points · first shared 2025 · 60 comments on HN
- 4Monads in Elixir2 people · 40 points · first shared 2015 · 8 comments on HN
- 5A beginners guide to fine tuning LLM using LoRA2 people · 23 points · first shared 2024 · 2 comments on HN
- 6Using ElasticSearch in Elixir2 people · 7 points · first shared 2015 · discussion on HN
- 7Spacemacs and Alchemist to make Elixir of immortality2 people · 6 points · first shared 2015 · discussion on HN
- 8Guts of Phoenix websocket channels2 people · 4 points · first shared 2015 · discussion on HN
- 9WebRTC file sharing broker using Elixir Phoenix1 people · 110 points · first shared 2015 · 23 comments on HN
- 10Upgradeable smart contracts in Ethereum1 people · 98 points · first shared 2018 · 40 comments on HN
- 11Blinking LED Using Elixir Embedded Image on Raspberry Pi1 people · 45 points · first shared 2015 · 16 comments on HN
- 12Elixir Cowboy with IIS 81 people · 28 points · first shared 2015 · 8 comments on HN
- 13Securing MongoDB Using Let's Encrypt Certificate1 people · 16 points · first shared 2018 · 13 comments on HN
- 14Leverage union types in Typescript to avoid invalid states1 people · 6 points · first shared 2017 · discussion on HN
- 15Create messenger bots using Elixir and Microsoft bot framework1 people · 5 points · first shared 2016 · discussion on HN
What HN people wrote when they linked it
brianberns · 2018-05-15
The Option/Maybe monad is very common in FP languages. I don't know if it's native in Elixir, but apparently it's pretty easy to implement: http://www.zohaib.me/monads-in-elixir-2/#maybe
There are lots of ways to conceptualize monads. I think "functors that flatten" is accurate, but is just one way.
derefr · 2023-01-18
An idiomatic Erlang/Elixir implementation of validation for a binary format would also give you decoding for free — see e.g. https://zohaib.me/binary-pattern-matching-in-elixir/. So I guess it's the encoding part that's unique to how Prolog works.
Which makes sense; my understanding is that in Prolog, insofar as a function encodingOf(A, B) is defined by using A and B on either side of a bind expression to equate B as the encoding of A, if encodingOf(A, knownEnc) would act as a parser for knownEnc, then encodingOf(knownDec, B) would act as an encoder for knownDec — essentially swapping the question "what would this parse to" given an encoded binary, for "what would parse to this" given a decoded term.
Erlang can't do exactly that — a given variable's "bound-ness" is determined during compilation, and head-clause variables can't be indeterminately bound — but if it could, then you would indeed get an encoder for the same format "for free", since binary-pattern matching in Erlang becomes a binary-building expression depending on whether the variables in the expression are bound or unbound.
(Now I'm curious how hard it would be to add indeterminately-bound compile-time function polymorphism to Erlang — i.e. generating bytecode for the powerset of bound-ness-es of the variables in the head clause, only where at least one generates valid bytecode, probably name-mangled with a bitfield suffix of said bound-ness-es; and then being able to bind function parameters from such…
lkuty · 2021-10-21
I would complement it with:
- Scott Wlaschin's Railway Oriented Programming (ROP): https://fsharpforfunandprofit.com/rop/ and https://fsharpforfunandprofit.com/posts/recipe-part2/
- Scott Wlaschin's The "Map and Bind and Apply, Oh my!" series at https://fsharpforfunandprofit.com/series/map-and-bind-and-apply-oh-my.… and its concept of an "elevated world".
- And for Elixir Programmers, Zohaib Rauf's "Railway Oriented Programming in Elixir" at https://zohaib.me/railway-programming-pattern-in-elixir/ based on Scott Wlaschin stuff.
- https://wiki.haskell.org/All_About_Monads. The introductory part (7 first pages of the pdf).
- Brian Beckman: Don't fear the Monad
https://www.youtube.com/watch?v=ZhuHCtR3xq8
- Philip Wadler's "Monads for Functional Programming" at http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf
- HN comment: https://news.ycombinator.com/item?id=16446139
ROP is a good way to introduce the Either monad without ever talking about monads, functors and co. Moreover it is highly useful.