Ben oversees the development and operation of a wide variety of software systems in the Residential line of business. Ben has 18 years commercial software development experience in Australia and the UK including time with GSJBW, Sensis and Melbourne IT, and has coordinated the Melbourne Scala Users Group for the past 7 years. His passion is finding better ways to do programming and applying them to practical situations; recent examples are taking Scala into the browser with Scala.js, and continuing to improve the reliability of software through better use of static typing.
YOW! Lambda Jam 2013 Brisbane
Programming with Type Classes in Scala
WORKSHOP – VIEW SLIDES
This workshop will introduce typeclass programming techniques in Scala. We will begin with motivation behind typeclases, and the history of how they came to Scala. I will present type-classes and object orientation as two alternative mechanisms motivated by the same goal, being abstraction over data, and consider the trade-offs of each approach. We will look several examples of typeclass usage, including equality, ordering, numbers and JSON serialization. The operation and usage of Scala’s ‘implicit’ keyword will be explained, and the interactions of typeclasses with sub-typing and variance will be outlined. I will briefly touch on higher-kinded types and multi-parameter typeclasses. Familiarity with Scala is assumed but not prior experience with typeclasses.
Slides and code are available here: https://github.com/benhutchison/ProgrammingWithTypeClasses
Typeclass-driven Polymorphism in Scala
A completely re-designed collections API was released for Scala 2.8 in 2010. Among it’s innovative features were highly polymorphic methods (e.g. map) whose static types varied in a rich, context-dependent fashion. The technique employed was based upon multi-parameter typeclasses, which interact with the type-inference process. The initial reception was uncertain: what Odersky described as “a new kind of polymorphism”, some Scala users – disturbed by the increased API complexity – described instead as “the longest suicide note in history”. It took another year for Miles Sabin to note the technique had precedent in Haskell, where it was called Functional Dependencies. This talk will explain the technique, and show how it can be useful in applications beyond the Collections API.
Slides and code are available here: https://github.com/benhutchison/TypeclassDrivenPolymorphism