Interview: Pursuing a Trick a Long Way Just To See Where It Goes, with Simon Peyton Jones

This interview explores the history and design philosophy of Haskell, a purely functional programming language, through an in-depth conversation with Simon Peyton Jones, one of its creators. We discuss what makes Haskell unique, the evolution of its type system including typeclasses and higher-kinded types, and how it serves as a laboratory for exploring programming language ideas.

4 Likes

So now the typeclass has to abstract not over a type, but over a type constructor. [SPJ at about 9:00]

Was it ever contemplated to use this form for declaring a constructor class?:

class Functor (f b)  where
  fmap :: (a -> b) -> (f a) -> (f b)   — i.e. standard sig


This keeps the class’s param as kind * aka Type, so introduces a restricted form of Multi-Param TC (without giving rise to full-on MPTCs that Haskellers were rightfully nervous about in the 90’s).

The advantage I see is the instances can now talk about (constrain) the content type. For example, constrain the IO Monad to at least use Serializable values.

We can achieve this these days in GHC using Type Equality Constraint:

class Functor fb  where
  fmap :: fb ~ (f b) => (a -> b) -> (f a) -> (f b)

And there’s various constrained-functor packages.

As Simon goes on to say, still we have “no lambda at the type level”.