Free and Libre Objects

Nick Pollard

Welcome

  • Nick Pollard
  • Principal Engineer @ nstack
  • nick@nstack.com
  • @Nick_enGB

Objects

  • Really an Algebra:
    • A set of operations (functions) and laws
    • over a set (type)
  • In Haskell this could be a record of functions
  • Or more commonly a type class

Free as in Beer

  • Get one ‘for free’?

Free as in Speech

  • Without constraints, not without costs
  • An object free of relations
  • The most generic instance of an algebra
  • Does exactly what the definition says and no more

Free Monoids

We need to satisfy the Monoid class, and be able to lift our underlying type

Many Free Monoids?

  • ‘The Free Monoid’ or ‘A Free Monoid’?
  • Actually both
  • Multiple encodings can exist
  • Isomorphic by definition

Practical Uses

  • Define an expression in the language of the algebra
  • Can interpret it in many ways
  • Using Free Applicatives we can do static analysis
    • Not possible with Free Monads, as structure not statically known

A Simple Expression Language

  • Execute
  • Analyse

Questions?

  • nick@nstack.com
  • @Nick_enGB