我正在阅读《Scala 编程》这本书(红皮书)。
在关于 Monoids 的章节中,我了解了 Monoid 同态是什么,例如:M具有连接和length函数的 String Monoidf保留了幺半群结构,因此是同态的。
M.op(f(x), f(y)) == M.op(f(x) + f(y))
// "Lorem".length + "ipsum".length == ("Lorem" + "ipsum").length
引用这本书(凭记忆,如果我错了,请纠正我:
当这发生在两个方向上时,它被命名为 Monoid isomorphisim,这意味着对于 monoids
M, N和函数f, g,f andThen g并且g andThen f是identity函数。例如StringMonoid 和List[Char]具有连接的 Monoid 是同构的。
但是我看不到一个实际的例子,我只能认为是f函数length,但是会发生什么g?
注意:我看过这个问题:What are isomorphism and homomorphisms。