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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:04:20+00:00 2026-06-03T09:04:20+00:00

I’m writing a Haskell to Javascript code generator, using GHC as a library. Since

  • 0

I’m writing a Haskell to Javascript code generator, using GHC as a library. Since Javascript doesn’t have an integer type and its Number type can only represent integers up to 2⁵³ properly, I’m representing integers as Numbers, explicitly performing all arithmetic modulo 2³². This works very well with a 32 bit GHC, but rather worse with the 64 bit version.

GHC will happily coerce Int64 values to Ints and interpret Int constants as 64 bit values (0xffffffff turns into 4294967295 rather than -1, for example) and that’s causing all sorts of annoying problems.

The compiler works very well for “normal” web stuff even on a 64 bit system, provided that the standard libraries are built on a 32 bit machine, but “please don’t use large-ish numbers, OK?” isn’t something you want to see in your compiler’s manual. Some of the problems (but not all) can be alleviated by compiling with -O0, but that (unsurprisingly) produces code that’s not only slow, but also way too big.

So, I need to stop GHC from assuming that Int and Int64 are equivalent. Is this even 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-03T09:04:21+00:00Added an answer on June 3, 2026 at 9:04 am

    That is not possible, without using a 32 bit GHC.

    The Haskell Language standard says that the only thing you know about the Int type is that it has

    at least the range [-2^29 .. 2^29-1

    So you can happily truncate Int values larger than this, and still be a fully compliant Haskell 2010 implementation!

    However, you should probably not do this, and instead look for a 64 bit integer type for JavaScript. The same trick as e.g. GHC does to support Int64 on 32 bit machines.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't

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.