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 898373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:01:56+00:00 2026-05-15T15:01:56+00:00

I’ve been trying to get a grip on arrows since they’re the basis of

  • 0

I’ve been trying to get a grip on arrows since they’re the basis of most FRP implementations. I think I understand the basic idea – they’re related to monads but store static information at each bind operator so you can walk through a chain of arrows and look at the static information without having to evaluate the whole arrow.

But I get lost at the point where we start discussing first, second, and swap. What do 2-tuples have to do with arrows? Tutorials present the tuple stuff as if it were an obvious next step, but I’m not really seeing the connection.

For that matter, what does the arrow syntax mean intuitively?

  • 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-15T15:01:56+00:00Added an answer on May 15, 2026 at 3:01 pm

    Please take a look in http://www.cs.yale.edu/homes/hudak/CS429F04/AFPLectureNotes.pdf, which explains how Arrows work in FRP.

    2-tuples are used in defining Arrows because it’s needed to represent an arrowized function taking 2 arguments.

    In FRP, constants and variables are often represented as arrows which ignores its “input”, e.g.

    twelve, eleven :: Arrow f => f p Int
    twelve = arr (const 12)
    eleven = arr (const 11)
    

    Function applications are then turned into compositions (>>>):

    # (6-) 12
    
    arr (6-) <<< twelve
    

    Now how do we turn a 2-argument function into an arrow? For instance

    (+) :: Num a => a -> a -> a
    

    due to currying we may treat this as a function returning a function. So

    arr (+) :: (Arrow f, Num a) => f a (a -> a)
    

    now let’s apply it to a constant

    arr (+)             -- # f     a (a -> a)
      <<< twelve        -- # f b Int
                          :: f b     (Int -> Int)
    
    +----------+      +-----+      +--------------+
    | const 12 |----> | (+) |  ==  | const (+ 12) |
    +----------+      +-----+      +--------------+
    

    hey wait, it doesn’t work. The result is still an arrow that returns a function, but we expect something akin to f Int Int. We notice that currying fails in Arrow because only composition is allowed. Therefore we must uncurry the function first

    uncurry :: (a -> b -> c) -> ((a, b) -> c)
    
    uncurry (+) :: Num a => (a, a) -> a
    

    Then we have the arrow

    (arr.uncurry) (+) :: (Num a, Arrow f) => f (a, a) a
    

    The 2-tuple arises because of this. Then the bunch functions like &&& are needed to deal with these 2-tuples.

    (&&&) :: f a b -> f a d -> f a (b, d)
    

    then the addition can be correctly performed.

    (arr.uncurry) (+)        -- # f   (a,    a) a
      <<<     twelve         -- # f b  Int
          &&& eleven         -- # f b      Int
                               :: f b           a
    
    +--------+
    |const 12|-----.
    +--------+     |       +-----+      +----------+
                  &&&====> | (+) |  ==  | const 23 |
    +--------+     |       +-----+      +----------+
    |const 11|-----'
    +--------+
    

    (Now, why don’t we need things like &&&& for 3-tuples for functions having 3 arguments? Because a ((a,b),c) can be used instead.)


    Edit: From John Hughes’s original paper Generalising Monads to Arrows, it states the reason as

    4.1 Arrows and Pairs

    However, even though in case of monads the operators return and >>= are all we need to begin writing useful code, for arrows the analogous operators arr and >>> are not sufficient. Even the simple monadic addition function that we saw earlier

       add :: Monad m => m Int -> m Int -> m Int
       add x y = x >>= \u -> (y >>= \v -> return (u + v))
    

    cannot yet be expressed in an arrow form. Making dependence on an input explicit, we see that an analogous definition should take the form

       add :: Arrow a => a b Int -> a b Int -> a b Int
       add f g = ...
    

    where we must combine f and g in sequence. The only sequencing operator available is >>>, but f and g do not have the right types to be composed. Indeed, the add function needs to save the input of type b across the computation of f, so as to be able to supply the same input to g. Likewise the result of f must be saved across the computation of g, so that the two results can eventually be added together and returned. The arrow combinators so far introduced give us no way to save a value across another computation, and so we have no alternative but to introduce another combinator.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.