Proposal: Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)

Proposal: ~~~~~~~~~ Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package) Discussion deadline: 2 weeks. Note: This is a reboot of a previous unresolved proposal[1] by Johan Tibell with a slightly different emphasis. Current Issues: ~~~~~~~~~~~~~~~ - The `deepseq` package should not depend on `containers` and `array` (ideally `deepseq` would be merged with `base` and `containers`/`array` would define their own `NFData` instances) - Not all data types defined by "core libraries" have `NFData` instances defined (e.g. `time` and `bytestring`). The lack of such "standard" instances causes users of `deepseq` to define local orphan instances - GHC boot packages can't depend on `deepseq` as it is not a GHC-boot package yet, and thus orphan instances are required for those packages -- which would benefit in terms of maintainability[4] and efficiency[3] from being defined locally by having access to the internal representations Rationale: ~~~~~~~~~~ The principal idea this proposal is based upon is that the `NFData` type-class is similarly universal/basic/fundamental as the `Ord`, `Show`, or `Eq` type-classes are -- it might be even desirable to make `NFData` part of a future Haskell Prelude at some point and maybe even allow automatic instance derivation. Building on this idea that `NFData` is a "primitive" type-class, the next best thing that can be done relatively easy and short-term as a transitional step is to 1) make `deepseq` a GHC-boot package[2], 2) remove `deepseq`'s dependancy on `array` and `containers`, 3) move the affected instance definitions to the `array` and `containers` packages respectively, and 4) satisfy the PVP by incrementing package versions where necessary. This should provide a path of least resistance, as no packages depending on `deepseq` would have to be adapted except for maybe PVP-related version constraint widening. Moreover, this would pave the way for a future proposal to merge the `deepseq` into `base` at some later point. References: ~~~~~~~~~~~ [1]: http://hackage.haskell.org/trac/ghc/ticket/4868 [2]: http://www.haskell.org/pipermail/libraries/2010-December/015427.html [3]: http://www.haskell.org/pipermail/libraries/2010-December/015428.html [4]: http://www.haskell.org/pipermail/libraries/2011-January/015488.html -- hvr

On Tue, Aug 23, 2011 at 1:39 PM, Herbert Valerio Riedel
Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
I'm strongly in favour of this also. IIRC Ian was the one who objected
most strenuously last time. What sayest thou, Ian?
G
--
Gregory Collins

On 8/23/11 9:23 AM, Gregory Collins wrote:
On Tue, Aug 23, 2011 at 1:39 PM, Herbert Valerio Riedel
wrote: Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
+1.
I'm strongly in favour of this also. IIRC Ian was the one who objected most strenuously last time. What sayest thou, Ian?
I'm curious about that too. -- Live well, ~wren

On Wednesday 24 August 2011, 07:32:45, wren ng thornton wrote:
On 8/23/11 9:23 AM, Gregory Collins wrote:
On Tue, Aug 23, 2011 at 1:39 PM, Herbert Valerio Riedel
wrote: Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
+1.
I'm strongly in favour of this also. IIRC Ian was the one who objected most strenuously last time. What sayest thou, Ian?
I'm curious about that too.
I seem to recall that Ian is on vacation, so your curiosity would have to wait a bit. Unless good reasons against surface, I support this proposal too.

