Use Kotlin extension functions on generic classes

Kotlin includes a powerful feature called Extension Functions. The use of this feature is controversial in cases where the extension function adds domain-specific behaviour to standard or 3rd party library classes. I generally agree with the critics on this, but there is an important exception to be made when the library class is a generic…