Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#5593 closed task (fixed)

Proposal: Remove Num superclass of Bits

Reported by: basvandijk Owned by:
Priority: normal Milestone: 7.6.1
Component: libraries/base Version: 7.2.1
Keywords: report-impact Cc: hvr, ekmett
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

This ticket summarizes the discussion on the proposal to remove the Num superclass of the Bits type class.

The proposal is to:

  • Remove the Num superclass of the Bits type class.
  • Remove the default implementations of bit, testBit and popCount since they use methods of Num.
  • Export the following convenience functions from Data.Bits:
bitDefault :: (Bits a, Num a) => Int -> a
bitDefault i = 1 `shiftL` i

testBitDefault ::  (Bits a, Num a) => a -> Int -> Bool
testBitDefault x i = (x .&. bit i) /= 0

popCountDefault :: (Bits a, Num a) => a -> Int
popCountDefault = go 0
 where
   go !c 0 = c
   go c w = go (c+1) (w .&. w - 1) -- clear the least significant

Attached are tickets for base and ghc.

Attachments (2)

0001-Remove-Num-superclass-of-Bits.patch (12.1 KB) - added by basvandijk 8 years ago.
Patch for base
0001-Add-extra-Num-constraints-since-the-Num-superclass-o.patch (1.8 KB) - added by basvandijk 8 years ago.
Patch for ghc

Download all attachments as: .zip

Change History (5)

Changed 8 years ago by basvandijk

Patch for base

Changed 8 years ago by basvandijk

Patch for ghc

comment:1 Changed 8 years ago by igloo

Milestone: 7.6.1
Status: newpatch

comment:2 Changed 8 years ago by igloo

difficulty: Unknown
Resolution: fixed
Status: patchclosed

Thanks, applied:

commit f99cee0118c6bbcd0283ea795a3bb6ff6090b5b5
Author: Bas van Dijk <v.dijk.bas@gmail.com>
Date:   Sat Oct 29 03:33:08 2011 +0200

    Remove Num superclass of Bits Add and export bitDefault, testBitDefault and
popCountDefault from Data.Bits.

commit 804108f0c0fbc2c5f926e4cb4d30b3891443a079

Author: Bas van Dijk <v.dijk.bas@gmail.com>
Date:   Sat Oct 29 03:38:07 2011 +0200

    Add extra Num constraints since the Num superclass of Bits is removed

comment:3 Changed 5 years ago by hvr

Cc: hvr ekmett added
Keywords: report-impact added
Note: See TracTickets for help on using tickets.