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.identity_m

alias of Identity

hymn.types.identity.unit

the unit of identity monad

Hy Specific API

identity-m

alias of Identity

Examples

=> (require hymn.dsl)
=> (import [hymn.types.identity [identity-m]])
=> (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.

=> (> (identity-m.unit 2) (identity-m.unit 1))
True
=> (= (identity-m.unit 42) (identity-m.unit 42))
True