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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:20:17+00:00 2026-06-07T05:20:17+00:00

Possible Duplicate: What is going on with the types in this ghci session? To

  • 0

Possible Duplicate:
What is going on with the types in this ghci session?

To try and practice a bit of haskell and learn about point free I was playing around with a function to square a number

so I started by defining

>let dup f x = f x x

so I could rewrite sq in terms of dup (without worrying about making dup point free for now)

>let sq x = dup (*) x

and checking the type of sq I see what I’m expecting to see

>:t sq
>sq :: Num t => t -> t

so I remove the x’s and get

>let sq = dup (*)
>:t sq
sq :: Integer -> Integer

what am I missing?

  • 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-07T05:20:20+00:00Added an answer on June 7, 2026 at 5:20 am

    You have run into the monomorphism restriction. Haskell will not infer polymorphic types for functions unless they are given in “function” style (not point free). This would mean that let sq = dup (*) would not type check, but Haskell has so called “default rules” for standard numeric classes that mean it defaults to the monomorphic type `Integer->Integer”

    Prelude> :set -XNoMonomorphismRestriction
    Prelude> let dup f x = f x x
    Prelude> let sq = dup (*)
    Prelude> :t sq
    sq :: Num t => t -> t
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: JavaScript: formatting number with exactly two decimals Maybe I'm going about this
I know you guys going to say this might be possible duplicate to PHP
This is a possible duplicate. Couldn't find the exact one, I remember going through
Possible Duplicate: substring and the indexOf method I have this problem that I'm going
Possible Duplicate: Why Objective-C doesn't support method overloading? I was going through this link
Possible Duplicate: CallStack determines where you are going next? Started from the comment in
Possible Duplicate: pass by reference not working I was going through some of the
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Choosing Java vs Python on Google App Engine We are going to

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.