I finally ended up defining a combinator 

flattenAndCompose :: (Category cat) => [cat a a] -> cat a a
flattenAndCompose = foldr (>>>) id 


that can be used both for function composition and Kleislis since both (->) and Kleisli are instances of Category. I will take a look at Endo - thanks for the pointer ..

regards.



On Fri, Feb 7, 2020 at 11:26 PM Matthew Farkas-Dyck <strake888@gmail.com> wrote:
On 2/1/20, Jack Kelly <jack@jackkelly.name> wrote:
> In Data.Monoid there is the 'Endo' newtype, which wraps functions of
> type 'a -> a'. Is there an 'EndoM' variant, or is that something that's
> usually created by putting other pieces together? Below is a sketch of
> what I mean:
>
> -- Maybe this is known by another name?
> newtype EndoM f a = EndoM { appEndoM :: a -> f a }

I define a general `Endo` type in the category package, here:
http://hackage.haskell.org/package/category-0.2.5.0/docs/Data-Morphism-Endo.html

Thus one can use `Endo (Kleisli m)`.
_______________________________________________
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.


--
Debasish Ghosh
http://manning.com/ghosh2
http://manning.com/ghosh

Twttr: @debasishg
Blog: http://debasishg.blogspot.com
Code: http://github.com/debasishg