<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 2, 2010, at 7:08 PM, Ivan Lazar Miljenovic wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">Knowing about something /= knowing how to use it. &nbsp;I own and have read<br>RWH, but I've never had to use hsc2hs, or Applicative, etc.</span></blockquote></div><br><div>Applicative is nice. &nbsp;I had to Google for hsc2hs.&nbsp;This is what I get for learning Haskell from the Haskell 98 Report and the Gentle Intro, and by writing programs. &nbsp;I read and commented on RWH while it was in beta. &nbsp; &nbsp;But I don't even know C. &nbsp;As a kid, I got tripped up by = meaning "binds to, for now" instead of being an equivalence relation (though I didn't know <i>that</i>&nbsp;at the time). &nbsp;As an adult, I just didn't care. &nbsp;I studied Mathematics and Philosophy and learned how to write proofs in maybe 2 dozen logics and maybe 100 algebras.</div><div><br></div><div>This is a common problem in "rich" languages: There is more than one way to solve a problem, even if the algorithmic content is essentially the same. &nbsp;The only sane way I have found to deal with this is to just ignore unfamiliar combinators and focus on a function definition's mathematical content, as much as possible. &nbsp;In particular, every function is a many-to-one relation made from a "join" of types (in the lattice of types). &nbsp;Haskell's rich type theory makes this easier than Perl or Lisp, for example. &nbsp;You can often guess the right interpretation for a combinator merely by looking at its type, and mentally deriving its free theorem (or equivalently, characterizing its free function), which is easy with some practice. &nbsp;Put another way, free theorems/functions are plumbing to be ignored. &nbsp;The mathematically interesting parts of a function definition are the parts that aren't free, and have to be explicitly defined, often in terms of pairs of values.</div><div><br></div><div>This mathematical approach makes these sorts of litmus tests trivial, in the worst sense possible. &nbsp;I'm not interested in memorizing hundreds or thousands of combinators. &nbsp;That's what Google/Haddock/text books are for. &nbsp;I had to Google to remember what FizzBuzz was, and I had to try GHCi to figure out of mod was named mod or %. &nbsp;And with the right tools, I was able to solve it in under a minute. &nbsp;It took about 10 seconds to get the logic down on paper, using arrows of the Categorical variety. &nbsp;This does not make me a Haskell n00b.</div><div><br></div><div>These kinds of ideas are rather subversive in a business environment. &nbsp;In my experience, businesses want to balance this sort of flexibility with maintaining a common body of knowledge. &nbsp;This leads to those brutish patterns OO people seem to love. &nbsp;At least functional patterns are expressive and often written in terms of free functions for some type or type class.</div><div><br></div><div>I remember an incident at a previous job, where a slightly more senior employee told me that I should be using the factory pattern instead of a map to traverse a list of "logic objects". &nbsp;I gave him a little challenge. &nbsp;I told him to just write up the supporting code (i.e., just the class names, imports, interfaces. &nbsp;No implementations.) for the class hierarchy while I solved the problem my way. &nbsp;It would be a race. &nbsp;10 minutes later, I was done. &nbsp;Half an hour later, he came by my desk, looked at the logic for traversing a list of hashes and writing a functor into the solution space, and agreed I was right.</div></body></html>