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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:12:54+00:00 2026-05-23T22:12:54+00:00

When playing around with Pointfree I was presented with a piece of code that

  • 0

When playing around with Pointfree I was presented with a piece of code that I can’t seem to understand.

:pl map (\x -> x * x) [1..10]
-- map (join (*)) [1..10]

My main problem is that I don’t get how join works here. I understand that it ‘removes’ one layer of a monadic wrapping (m (m a) to m a). I figure it boils down to something like [1..10] >>= (\x -> [x * x]), but I don’t really get how the “extra layer” gets introduced. I get that join x = x >>= id, but then I’m still stuck on how that “duplicates” each value so that (*) gets two arguments. This has been bugging me for about half an hour now and I’m mostly annoyed at myself, because I feel like I have all the puzzle pieces but can’t seem to fit them together…

P.S. Don’t worry, I would’t really use this pointfree version, this is pure curiosity and an attempt to understand Haskell better.

  • 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-23T22:12:55+00:00Added an answer on May 23, 2026 at 10:12 pm

    join is using the instance of Monad for (->) a, as defined in Control.Monad.Instances. The instance is similar to Reader, but without an explicit wrapper. It is defined like this:

    instance Monad ((->) a) where
      -- return :: b -> (a -> b)
      return = const
      -- (>>=) :: (a -> b) -> (b -> a -> c) -> (a -> c)
      f >>= g = \x -> g (f x) x
    

    If you now reduce join using this instance:

    join
    (>>= id)
    flip (\f g x -> g (f x) x) (\a -> a)
    (\f x -> (\a -> a) (f x) x)
    (\f x -> f x x)
    

    As you can see, the instance for (->) a makes join to a function that applies an argument twice. Because of this, join (*) is simply \x -> x * x.

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

Sidebar

Related Questions

Just playing around with some of the APIs in .NET and I can't seem
I've been playing around with Simple.Data and have run across something that I can't
I'm playing around with Asymmetric Encryption and Decryption , but I don't understand the
i'm playing around with a piece of code i found on the web and
Just playing around with some sample code and hit on an unexpected problem with
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
I'm playing around with the <canvas> element, drawing lines and such. I've noticed that
While playing around with the emulator, I noticed that when trying to view a
Just playing around with java trying to learn it etc. Here is my code
I'm just playing around with some code but it seemed to have the specific

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.