trait ChainableContainer[A] {
def map(fn: A => B): ChainableContainer[B]
def flatten(nested: ChainableContainer[ChainableContainer[A]]):ChainableContainer
}
But beyond making it a little easier to guess what's going on, the underlying math isn't useful in actual programming.