Whats the name of arrows in category theory that have this type:
a -> a
"From a type(?) to another object of the same type"
Or maybe there's no particular name for them?
In other words: Is there a name for the set of all arrows that go from any type a to the same type a? Examples of arrows (functions?) of that set:
\x->x+x :: Int->Int
\x-> "hello, " ++ x :: String -> String
...
Edit
@leftaroundabout says that I'm using OO definition of object for category theory, which is wrong. Therefore, what I'm really asking is: "In category theory, in a category đť“’ what is the name for a morphism from some object O of đť“’ to O itself?"
If I'm correct in interpreting your question as "what do we call morphisms from an object to itself in category theory?", then the word you're looking for is endomorphism.
The word you're looking for, as many others have said, is "endomorphism." But in a more concrete note it's worth mentioning here the Endo
type in Data.Monoid
:
data Endo a = Endo { appEndo :: a -> a }
instance Monoid (Endo a) where
mempty = Endo id
Endo f `mappend` Endo g = Endo (f . g)
This type is sometimes useful. For example, as Brent Yorgey explains, folds are made of monoids:
import Data.Monoid
foldr :: (a -> b -> b) -> b -> [a] -> b
foldr f z xs = appEndo (mconcat (map (Endo . f) xs)) z
foldl :: (b -> a -> b) -> b -> [a] -> b
foldl f z xs = appEndo (mconcat (map (Endo . flip f) (reverse xs))) z
So, since monoids are associative, oftentimes folds can be parallelized (with a divide-and-conquer strategy) by first rewriting them in terms of Endo
, and then replacing the specific Endo b
for that fold with some more concrete type that allows for some of the work to be done at each mappend
step.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With