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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:12:52+00:00 2026-06-14T12:12:52+00:00

import Control.Applicative main = print $ fmap (*2) (1,2) produces (1,4) . I would

  • 0
import Control.Applicative

main = print $ fmap (*2) (1,2)

produces (1,4). I would expect it it to produce (2,4) but instead the function is applied only to the second element of the tuple.

Update I’ve basically figured this out almost straight away. I’ll post my own answer in a minute..

  • 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-06-14T12:12:54+00:00Added an answer on June 14, 2026 at 12:12 pm

    The Functor instance is actually from the GHC.Base module which is imported by Control.Applicative.

    Trying to write the instance I want, I can see that it won’t work, given the definition of tuples; the instance requires just one type parameter, while the 2-tuple has two.

    A valid Functor instance would at least have to be on tuples, (a,a) that have the same type for each element, but you cannot do anything sneaky, like define the instance on:

     type T2 a = (a,a)
    

    because instance types aren’t permitted to be synonyms.

    The above restricted 2-tuple synonym is logically the same as the type:

    data T2 a = T2 a a
    

    which can have a Functor instance:

    instance Functor T2 where
        fmap f (T2 x y) = T2 (f x) (f y)
    

    As Gabriel remarked in the comments, this can be useful for branching structures or concurrency.

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

Sidebar

Related Questions

import MySQLdb import sys from libdesklets.controls import Control from IDBConnection import IDBConnection class DBConnection(Control,
Looking for the correct way and control to import and export of out of
I'm attempting to import a clearcase project into rtc source control and I'm following
import org.joda.time.LocalDate; public class Test { public static void main(String[] args) { long time=System.currentTimeMillis();
import java.util.Scanner; public class CourseSplitter { public static void main(String args[]){ Scanner keyboard =
I am trying to control the selectedIndex property of a ViewStack on the main
Bottle.py ships with an import to handle throwing HTTPErrors and route to a function.
package { import mx.controls.LinkButton; import flash.text.TextLineMetrics; public class multiLineLinkButton extends LinkButton { override protected
import java.awt.*; import javax.swing.*; import javax.swing.GroupLayout; /** * @author Ene Ion */ public class
import httplib2 from urllib import urlencode h = httplib2.Http() h.add_credentials('zackster@gmail.com', 'PassWord') data = dict(key=ThisIsMyApiKeyICopiedAndPastedIt)

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.