Boris Buliga

Welcome to my personal site, where I irregularly post technical notes, usually Emacs or Haskell-related. I am developer at Wix during the daytime, and developer at home before and after the daytime. When I am not writing code, I am either drinking wine or drinking tea (with these little cups). Cheese is my bread and tracking everything in Emacs is my cheese. So welcome!

(tagged 'readings)

Readings Vol. I: precondition encoding

February 1, 2020

When we write libraries for others (including ourselves) to use we often require some preconditions to be met. Sometimes we just make them implicit (in the form of folklore, passed from developer to developer during post mortem ritual). In other cases we encode the possibility of failure due to unsatisfied preconditions.

safeHead :: [a] -> Maybe a
safeHead [] = None
safehead (a:_) = Just a

Is this is the only thing we can do? Definitely no! Is it the best thing we can do? Depends on the situation.

This article is part of the readings series where I take one topic and share links to related articles and papers. This time our focus is precondition encoding.

Read more →