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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:42:17+00:00 2026-05-23T19:42:17+00:00

I started with haskell yesterday and am still completely lost on the shore of

  • 0

I started with haskell yesterday and am still completely lost on the shore of this brave new world. Now I have run into the following issue:

Let’s assume I have some function that does some magic to an integer and another variable:

makeTuple :: Int -> a -> (Int, a)
makeTuple n x = (n, x)

Now I want to apply this function to all elements of a list. So far no problem, as mapping is your daily bread and butter in python (where I come from), too.

makeTupleList :: Int -> [a] -> [ (Int, a) ]
makeTupleList n x = map (makeTuple n) x

As far as I understand, the binary function makeTuple is applied partially with the integer n and hence becomes a unary function which can be mapped to each element of x. So far, all is well.

But what do I do when the makeTuple function has another signature, like:

makeTuple2 :: a -> Int -> (Int, a)
makeTuple2 x n = (n, x)

Many ways lead to Rome: the effect is the same, but the way is another. Now obviously the mapping doesn’t work anymore: The function expects an Int and gets an a.

makeTupleList2 :: Int -> [a] -> [ (Int, a) ]
makeTupleList2 n x = map (makeTuple2 n) x -- boolshit

This was to be expected. My -maybe too pythonic- workaround is using another function to pass the parameters where they should go:

makeTupleList2 :: Int -> [a] -> [ (Int, a) ]
makeTupleList2 n x = map (\x -> makeTuple2 x n) x

Question:
What is the preferred functional, haskell-style way of partially applying functions when the parially applied parameters isn’t the leftmost?

  • 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-23T19:42:17+00:00Added an answer on May 23, 2026 at 7:42 pm

    You can use flip, which swaps the first and second arguments of a function.

    makeTupleList2 n x = map (flip makeTuple2 n) x
    

    Another option is to use the backticks syntax to make an infix operator and then partially apply that using an operator section.

    maleTupleList2 n x = map (`makeTuple2` n) x
    

    Or, as you said we can use a lambda expression. Which one to use depends on context and personal taste. Use whatever you feel is most clear.


    PS: What you’re doing is called partial application. Currying is the process of transforming a function taking multiple arguments (a, b) -> c into curried form a -> b -> c so that it can be partially applied.

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

Sidebar

Related Questions

I have recently started diving into Haskell. Its quite interesting, but the definition of
I just recently started diving into Real World Haskell and the book provides some
Just started learning Haskell. I have an empty source file with this inside: pe
Started to learn haskell today for school and I run into a problem with
I'm completely new to Haskell. To grasp the basics I've started working through 'Learn
I have just started delving into the world of functional programming. A lot of
I started playing with Haskell and I use Vim. I have autoindent on in
I'm just digging a bit into Haskell and I started by trying to compute
Started using Visual Studio 2012 RC since yesterday, We have one WCF solution. Whenever
I started learning haskell yesterday and I got stuck on a problem. After a

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.