# Where are the two missing bits from \`Int\`?

**URL:** <https://discourse.haskell.org/t/where-are-the-two-missing-bits-from-int/7962>\
**Category:** Learn\
**Created:** [October 29, 2023, 10:44am UTC](https://discourse.haskell.org/t/where-are-the-two-missing-bits-from-int/7962 "2023-10-29T10:44:39Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![atravers](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@atravers](https://discourse.haskell.org/u/atravers)\
**Post date:** [October 30, 2023, 10:10pm UTC](https://discourse.haskell.org/t/where-are-the-two-missing-bits-from-int/7962/7 "2023-10-30T22:10:04Z")

</div>

> [@sgraf](#):
>
> I’m not convinced we need the “graph” either […] but don’t have a replacement to offer.

Have I got a deal for you!

- for theoreticians:  
[Call-by-Need Is Clairvoyant Call-by-Value](https://www.cs.nott.ac.uk//~pszjlh/cbncbv.pdf) ([_2019_](https://www.cs.nott.ac.uk//~pszjlh/cbncbv_erratum.pdf) )

- for implementors:  
[On Inter-deriving Small-step and Big-step Semantics: A Case Study for Storeless Call-by-need Evaluation](http://www.zerny.dk/danvy-al-tcs12.pdf) (2012).

(Alas, the acronym _“STM”_ has already been taken…)

* * *

> Of course, the '98 paper is concerned with side-effects in SML, which warrants a more first class integration of commands.

Not necessarily - read section 5.1 (_First-order versus higher-order_, page 29 of 33) in [How to Declare an Imperative](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.91.3579&rep=rep1&type=pdf) (1997). But failing that, there’s the evidence-passing style as used by Linear Haskell:

> [@Since Haskell has linear types so we can track resources, why can't we disable the GC like in ATS?](http://discourse.haskell.org/t/since-haskell-has-linear-types-so-we-can-track-resources-why-cant-we-disable-the-gc-like-in-ats/7951/12):
>
> No, you shouldn’t need pragmas. As the abstract says: Soundness of linear constraints is ensured by the fact that they desugar into Linear Haskell. Linear types permeate all the way into Core, so optimizations should preserve them, although I believe that is not yet checked at the moment. @romes is working on that. But any problems with that should be seen as bugs in GHC, not as problems with linear constraints. Also, the second argument of swap is not a good example because that’s just an …

* * *

> As it happens, we were just discussing today [_again!_] how to equip STG with an “ABI” that allows us to have first class call-by-value functions:

~~_That’s odd: from [Making a Fast Curry](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.5.6776&rep=rep1&type=pdf) (2004), I thought the STG language was already strict._~~

Edit: from that paper, I presumed an implementation of the STG language in another strict language would be a simple matter of replacing the local bindings `v = e` in each `Let`-expressions with calls to e.g. `v = halloc(e);` with the result of the `Let`-expression immediately following:

```
Let b1 = e1; ... bN = eN; in result
```

therefore being expanded to:

```
b1 = halloc(e1);
     ⋮ 
bN = halloc(eN);
{- code
    for
    result -};
```

So in that very specific sense, there’s already a strict variant of the STG language lurking in the original one - it just needs to be _“exposed”_.

Perhaps the _“strict Core”_ variant devised in [Types are Calling Conventions](https://www.researchgate.net/profile/Simon-Peyton-Jones/publication/221562931_Types_are_calling_conventions/links/0c960517e31f4ad9b5000000/Types-are-calling-conventions.pdf) (2009) could be of some use, despite it being (apparently) [superseded](https://www.researchgate.net/profile/Paul-Downen/publication/343413492_Kinds_are_calling_conventions/links/5f3aeddda6fdcccc43d0e45a/Kinds-are-calling-conventions.pdf)…

* * *

> Both of these references are _very_ interesting, thank you! […]

…getting back on-topic: were Standard ML’s `int` values also similarly limited in size back then (1990-1997)? If so, the appropriate standard reference for that language ought to have the answer to the original question.

---

_[View the full topic](https://discourse.haskell.org/t/where-are-the-two-missing-bits-from-int/7962)._
