[Haskell-cafe] monoid homomorphism
Li-yao Xia
lysxia at gmail.com
Thu Sep 22 10:49:15 UTC 2022
Hi Co,
(This email in a gist in case the ASCII art below gets lost in
translation https://gist.github.com/Lysxia/d81abf4e35e8094df0a92ec5ff1467da)
Categorically, we prefer looking at a monoid (Z, 1, (*)) as a pair of morphisms (functions in Set) (const 1 : () -> Z) and (uncurry (*) : Z x Z -> Z).
A monoid homomorphism is_odd : Z -> B is a morphism which makes the following diagrams commute:
const 1
() ------------> Z
| |
id | | is_odd
| |
v v
() ------------> B
const True
(*)
Z x Z ---------> Z
| |
is_odd *** is_odd | | is_odd
| |
v v
B x B ---------> B
(&&)
Cheers,
Li-yao
On 2022-09-22 10:03 AM, coplot coplot wrote:
Hello every one,
I'm reading "Programming with Categories Brendan Fong Bartosz Milewski
David I. Spivak"
and here there's an example of monoid in Haskell:
/Consider the monoidsZ×�(Z,1,×)andBAND�(B,true,AND).Let
is_odd:Z→Bbe the function that sends odd numbers totrueand even numbers to
false. This is a monoid homomorphism. It preserves identities because1is
odd, and
it preserves composition because the product of any two odd numbers is
odd, but the
product of anything with an even number is even./
I'd like representing it graphically I mean the object Zx and arrows
about is_odd function,
but I do not know how can do it.
This is a valid example of monoid homomorphism and I'd like to know
the Haskell implementation and the corresponding categorically view.
Thanks
Co
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20220922/d269463b/attachment.html>
More information about the Haskell-Cafe
mailing list