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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:08:02+00:00 2026-06-15T04:08:02+00:00

showInt :: Int -> String showInt x = show x Does the above code

  • 0
showInt :: Int -> String
showInt x = show x

Does the above code calls show passing the Int dictionary or does it calls directly the function declared on Show Int instance?

I mean, does GHC removes polymorphic indirection from generated code when possible?

  • 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-15T04:08:03+00:00Added an answer on June 15, 2026 at 4:08 am

    Yes. This is the generated core using GHC 7.4.2:

    Foo.showInt :: GHC.Types.Int -> GHC.Base.String
    [... attributes omitted ...]
    Foo.showInt = GHC.Show.$fShowInt_$cshow
    

    As you can see, it’s just a direct reference to GHC.Show.$fShowInt_$cshow.

    Compare with what happens if we remove the type signature so that the inferred type Show a => a -> String is used instead:

    Foo.showInt
      :: forall a_aop. GHC.Show.Show a_aop => a_aop -> GHC.Base.String
    [... attributes omitted ...]
    Foo.showInt =
      \ (@ a_aot) ($dShow_aou :: GHC.Show.Show a_aot) (x_a9Z :: a_aot) ->
        GHC.Show.show @ a_aot $dShow_aou x_a9Z
    

    Here, it takes a dictionary argument $dShow_aou and it uses the accessor function GHC.Show.show to look
    up the appropriate function from this dictionary before applying the resulting function to the argument x_a9Z.

    What happens in the first case, at least conceptually, is that since the concrete type is known, GHC inserts a direct reference to the appropriate instance dictionary rather than taking it as an argument. Then, the accessor, which is basically just a record label, can be inlined and you’re left
    with a direct reference to the appropriate function.

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

Sidebar

Related Questions

I have this type definition: data Operace = Op (Int->Int->Int) String (Int->Int->Int) deriving Show
I am trying to write the pattern matcher for the below string show int
public String show(int[] row) { for(int i = 0; i < row.length; i++) {
I have actions public virtual ActionResult Show(string userId) and public virtual ActionResult Show(int groupId)
I'm currently trying to write a little Show instance for primitive arithmetic functions. Goal
I have a String array and I want to show its items in a
I have the following code and i try to show text in text-view which
When showing data from a mysql table on an php page does it have
My Yii code not showing error summery before save movie in database.. what's the
I try to use gallery to show image in network. But when turn left

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.