On Tue, Aug 23, 2011 at 03:23:04PM +0200, Gregory Collins wrote:
On Tue, Aug 23, 2011 at 1:39 PM, Herbert Valerio Riedel
wrote: Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
Moreover, this would pave the way for a future proposal to merge the `deepseq` into `base` at some later point.
I'm strongly in favour of this also. IIRC Ian was the one who objected most strenuously last time. What sayest thou, Ian?
In general, my opinion is still that we should be trying to make base smaller, not larger. Some stats: Directory: ghc-7.0.4/libraries/base ghc-7.2.1/libraries/base Size: 2.8 MB 3.2 MB Exposed GHC.* modules: 62 69 Exposed other modules: 90 102 Private GHC.* modules: 12 12 Private other modules: 0 3 Total modules: 164 186 {-# SOURCE #-} imports: 12 18 [for those stats, I pretended System.Event* was called GHC.Event* in 7.0] That's just my opinion, though. Thanks Ian

On 24/08/2011 22:38, Ian Lynagh wrote:
On Tue, Aug 23, 2011 at 03:23:04PM +0200, Gregory Collins wrote:
On Tue, Aug 23, 2011 at 1:39 PM, Herbert Valerio Riedel
wrote: Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
Moreover, this would pave the way for a future proposal to merge the `deepseq` into `base` at some later point.
I'm strongly in favour of this also. IIRC Ian was the one who objected most strenuously last time. What sayest thou, Ian?
In general, my opinion is still that we should be trying to make base smaller, not larger. Some stats:
Are you also opposed to making deepseq a GHC-boot package? Any subsequent proposal to merge it into base could be countered at that point with an alternative proposal to move other things out of base instead and have them depend on deepseq. Ganesh

On 25 August 2011 05:53, Ganesh Sittampalam
On 24/08/2011 22:38, Ian Lynagh wrote:
On Tue, Aug 23, 2011 at 03:23:04PM +0200, Gregory Collins wrote:
On Tue, Aug 23, 2011 at 1:39 PM, Herbert Valerio Riedel
wrote: Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
Moreover, this would pave the way for a future proposal to merge the `deepseq` into `base` at some later point.
I'm strongly in favour of this also. IIRC Ian was the one who objected most strenuously last time. What sayest thou, Ian?
In general, my opinion is still that we should be trying to make base smaller, not larger. Some stats:
Are you also opposed to making deepseq a GHC-boot package? Any subsequent proposal to merge it into base could be countered at that point with an alternative proposal to move other things out of base instead and have them depend on deepseq.
+1 Conrad.

On Wed, 2011-08-24 at 22:38 +0100, Ian Lynagh wrote:
Moreover, this would pave the way for a future proposal to merge the `deepseq` into `base` at some later point.
I'm strongly in favour of this also. IIRC Ian was the one who objected most strenuously last time. What sayest thou, Ian?
In general, my opinion is still that we should be trying to make base smaller, not larger.
That's fine too -- although merging `deepseq` w/ `base` is beyond this proposal (I mentioned it for the case `NFData` was about to make its way into a future Haskell20xx (Library) Report). But what's about the actual proposal at hand? +1 or -1? :-) However, out of curiosity and generally speaking: What should be part of `base` anyway? The current descriptions says | This package contains the Prelude and its support libraries, and a | large collection of useful libraries ranging from data structures to | parsing combinators and debugging utilities. -- hvr

+1
Sent from my iPhone
On Aug 23, 2011, at 7:39 AM, Herbert Valerio Riedel
Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
Discussion deadline: 2 weeks.
Note: This is a reboot of a previous unresolved proposal[1] by Johan Tibell with a slightly different emphasis.
Current Issues: ~~~~~~~~~~~~~~~
- The `deepseq` package should not depend on `containers` and `array` (ideally `deepseq` would be merged with `base` and `containers`/`array` would define their own `NFData` instances)
- Not all data types defined by "core libraries" have `NFData` instances defined (e.g. `time` and `bytestring`). The lack of such "standard" instances causes users of `deepseq` to define local orphan instances
- GHC boot packages can't depend on `deepseq` as it is not a GHC-boot package yet, and thus orphan instances are required for those packages -- which would benefit in terms of maintainability[4] and efficiency[3] from being defined locally by having access to the internal representations
Rationale: ~~~~~~~~~~
The principal idea this proposal is based upon is that the `NFData` type-class is similarly universal/basic/fundamental as the `Ord`, `Show`, or `Eq` type-classes are -- it might be even desirable to make `NFData` part of a future Haskell Prelude at some point and maybe even allow automatic instance derivation.
Building on this idea that `NFData` is a "primitive" type-class, the next best thing that can be done relatively easy and short-term as a transitional step is to
1) make `deepseq` a GHC-boot package[2],
2) remove `deepseq`'s dependancy on `array` and `containers`,
3) move the affected instance definitions to the `array` and `containers` packages respectively, and
4) satisfy the PVP by incrementing package versions where necessary.
This should provide a path of least resistance, as no packages depending on `deepseq` would have to be adapted except for maybe PVP-related version constraint widening.
Moreover, this would pave the way for a future proposal to merge the `deepseq` into `base` at some later point.
References: ~~~~~~~~~~~
[1]: http://hackage.haskell.org/trac/ghc/ticket/4868 [2]: http://www.haskell.org/pipermail/libraries/2010-December/015427.html [3]: http://www.haskell.org/pipermail/libraries/2010-December/015428.html [4]: http://www.haskell.org/pipermail/libraries/2011-January/015488.html
-- hvr
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

