I grow under the sun. 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.
P.S. d12frosted means dice with 12 sides from the Chessex™ frosted series. I used to play. Just a little bit.
They say functional programming has many essences and the composition is one of
them. Thanks to the wonderful dot operator, we know how to compose functions
a -> b and
b -> c to get a function
a -> c. But in some cases
functions are not that simple and it becomes tricky to compose them nicely.
valid :: a -> Bool = \a -> check1 a && (check2 a || check3 a) valid where check1 = undefined :: a -> Bool = undefined :: a -> Bool check2 = undefined :: a -> Bool check3
It would be lovely to express it in a more declarative way by abstracting away function application and result combination.
valid :: a -> Bool = check1 .&& (check2 .|| check3) valid (.&&) :: (a -> Bool) -> (a -> Bool) -> a -> Bool (.||) :: (a -> Bool) -> (a -> Bool) -> a -> Bool
Apart from implementing combinators for predicate composition, we want to avoid any runtime penalty from using abstractions. In this article we are going to implement the following functions and investigate how far we can go with abstractions until performance degrades. Or maybe it won’t degrade. Who knows?