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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:20:52+00:00 2026-05-15T16:20:52+00:00

Unboxed types, like Int# , and strict functions, like f (!x) = … ,

  • 0

Unboxed types, like Int#, and strict functions, like f (!x) = ..., are something different, but I see conceptual similarity – they disallow thunks/laziness in some way. If Haskell was a strict language like Ocaml, every function would be strict and every type unboxed. What is the relationship between unboxed types and enforcing strictness?

  • 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-15T16:20:53+00:00Added an answer on May 15, 2026 at 4:20 pm

    Unboxed vs Boxed Data

    To support parametric polymorphism and laziness, by default Haskell data types are represented uniformly as a pointer to a closure on the heap, with a structure like this:

    alt text
    (source: haskell.org)

    These are “boxed” values. An unboxed object is represented by the value itself directly, without any indirection or closure. Int is boxed, but Int# is unboxed.

    Lazy values require a boxed representation. Strict values do not: they can represented either as fully evaluated closures on the heap, or as primitive unboxed structures. Note that pointer tagging is an optimization that we can use on boxed objects, to encode the constructor in the pointer to the closure.

    The Relationship to Strictness

    Normally, unboxed values are generated in an ad hoc fashion by functional language compilers. In Haskell, however, unboxed values are special. They:

    1. they have a different kind, #;
    2. can only be used in special places; and
    3. they’re unlifted, so are not represented as a pointer to a heap value.

    Because they are unlifted they are necessarily strict. The representation of laziness is not possible.

    So particular unboxed types, like Int#, Double#, really are represented just as double or int on the machine (in C notation).

    Strictness Analysis

    Separately, GHC does strictness analysis of regular Haskell types. If a value’s use is found to be strict – i.e. it can never be ‘undefined’ – the optimizer might replace all uses of the regular type (e.g. Int) with an unboxed one (Int#), since it knows that the use of Int is always strict, and thus replacement with the more efficient (and always strict) type Int# is safe.

    We can of course have strict types without unboxed types, for example, an element-strict polymorphic list:

    data List a = Empty | Cons !a (List a)
    

    is strict in its elements, but does not represent them as unboxed values.

    This also points out the mistake you made about strict languages, like OCaml. They still need to support polymorphism, so either they provide a uniform representation, or they specialize data types and functions to every type. GHC by default uses uniform representation, as does OCaml, though GHC can also specialize types and functions now (like C++ templates).

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

Sidebar

Related Questions

Ok I must be overlooking something extremely simple but I am lost. Given this
I was wondering why Nullable<T> is a value type, if it is designed to
One one hand, in Haskell Vector a seems to be the preferred type to
I am resorting to a horrible hack in order to fill a locked-down data
Why does this throw NullPointerException public static void main(String[] args) throws Exception { Boolean
Possible Duplicates: Booleans, conditional operators and autoboxing Java, Google Collections Library; problem with AbstractIterator?
Considering this class: public class Foo { public Int32 MyField; } I guess the

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.