The Identity Monad¶
hymn.types.identity - the identity monad
-
class
hymn.types.identity.
Identity
(value)¶ Bases:
hymn.types.monad.Monad
,hymn.mixins.Ord
the identity monad
-
hymn.types.identity.
unit
()¶ alias of
Identity.unit()
Examples¶
=> (import [hymn.types.identity [identity-m]])
=> (require [hymn.macros [do-monad]])
=> (do-monad [a (identity-m.unit 1) b (identity-m.unit 2)] (+ a b))
Identity(3)
Identity monad is comparable as long as what’s wrapped inside are comparable.
=> (import [hymn.types.identity [identity-m]])
=> (> (identity-m.unit 2) (identity-m.unit 1))
True
=> (= (identity-m.unit 42) (identity-m.unit 42))
True