The personal website of Daniel Brice.

Made with Jekyll and hosted on GitHub Pages.

I’ll be using this space to muse about Math and coding and games, mostly.

• ## Exception Handling with Explicit IO

In a previous post, we added exception handling to a hypothetical API server written in Scala. Since Scala implicitly allows arbitrary I/O anywhere, modeling exception handling by adding a layer of indirection using Either values was essentially free. I wanted to try implementing the same logic in Haskell, which would force us to deal with intermingling exception handling intermingled with explicit I/O, creating two layers of abstraction that we’ll have to juggle.

more...
• ## Three Models of Exception Handling

A hotshot teammate just pulled a miracle. Over the weekend, they built the API our customers have been promised for the past year, averting an existential crisis for the company. One problem: Only the happy path returns a response; all exceptional circumstances simply crash the computer. So, it’s up to us to productionalize the prototype by adding appropriate error handling, and we won’t sacrifice compile-time safety and re-usability along the way.

more...
• ## Scala Try is Broken

Scala’s Try class is broken. Not “broken” in the sense that it doesn’t fulfill its purpose: its purpose is to sandbox Throwables in an algebraic sum construct and provide a monadic interface over the sandbox. It does that just fine. Try is broken in the sense that one of its methods, _.toOption can return malformed Option values, violating our trust in the semantics of the Option class and leading to potential instability down the call stack.

more...
• ## Automatic Differentiation Revisited

Branium and the Santa Monica Haskell Users Group were kind enough to give me a chance to present about automatic differentiation for an evening, a topic we’ve visited before. This gave me a chance to improve my existing implementation and even add symbolic differentiation capabilities.

more...
• ## Why does trig-sub even exist?

I was writing an exam for my students, and I wanted to give them a trig sub integral that wasn’t too difficult (there’s this infinitesimal sweet spot between ridiculously too difficult and utterly trivial). I noticed something about virtually every single trig sub integral that I imagined or ran into – almost all of them could be solved without any trig.

Case in point: consider $$\int \frac{x^3}{\sqrt{x^2 + 1}} \, dx$$

more...