points by ndriscoll 1 year ago

The example is a single-abstract-method class, i.e. a lambda function. You can define it as

  `type Logger = (String, Severity) => IO ()`

  `def empty: Logger = (_, _) => IO.unit`

  `def aboveSeverity(l: Logger)(minsev: Severity): Logger = (s, sev) => if sev >= minsev l(s, sev) else IO.unit`

Or Curried if you like. In Scala, you might put these on a companion object so that you can give Logger.empty to your tests, etc. You don't need the type to remember which type of logger you had. The only thing you care about is that you can call it.