[Haskell-cafe] Seeking help to generalize this ..

Li-yao Xia lysxia at gmail.com
Sat Feb 1 18:58:41 UTC 2020


Hi Debasish,

You can also write


    (f1 >=> f2 >=> f3) acc

or

    f1 acc >>= f2 >>= f3

or

    foldr (>=>) [f1, f2, f3] pure acc


Regards,
Li-yao

On 2/1/20 1:54 PM, Debasish Ghosh wrote:
> Hi -
> 
> How can I generalize the following pattern to an arbitrary list of 
> functions ?
> 
> compose :: (Monad m) => (Foo -> m Foo) -> (Foo -> m Foo) -> (Foo -> m 
> Foo) -> Foo -> m Foo
> compose f1 f2 f3 acc = do
>    a <- f1 acc
>    b <- f2 a
>    f3 b
> 
> Any help please ..
> regards.
> 
> -- 
> Debasish Ghosh
> http://manning.com/ghosh2
> http://manning.com/ghosh
> 
> Twttr: @debasishg
> Blog: http://debasishg.blogspot.com
> Code: http://github.com/debasishg
> 
> _______________________________________________
> 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.
> 


More information about the Haskell-Cafe mailing list