+1
On Tue, Aug 23, 2011 at 3:49 PM, Edward Kmett
+1
Sent from my iPhone
On Aug 23, 2011, at 7:39 AM, Herbert Valerio Riedel
wrote: Proposal: ~~~~~~~~~
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
Discussion deadline: 2 weeks.
Note: This is a reboot of a previous unresolved proposal[1] by Johan Tibell with a slightly different emphasis.
Current Issues: ~~~~~~~~~~~~~~~
- The `deepseq` package should not depend on `containers` and `array` (ideally `deepseq` would be merged with `base` and `containers`/`array` would define their own `NFData` instances)
- Not all data types defined by "core libraries" have `NFData` instances defined (e.g. `time` and `bytestring`). The lack of such "standard" instances causes users of `deepseq` to define local orphan instances
- GHC boot packages can't depend on `deepseq` as it is not a GHC-boot package yet, and thus orphan instances are required for those packages -- which would benefit in terms of maintainability[4] and efficiency[3] from being defined locally by having access to the internal representations
Rationale: ~~~~~~~~~~
The principal idea this proposal is based upon is that the `NFData` type-class is similarly universal/basic/fundamental as the `Ord`, `Show`, or `Eq` type-classes are -- it might be even desirable to make `NFData` part of a future Haskell Prelude at some point and maybe even allow automatic instance derivation.
Building on this idea that `NFData` is a "primitive" type-class, the next best thing that can be done relatively easy and short-term as a transitional step is to
1) make `deepseq` a GHC-boot package[2],
2) remove `deepseq`'s dependancy on `array` and `containers`,
3) move the affected instance definitions to the `array` and `containers` packages respectively, and
4) satisfy the PVP by incrementing package versions where necessary.
This should provide a path of least resistance, as no packages depending on `deepseq` would have to be adapted except for maybe PVP-related version constraint widening.
Moreover, this would pave the way for a future proposal to merge the `deepseq` into `base` at some later point.
References: ~~~~~~~~~~~
[1]: http://hackage.haskell.org/trac/ghc/ticket/4868 [2]: http://www.haskell.org/pipermail/libraries/2010-December/015427.html [3]: http://www.haskell.org/pipermail/libraries/2010-December/015428.html [4]: http://www.haskell.org/pipermail/libraries/2011-January/015488.html
-- hvr
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- Nicolas Pouillard http://nicolaspouillard.fr

| Make `NFData` a fundamental/primitive type-class | (by making `deepseq` a GHC-boot package) The goals are good, but I don't follow the proposed design. In particular, why does the deepseq package need to be in base? In principle, you can do this: * Implement deepseq * Add instances for GHC types and container types; these instances wouldn't be orphans because they'd be in the module defining the NFData class The main objection seems to be this: * deepseq would thereby depend on 'containers' (say), whereas a random customer of deepseq might find that odd. And it might increase the size of his binaries. The solution to that is to make containers depend on deepseq. That would induce the inverse dependency: every user of containers would get deepseq willy-nilly. Perhaps that is less bad. And it would make 'deepseq' into a GHC boot package, which is probably fine. But that *isn't* a reason to merge deepseq into the already too-big base package, is it? And that is the root of Ian's objection. Simon

On Thu, Aug 25, 2011 at 9:12 AM, Simon Peyton-Jones
But that *isn't* a reason to merge deepseq into the already too-big base package, is it? And that is the root of Ian's objection.
No. Lets just reverse the containers <-> deepseq dependency and make deepseq a bootlib. Johan

