3 ms·
I actually like the first one best, and would prefer a case-lambda even more. Once it becomes available we can write foo x y = x >>= \case Leaf -> ..
by eru 15y ago
I actually like the first one best, and would prefer a case-lambda even more. Once it becomes available we can write
foo x y = x >>= \case
Leaf -> ..
Branch l r -> ..
modulo whatever syntax gets chosen. That would save an unnecessary temporary variable. (See https://groups.google.com/group/haskell-cafe/browse_thread/thread/6f80e46ae3695979/7cb2c5d36c36c7f4 https://groups.google.com/group/haskell-cafe/browse_thread/t...)
Temporary variables clutter up the name space. While reading code you have to look for shadowing, or whether that variable is ever used again.
- hollerith 15y agoAgree about case lambda (and consequently that I could have chosen a better example).