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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:12:52+00:00 2026-06-01T02:12:52+00:00

rho x = map (((flip mod) x).(\a -> a^2-1)) (rho x) This function will

  • 0
rho x = map (((flip mod) x).(\a -> a^2-1)) (rho x)

This function will generate an infinite list. And I tested in GHCi, the function type is

*Main> :t rho
rho :: Integral b => b -> [b]

If I define a function like this

fun x = ((flip mod) x).(\a -> a^2-1)

The type is

*Main> :t fun
fun :: Integral c => c -> c -> c

My question is, how can Haskell deduce the function type to b -> [b]? We don’t have any [] type data in this function. Thanks!

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

    map has the following type:

    map :: (a -> b) -> [a] -> [b]
    

    So, we can deduce the types of the arguments to map:

    (((flip mod) x).(\a -> a^2-1)) :: (a -> b)
    (rho x) :: [a]
    

    But the result of map is also the result of rho x, so:

    (rho x) :: [b]
    

    Which implies that a and b are the same type, so:

    rho :: ? -> [b]
    

    If we examine the mapping function, and make x free, we find the type:

    \x -> ((flip mod) x).(\a -> a^2-1) :: Integral b => b -> (b -> b)
    

    The Integral b => b gives us the type of x, and the (b -> b) unifies with the type of the function composition, so we know that this b is the same as the previous one.

    rho :: Integral b => b -> [b]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With n<-3; rho<-0.5; I want to draw the picture of the function g<-function(r) {
I have a list shaped like this: '((Alpha . 1538) (Beta . 8036) (Gamma
syms x1 x2 x3 theta gamma beta rho miu sigma; f=-(exp(i*x1)-1)*Ei(1, x2)/(i*x1); Undefined function
I'm using polar plots (POLAR(THETA,RHO)) in MATLAB. Is there an easy way to fix
I am tryin to setup the rho mobile for android applications. I am somehow
I am trying to make a 3D plot from x, y, z points list,
Please can someone post a SQL function to convert easting/northing to longitude/latitude. I know
I am trying to implement Pollard Rho integer factorization in C/C++.Google gives me a
I am trying to combine the following two functions into one portable function: void
I have this equation and it's quite big (basically a FDM one) but it

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.