Hello Simon, On Thu, 2011-08-25 at 07:12 +0000, Simon Peyton-Jones wrote:
| Make `NFData` a fundamental/primitive type-class | (by making `deepseq` a GHC-boot package)
The goals are good, but I don't follow the proposed design. In particular, why does the deepseq package need to be in base?
I regret not having made it clearer that merging with `base` is beyond the current proposal (and mostly under the assumption that it reaches equal footing with type-classes such as Eq w.r.t. to standardisation) Also I'm a bit mislead by `base`'s description including "large collection of useful libraries", from which I assumed that it wouldn't be such a big deal to include a lightweight and useful type-class such as `NFData` in `base` anyway... :-)
In principle, you can do this:
* Implement deepseq
I'm not sure I understand what you mean by "implement deepseq" exactly... so... what do you mean by it?
* Add instances for GHC types and container types; these instances wouldn't be orphans because they'd be in the module defining the NFData class
Are there "abstract" GHC types whose internal representation isn't visible outside the defining modules (and which would be sensible to have access to for efficient deepseq/rnf implementations)?
The main objection seems to be this:
* deepseq would thereby depend on 'containers' (say), whereas a random customer of deepseq might find that odd. And it might increase the size of his binaries.
That's a slight understatement... it's not only `containers` but you'd get also 'array' and every other GHC-boot package (e.g. `time` and `bytestring`) that `deepseq` decides to define NFData instances for depended upon... And to be honest, the other issue of not having access to the internal representation of the data-structures is important too as it requires NFData instances to use the possibly suboptimal exported API, leading to potentially inefficient NFData instances (which is a bit counterproductive IMHO, as NFData is mostly used for benchmarking and parallelism, where I assume efficiency of the NFData operation would be desirable)
The solution to that is to make containers depend on deepseq. That would induce the inverse dependency: every user of containers would get deepseq willy-nilly. Perhaps that is less bad.
And it would make 'deepseq' into a GHC boot package, which is probably fine.
...may I count this as a +1 for the core proposal (i.e. just the containers+array <-> deepseq dependancy reversal + inclusion as GHC-boot packge)? :-)
But that *isn't* a reason to merge deepseq into the already too-big base package, is it? And that is the root of Ian's objection.
Indeed, that's not a reason to merge `deepseq` (= NFData type-class & instances for base-types) into `base` at this point. -- hvr

On 25/08/2011 08:12, Simon Peyton-Jones wrote:
| Make `NFData` a fundamental/primitive type-class | (by making `deepseq` a GHC-boot package)
The goals are good, but I don't follow the proposed design. In particular, why does the deepseq package need to be in base?
The proposal is to make deepseq a boot package, not to move anything into base.
In principle, you can do this:
* Implement deepseq
* Add instances for GHC types and container types; these instances wouldn't be orphans because they'd be in the module defining the NFData class
That's what we have right now, the problem is that deepseq can't define a good instance for NFData Map, because it can't see enough of the internals of Map.
The main objection seems to be this:
* deepseq would thereby depend on 'containers' (say), whereas a random customer of deepseq might find that odd. And it might increase the size of his binaries.
The solution to that is to make containers depend on deepseq. That would induce the inverse dependency: every user of containers would get deepseq willy-nilly. Perhaps that is less bad.
And it would make 'deepseq' into a GHC boot package, which is probably fine.
Exactly, that's the proposal! (+1 from me, BTW) Cheers, Simon

| > And it would make 'deepseq' into a GHC boot package, which is probably fine. | | Exactly, that's the proposal! | | (+1 from me, BTW) OK with me too. S

On Fri, Aug 26, 2011 at 10:34 AM, Paterson, Ross
Simon Marlow writes:
That's what we have right now, the problem is that deepseq can't define a good instance for NFData Map, because it can't see enough of the internals of Map.
Couldn't the strict foldl do it?
In this case yes, if you know the internal representation of the Map type (which is subject to change). To do it well you must force the values but not the keys while folding (the keys are already WHNF so forcing them would be wasteful). You must also make sure that the fold itself doesn't add any extra overhead. Johan

On Tue, 2011-08-23 at 13:39 +0200, Herbert Valerio Riedel wrote:
Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)
Discussion deadline: 2 weeks.
Fyi, now that the initial discussion period is over, I've created a new ticket and attached patches for the involved libraries at http://hackage.haskell.org/trac/ghc/ticket/5468
participants (14)
-
Conrad Parker
-
Daniel Fischer
-
Edward Kmett
-
Ganesh Sittampalam
-
Gregory Collins
-
Herbert Valerio Riedel
-
Ian Lynagh
-
Ivan Lazar Miljenovic
-
Johan Tibell
-
Nicolas Pouillard
-
Paterson, Ross
-
Simon Marlow
-
Simon Peyton-Jones
-
wren ng thornton