Blog
Object-Oriented Haskell - Part 1: Objects, Fields, Methods, Interfaces
(Oct 17, 2017)Object-oriented Haskell, you say? But isn’t Haskell a functional programming language? Aren’t functional programming and object-oriented programming mutually exclusive?Well; no, they are not, and I will show you how it is possible to write object-oriented code in Haskell using only a minimal set of utility code, and without giving up much of Haskell’s pure functional benefits.What Is OOP, Anywa...
Object-Oriented Haskell - Part 3: Generalized Mutability
(Nov 21, 2017)In Part 1, we have seen how an interface-based OOP model can be implemented in idiomatic Haskell, and we then extended this model to allow for mutable objects by using IORef in Part 2. In this part, we will extend the model further to decouple the mutable-variable implementation from mutability in the objects themselves.Generalizing Mutable VariablesLet’s look at the bare minimum interface for ...
Object-Oriented Haskell - Part 2: Mutability And Multiple Interfaces
(Nov 1, 2017)In Part 1, we have seen how an interface-based OOP model can be implemented in idiomatic Haskell; we defined interfaces, a typeclass to enable a typesafe cast-to-interface function, and an accessor function / operator to conveniently access an object member through an interface. We will now look at how we can implement mutable objects in idiomatic Haskell.Mutability in HaskellHaskell is a pure ...