[GHC] #12970: Add default implementation for Bits.bitSize

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: | Version: libraries/base | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I think it would be a good idea to provide a default implementation for bitSize, example: {{{#!hs bitSize b = fromMaybe (error "bitSize is undefined") (bitSizeMaybe b) }}} The advantage is that from now on new instances of Bits no longer need to define bitSize. And once bitSize has been removed there will be no errors about it not being a method of class Bits. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: Type: feature request | Status: upstream Priority: normal | Milestone: Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * cc: core-libraries-committee@… (added) * status: new => upstream Comment: This would need to be cleared with the [[https://wiki.haskell.org/Core_Libraries_Committee|Core Libraries Committee]]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: Type: feature request | Status: upstream Priority: normal | Milestone: Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): it may make sense to also consider a DefaultSignature-based default impl for `bitSizeMaybe` inheriting from `FiniteBits(finiteBitSize)` -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: (none) Type: feature request | Status: upstream Priority: normal | Milestone: Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by txnull): Any news on the issue? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: (none) Type: feature request | Status: upstream Priority: normal | Milestone: Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): We deprecated bitSize back in 7.8. Removing it outright in 8.4 seems to be a reasonably measured move and would preempt the need for this default. I'm rather inclined to say we should just finish removing it. Either way, we're now past the window in which we should do anyhing either way that would affect 8.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: (none) Type: feature request | Status: upstream Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: normal => high * milestone: => 8.4.1 Comment: Sounds good to me, let's remove it for 8.4. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: upstream Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * owner: (none) => dfeuer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: upstream => patch * differential: => Phab:D3723 Comment: I've submitted Phab:D3723 to remove `bitSize`. My only question is whether we should add it back as a function {{{#!hs bitSize :: FiniteBitSize a => a -> Int bitSize = finiteBitSize }}} to reduce unnecessary breakage. This only goes so far; module import lines may need to be changed to fix old code. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:7 dfeuer]:
I've submitted Phab:D3723 to remove `bitSize`. My only question is whether we should add it back as a function
to be fair, bitSize was deprecated 3 years ago in GHC 7.8; and when GHC 8.4 is released that'll be 4 years. If the point of a deprecation is to eventually rid the API of the deprecated entity, 4 years (or a 4 rls window) is IMO more than enough time for everyone to adapt... ;-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Replying to [comment:8 hvr]:
Replying to [comment:7 dfeuer]:
I've submitted Phab:D3723 to remove `bitSize`. My only question is whether we should add it back as a function
to be fair, bitSize was deprecated 3 years ago in GHC 7.8; and when GHC 8.4 is released that'll be 4 years. If the point of a deprecation is to eventually rid the API of the deprecated entity, 4 years (or a 4 rls window) is IMO more than enough time for everyone to adapt... ;-)
For sure. It's a bit sad, though, that we're discarding a perfectly good name simply because it was originally stuck in the wrong class. I guess that's life. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

For sure. It's a bit sad, though, that we're discarding a perfectly good name simply because it was originally stuck in the wrong class. I guess
#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): that's life. Oh, now that I read the type-sig more carefully, I see it changes from `BitSize a =>` to `FiniteBitSize a =>`; which makes me more neutral on this. I guess it's a sensible thing to do; the only downside is that we carry around redundancy (e.g. an alias for `finiteBiteSize`). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): Are we going to do this? If so I wonder whether we should push it to 8.6 to avoid breaking libraries again prior to 8.4. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): Replying to [comment:11 bgamari]:
Are we going to do this? If so I wonder whether we should push it to 8.6 to avoid breaking libraries again prior to 8.4.
By that argument we'd never remove anything, as the same situation would just re-present itself during GHC 8.5; if maintainers have been ignoring the warnings introduced in GHC 7.8, they'll likely ignore them forever... life's too short... ;-) In comment:4 Ed wrote:
We deprecated `bitSize` back in 7.8. Removing it outright in 8.4 seems to be a reasonably measured move and would preempt the need for this default. I'm rather inclined to say we should just finish removing it.
So that's the part I believe everyone agrees. And one year later, David submitted a patch (see comment:7) to finally finish this. However, David also brought up a suggestion of doing something that wasn't originally considered/planned: adding a top-level `bitSize` binding in place of the removed `bitSize` method. It isn't clear whether this is something everyone agrees to want to do (David writes in phab:D3723: ''"@ekmett seems to oppose stealing the name."''). What I'd suggest at this point while we're still ahead of the GHC 8.4 freeze: Do the removal now, don't add anything new in its place. Once GHC HEAD snapshots appear with this change, we'll see quickly how bad the fallout is. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

By that argument we'd never remove anything, as the same situation would just re-present itself during GHC 8.5; if maintainers have been ignoring
#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.4.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): the warnings introduced in GHC 7.8, they'll likely ignore them forever... life's too short... ;-) Fair enough. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.6.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.4.1 => 8.6.1 Comment: The patch isn't ready yet and at this point it's too late at this point for non-necessary interface changes. Bumping. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.6.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): Edward Kmett seems to think this should wait indefinitely as `bitSize` is part of Haskell 2010. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: ⊥ Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.6.1 => ⊥ Comment: Alright; un-milestoning. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: ⊥ Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): I wouldn't say indefinitely. There is a Haskell Prime Committee that when I last checked was aiming for a 2020 report. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: ⊥ Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by txnull): Then maybe back to my initial idea and add a default implementation for bitSize in the mean time? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: ⊥ Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Comment (by ekmett): I have no objection to filling in a default definition until it gets removed. That would make it possible for folks to eventually remove the definitions from their code and stay 3-release friendly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.6.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * milestone: ⊥ => 8.6.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: patch Priority: high | Milestone: 8.6.1 Component: libraries/base | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723, Wiki Page: | Phab:D4857 -------------------------------------+------------------------------------- Changes (by bgamari): * differential: Phab:D3723 => Phab:D3723, Phab:D4857 Comment: Adding default implementation for 8.6 in D4857. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12970: Add default implementation for Bits.bitSize
-------------------------------------+-------------------------------------
Reporter: txnull | Owner: dfeuer
Type: feature request | Status: patch
Priority: high | Milestone: 8.6.1
Component: libraries/base | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3723,
Wiki Page: | Phab:D4857
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#12970: Add default implementation for Bits.bitSize -------------------------------------+------------------------------------- Reporter: txnull | Owner: dfeuer Type: feature request | Status: closed Priority: high | Milestone: 8.6.1 Component: libraries/base | Version: Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3723, Wiki Page: | Phab:D4857 -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: I've gone ahead with this for 8.6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12970#comment:23 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC