import { Monoid , MonoidConstructor } from "../monoid" ; export default class Sum implements Monoid < Sum > { constructor ( private n ) { } static identity ( ) { return sumId ; } identity ( ) { return sumId ; } combine ( s ) { return new Sum ( this . n + s . n ) ; } static toNumber ( s ) { return s . n ; } static create ( n ) { return new Sum ( n ) ; } } const sumId = new Sum ( 0 ) ;