On Thu, 20 Dec 2012, Gershom Bazerman <gersh...@gmail.com> wrote:
On 12/20/12 10:05 PM, Jay Sulzberger wrote:
What does the code for going backwards looks like? That is,
suppose we have an instance of Category with only one object.
What is the Haskell code for the function which takes the
category instance and produces a monoid thing, like your integers
with 1 and usual integer multiplication? Could we use a
"constraint" at the level of types, or at some other level, to
write the code? Here by "constraint" I mean something like a
declaration that is a piece of Haskell source code, and not
something the human author of the code uses to write the code.
instance C.Category k => Monoid (k a a) where
mempty = C.id
mappend = (C..)
The above gives witness to the fact that, if I'm using the language
correctly, if we choose any object (our "a") in any given category, this
induces a monoid with the identity morphism as unit and composition of
endomorphisms as append.
The standard libraries in fact provide this instance for the function arrow
category (under a newtype wrapper):
newtype Endo a = Endo { appEndo :: a -> a }
instance Monoid (Endo a) where
mempty = Endo id
Endo f `mappend` Endo g = Endo (f . g)
--Gershom
Thanks, Gershom!
I think I see. The Haskell code picks out the
"isotropy/holonomy" monoid at the object a of any Haskell
Category instance.
actual old fashioned types remark: To get the holonomy
semigroup^Wmonoid, interpolate a functor.
I am glad that Haskell today smoothly handles this.
ad paper on polymorphisms: I hope to post a rant against the
misleading distinction between "parametric polymorphism" and "ad
hoc polymorphism". Lisp will be used as a bludgeon in the only
argument in the rant. The Four Things Which Must Be
Distinguished will perform the opening number.
oo--JS.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe