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

  • Home
  • SEARCH
  • 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 8602621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:07:48+00:00 2026-06-12T02:07:48+00:00

While reading https://en.uncyclopedia.co/wiki/Haskell (and ignoring all the offensive stuff), I stumbled upon the following

  • 0

While reading https://en.uncyclopedia.co/wiki/Haskell (and ignoring all the “offensive” stuff), I stumbled upon the following piece of obfuscated code:

fix$(<$>)<$>(:)<*>((<$>((:[{- thor's mother -}])<$>))(=<<)<$>(*)<$>(*2))$1

When I run that piece of code in ghci (after importing Data.Function and Control.Applicative), ghci prints the list of all powers of 2.

How does this piece of code work?

  • 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-12T02:07:49+00:00Added an answer on June 12, 2026 at 2:07 am

    To begin with, we have the lovely definition

    x = 1 : map (2*) x
    

    which by itself is a bit mind-bending if you’ve never seen it before. Anyway it’s a fairly standard trick of laziness and recursion. Now, we’ll get rid of the explicit recursion using fix, and point-free-ify.

    x = fix (\vs -> 1 : map (2*) vs)
    x = fix ((1:) . map (2*))
    

    The next thing we’re going to do is expand the : section and make the map needlessly complex.

    x = fix ((:) 1 . (map . (*) . (*2)) 1)
    

    Well, now we have two copies of that constant 1. That will never do, so we’ll use the reader applicative to de-duplicate that. Also, function composition is a bit rubbish, so let’s replace that with (<$>) wherever we can.

    x = fix (liftA2 (.) (:) (map . (*) . (*2)) 1)
    x = fix (((.) <$> (:) <*> (map . (*) . (*2))) 1)
    x = fix (((<$>) <$> (:) <*> (map <$> (*) <$> (*2))) 1)
    

    Next up: that call to map is much too readable. But there’s nothing to fear: we can use the monad laws to expand it a bit. In particular, fmap f x = x >>= return . f, so

    map f x = x >>= return . f
    map f x = ((:[]) <$> f) =<< x
    

    We can point-free-ify, replace (.) with (<$>), and then add some spurious sections:

    map = (=<<) . ((:[]) <$>)
    map = (=<<) <$> ((:[]) <$>)
    map = (<$> ((:[]) <$>)) (=<<)
    

    Substituting this equation in our previous step:

    x = fix (((<$>) <$> (:) <*> ((<$> ((:[]) <$>)) (=<<) <$> (*) <$> (*2))) 1)
    

    Finally, you break your spacebar and produce the wonderful final equation

    x=fix(((<$>)<$>(:)<*>((<$>((:[])<$>))(=<<)<$>(*)<$>(*2)))1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading the OWASP site, I stumbled upon pages www.owasp.org/index.php/Category:Countermeasure and www.owasp.org/index.php/Category:Control . My
While reading this class BitmapFactory I noticed that almost all methods inside are static.
While reading proggit today, I came upon this comment in a post about how
while reading about cookies i found difficulty to grasp the following statement setcookie() must
While reading the spree source code via the official code repository on Github, https://github.com/spree/spree
I've been reading https://developers.google.com/maps/documentation/javascript/overlays for a while now and I can't seem to get
While reading the K&R 2nd edition I noticed that the programs always began with
While reading from serial port I am using serialport.read(xyz,0,4) where xyz is a byte
While reading from a configuration file in Perl there might be cases when a
While reading through another question here, on creating a URL shortening service, it was

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.