<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Co,</p>
<p>(This email in a gist in case the ASCII art below gets lost in
translation
<a class="moz-txt-link-freetext" href="https://gist.github.com/Lysxia/d81abf4e35e8094df0a92ec5ff1467da">https://gist.github.com/Lysxia/d81abf4e35e8094df0a92ec5ff1467da</a>)<br>
</p>
<pre>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
(&&)</pre>
<p>Cheers,<br>
Li-yao<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 2022-09-22 10:03 AM, coplot coplot
wrote:<br>
</div>
<div class="replaced-blockquote"
cite="mid:trinity-5e41d251-42f6-413c-94d6-849a4145a0b9-1663837438339@3c-app-mailcom-lxa02"
type="cite">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div style="font-family: Verdana;font-size: 12.0px;">
<div><span style="font-family:Courier New,Courier,monospace;"><span
style="font-size:12px;">Hello every one,<br>
I'm reading </span>"Programming with Categories Brendan
Fong Bartosz Milewski David I. Spivak"<br>
<span style="font-size:12px;">and here there's an example of
monoid in Haskell:<br>
<br>
<em><span dir="ltr" role="presentation" style="left:
270.895px; top: 756.961px; transform: scaleX(0.9146);">Consider
the monoids</span><span dir="ltr" role="presentation"
style="left: 453.022px; top: 756.961px;"> </span><span
dir="ltr" role="presentation" style="left: 459.333px;
top: 756.222px;">Z</span><span dir="ltr"
role="presentation" style="left: 471.023px; top:
763.443px;">×</span><span dir="ltr"
role="presentation" style="left: 479.91px; top:
763.443px;"> </span><span dir="ltr"
role="presentation" style="left: 488.25px; top:
756.961px;">�</span><span dir="ltr"
role="presentation" style="left: 500.414px; top:
756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 507.923px; top:
756.961px;">(</span><span dir="ltr"
role="presentation" style="left: 514.213px; top:
756.222px;">Z</span><span dir="ltr"
role="presentation" style="left: 526.45px; top:
756.961px;">,</span><span dir="ltr"
role="presentation" style="left: 530.996px; top:
756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 534.39px; top:
756.961px;">1</span><span dir="ltr"
role="presentation" style="left: 544.027px; top:
756.961px;">,</span><span dir="ltr"
role="presentation" style="left: 548.572px; top:
756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 551.965px; top:
756.961px; transform: scaleX(0.826324);">×)</span><span
dir="ltr" role="presentation" style="left: 570.42px;
top: 756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 576.735px; top:
756.961px; transform: scaleX(0.899178);">and</span><span
dir="ltr" role="presentation" style="left: 607.517px;
top: 756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 613.833px; top:
756.222px;">B</span><span dir="ltr"
role="presentation" style="left: 626.597px; top:
763.443px; transform: scaleX(1.08221);">AND</span><span
dir="ltr" role="presentation" style="left: 658.251px;
top: 763.443px;"> </span><span dir="ltr"
role="presentation" style="left: 666.592px; top:
756.961px;">�</span><span dir="ltr"
role="presentation" style="left: 678.755px; top:
756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 686.265px; top:
756.961px;">(</span><span dir="ltr"
role="presentation" style="left: 692.555px; top:
756.222px;">B</span><span dir="ltr"
role="presentation" style="left: 705.865px; top:
756.961px;">,</span><span dir="ltr"
role="presentation" style="left: 710.41px; top:
756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 713.803px; top:
756.961px; transform: scaleX(0.871732);">true</span><span
dir="ltr" role="presentation" style="left: 752.53px;
top: 756.961px;">,</span><span dir="ltr"
role="presentation" style="left: 757.075px; top:
756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 760.47px; top:
756.961px; transform: scaleX(1.08183);">AND</span><span
dir="ltr" role="presentation" style="left: 803.797px;
top: 756.961px;">)</span><span dir="ltr"
role="presentation" style="left: 810.088px; top:
756.961px;">.</span><span dir="ltr"
role="presentation" style="left: 814.634px; top:
756.961px;"> </span><span dir="ltr"
role="presentation" style="left: 826.507px; top:
756.961px; transform: scaleX(0.915124);">Let</span><br
role="presentation">
<span dir="ltr" role="presentation" style="left:
164.832px; top: 782.929px; transform:
scaleX(0.871732);">is</span><span dir="ltr"
role="presentation" style="left: 183.923px; top:
782.929px;">_</span><span dir="ltr"
role="presentation" style="left: 193.013px; top:
782.929px; transform: scaleX(0.871732);">odd</span><span
dir="ltr" role="presentation" style="left: 221.65px;
top: 782.929px;"> </span><span dir="ltr"
role="presentation" style="left: 223.67px; top:
782.929px;">:</span><span dir="ltr"
role="presentation" style="left: 228.215px; top:
782.929px;"> </span><span dir="ltr"
role="presentation" style="left: 234.33px; top:
782.19px;">Z</span><span dir="ltr" role="presentation"
style="left: 246.028px; top: 782.19px;"> </span><span
dir="ltr" role="presentation" style="left: 251.345px;
top: 782.929px;">→</span><span dir="ltr"
role="presentation" style="left: 270.927px; top:
782.929px;"> </span><span dir="ltr"
role="presentation" style="left: 276.248px; top:
782.19px;">B</span><span dir="ltr" role="presentation"
style="left: 289.018px; top: 782.19px;"> </span><span
dir="ltr" role="presentation" style="left: 293.755px;
top: 782.929px; transform: scaleX(0.874525);">be the
function that sends odd numbers to</span><span
dir="ltr" role="presentation" style="left: 635.301px;
top: 782.929px;"> </span><span dir="ltr"
role="presentation" style="left: 640.033px; top:
782.929px; transform: scaleX(0.871732);">true</span><span
dir="ltr" role="presentation" style="left: 678.215px;
top: 782.929px;"> </span><span dir="ltr"
role="presentation" style="left: 682.957px; top:
782.929px; transform: scaleX(0.868159);">and even
numbers to</span><br role="presentation">
<span dir="ltr" role="presentation" style="left:
164.832px; top: 808.899px; transform:
scaleX(0.871732);">false</span><span dir="ltr"
role="presentation" style="left: 212.558px; top:
808.899px; transform: scaleX(0.88598);">. This is a
monoid homomorphism. It preserves identities because</span><span
dir="ltr" role="presentation" style="left: 744.25px;
top: 808.899px;"> </span><span dir="ltr"
role="presentation" style="left: 748.855px; top:
808.899px;">1</span><span dir="ltr"
role="presentation" style="left: 757.946px; top:
808.899px;"> </span><span dir="ltr"
role="presentation" style="left: 762.552px; top:
808.899px; transform: scaleX(0.893963);">is odd, and</span><br
role="presentation">
<span dir="ltr" role="presentation" style="left:
164.832px; top: 834.867px; transform:
scaleX(0.878098);">it preserves composition because
the product of any two odd numbers is odd, but the</span><br
role="presentation">
<span dir="ltr" role="presentation" style="left:
164.832px; top: 860.837px; transform:
scaleX(0.87965);">product of anything with an even
number is even.</span></em></span><br>
<br>
<br>
I'd like representing it graphically I mean the object Zx
and arrows about is_odd function,<br>
but I do not know how can do it.</span></div>
<div><br>
<span style="font-family:Courier New,Courier,monospace;">This
is a valid example of monoid homomorphism and I'd like to
know<br>
the Haskell implementation and the corresponding
categorically view.<br>
<br>
Thanks<br>
Co</span></div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
</div>
</body>
</html>