Proposal: rather than retrieve generics based on values, we could have the interface provide functions for you, whose values change based on arguments.. Typeclasses are instances of a class Typeclass, which provides an extend method, whereby new instances can be appended. When a typeclass' generic receives a value, it looks for an implementation against the defaults and its extensions, , baulking if it can't find one compatible..
With this, out concat example could be rewritten:
function mconcat (xs) {
return Foldable.foldr(xs, Monoid.plus, Monoid.zero);
};
Proposal: rather than retrieve generics based on values, we could have the interface provide functions for you, whose values change based on arguments.. Typeclasses are instances of a class
Typeclass, which provides anextendmethod, whereby new instances can be appended. When a typeclass' generic receives a value, it looks for an implementation against the defaults and its extensions, , baulking if it can't find one compatible..With this, out concat example could be rewritten: