Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6899843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:28:21+00:00 2026-05-27T07:28:21+00:00

I’ve reading the The Typeclassopedia by Brent Yorgey in Monad.Reader#13 ,and found that the

  • 0

I’ve reading the “The Typeclassopedia” by Brent Yorgey in Monad.Reader#13 ,and found that “the Functor hierachy” is interdependent of “the Category hierachy” as the Figure.1 shown.

Figure.1

And according to the author, ArrowApply == Monad, especially that the previous one is just a type class instance that can be used when

“we would like to be able to compute an arrow from intermediate results, and use this computed arrow to continue the computation. This is the power given to us by ArrowApply.”

But how can we put these things together ? I mean that there are some flow control functions both in Monad and Arrow ( like if and else vs. ArrowChoice, or forM vs. ArrowLoop), and some features seem like “missing” in Monad ( (***),(|||) or first). All these are seem like that we need to make a choice between using Monad or Arrow system to construct our side effect computation flow, and will lose some features in another system.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:28:22+00:00Added an answer on May 27, 2026 at 7:28 am

    The answer lies in the following (all of this is from the Control.Arrow docs)

    newtype ArrowApply a => ArrowMonad a b = ArrowMonad (a () b)
    instance Monad ArrowApply a => Monad (ArrowMonad a)
    

    The ArrowMonad newtype is the vehicle with which we define the Monad instance for ArrowApply arrows. We could have used

    instance Monad ArrowApply a => Monad (a ())
    

    but this would’ve caused problems with Haskell’s limited type class inference (It would work with the UndecideableInstances extension, I fathom).

    You can think of the Monad instance for ArrowApply arrows as translating monadic operations into equivalent arrow operations, as the source shows:

    instance ArrowApply a => Monad (ArrowMonad a) where
            return x = ArrowMonad (arr (\_ -> x))
            ArrowMonad m >>= f = ArrowMonad (m >>>
                            arr (\x -> let ArrowMonad h = f x in (h, ())) >>>
                            app)
    

    So know we know that ArrowApply is as powerful as Monad since we can implement all of the Monad operations in it. Surprisingly, the converse is also true. This is given by the Kleisli newtype as @hammar noted. Observe:

    newtype Kleisli m a b = Kleisli { runKleisli :: a -> m b }
    
    instance Monad m => Category (Kleisli m) where
            id = Kleisli return
            (Kleisli f) . (Kleisli g) = Kleisli (\b -> g b >>= f)
    
    instance Monad m => Arrow (Kleisli m) where
            arr f = Kleisli (return . f)
            first (Kleisli f) = Kleisli (\ ~(b,d) -> f b >>= \c -> return (c,d))
            second (Kleisli f) = Kleisli (\ ~(d,b) -> f b >>= \c -> return (d,c))
    
    instance Monad m => ArrowApply (Kleisli m) where
            app = Kleisli (\(Kleisli f, x) -> f x)
    
    instance Monad m => ArrowChoice (Kleisli m) where
        left f = f +++ arr id
        right f = arr id +++ f
        f +++ g = (f >>> arr Left) ||| (g >>> arr Right)
        Kleisli f ||| Kleisli g = Kleisli (either f g)
    

    The previous gives implementations for all of the usual arrow operations using monad operations. (***) is not mentioned since it has a default implementation usin first and second:

    f *** g = first f >>> second g
    

    So now we know how to implement arrow (Arrow, ArrowChoice, ArrowApply) operations using Monad operations.


    To answer your question about why we have both Monad and Arrow if they turn out to be equivalent:

    The less powerful arrows are useful when we do not need the full power of a monad, just like applicative functors can be useful. And even though ArrowApply and Monad are equivalent, an Arrow or ArrowChoice without app is something that is not representable in the Monad hierarchy. Vice versa, an Applicative is not representable in the arrow hierarchy.
    This is because ap comes “first” in the monad hierarchy and “last” in the arrow hierarchy.

    The main semantic difference between the monad and arrow worlds is that arrows capture a transformation (arr b c means we produce a c from a b), while monads capture an operation (monad a produces an a). This difference is reflected well in the Kleisli and ArrowMonad newtypes:

    newtype Kleisli m a b = Kleisli { runKleisli :: a -> m b }
    newtype ArrowApply a => ArrowMonad a b = ArrowMonad (a () b)
    

    In Kleisli we have to add the source type a, and in ArrowMonad we set it to ().


    I hope this satisfies you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.