The Monoid Class¶
hymn.types.monoid - base monoid class
-
class
hymn.types.monoid.Monoid¶ Bases:
objectthe monoid class
types with an associative binary operation that has an identity
-
append(other)¶ an associative operation for monoid
-
classmethod
concat(seq)¶ fold a list using the monoid
-
-
hymn.types.monoid.append(*monoids)¶ the associative operation of monoid
Examples¶
append() adds up the values, while handling empty
gracefully, <> is an alias of append()
=> (import [hymn.types.maybe [Just Nothing]])
=> (import [hymn.types.monoid [<> append]])
=> (append (Just "Cuddles ") Nothing (Just "the ") Nothing (Just "Hacker"))
Just('Cuddles the Hacker')
=> (<> (Just "Cuddles ") Nothing (Just "the ") Nothing (Just "Hacker"))
Just('Cuddles the Hacker')