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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:09:25+00:00 2026-05-19T13:09:25+00:00

I was a bit confused by the documentation for fix (although I think I

  • 0

I was a bit confused by the documentation for fix (although I think I understand what it’s supposed to do now), so I looked at the source code. That left me more confused:

fix :: (a -> a) -> a
fix f = let x = f x in x

How exactly does this return a fixed point?

I decided to try it out at the command line:

Prelude Data.Function> fix id
...

And it hangs there. Now to be fair, this is on my old macbook which is kind of slow. However, this function can’t be too computationally expensive since anything passed in to id gives that same thing back (not to mention that it’s eating up no CPU time). What am I doing wrong?

  • 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-19T13:09:26+00:00Added an answer on May 19, 2026 at 1:09 pm

    You are doing nothing wrong. fix id is an infinite loop.

    When we say that fix returns the least fixed point of a function, we mean that in the domain theory sense. So fix (\x -> 2*x-1) is not going to return 1, because although 1 is a fixed point of that function, it is not the least one in the domain ordering.

    I can’t describe the domain ordering in a mere paragraph or two, so I will refer you to the domain theory link above. It is an excellent tutorial, easy to read, and quite enlightening. I highly recommend it.

    For the view from 10,000 feet, fix is a higher-order function which encodes the idea of recursion. If you have the expression:

    let x = 1:x in x
    

    Which results in the infinite list [1,1..], you could say the same thing using fix:

    fix (\x -> 1:x)
    

    (Or simply fix (1:)), which says find me a fixed point of the (1:) function, IOW a value x such that x = 1:x… just like we defined above. As you can see from the definition, fix is nothing more than this idea — recursion encapsulated into a function.

    It is a truly general concept of recursion as well — you can write any recursive function this way, including functions that use polymorphic recursion. So for example the typical fibonacci function:

    fib n = if n < 2 then n else fib (n-1) + fib (n-2)
    

    Can be written using fix this way:

    fib = fix (\f -> \n -> if n < 2 then n else f (n-1) + f (n-2))
    

    Exercise: expand the definition of fix to show that these two definitions of fib are equivalent.

    But for a full understanding, read about domain theory. It’s really cool stuff.

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

Sidebar

Related Questions

I'm a bit confused here. Microsoft as far as I can tell claims that
I'm a bit confused that the argument to crypto functions is a string. Should
I am a bit confused why this code compiles. I leave out the necessary
I'm a bit confused by the documentation here. I have a transaction, which start
I'm a bit confused on the description of joystick axes and I'm hoping that
I'm a bit confused as to the term closure used within the Groovy documentation
I am a bit confused about socket programming in C. You create a socket,
I am bit confused about ADO.Net Data Services. Is it just meant for creating
I'm a bit confused from what I've heard Java doesn't do events. But I
I'm fairly new to the Zend Framework and MVC and I'm a bit confused

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.