[GHC] #13203: Implement Bits Natural clearBit

GHC ghc-devs at haskell.org
Tue Oct 3 14:07:18 UTC 2017


#13203: Implement Bits Natural clearBit
-------------------------------------+-------------------------------------
        Reporter:  dylex             |                Owner:  supersven
            Type:  bug               |               Status:  new
        Priority:  lowest            |            Milestone:
       Component:  libraries/base    |              Version:  8.0.2
      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 supersven):

 Hey,

 I did a small experiment to check that GHC.Natural behaves as expected.

 How to reproduce (that `clearBit` doesn't work):
 {{{
 [nix-shell:~/src/ghc]$ inplace/bin/ghc-stage2 --interactive
 GHCi, version 8.3.20170930: http://www.haskell.org/ghc/  :? for help
 Prelude> import GHC.Natural
 Prelude GHC.Natural> import Data.Bits
 Prelude GHC.Natural Data.Bits> clearBit (naturalFromInteger 1) 0
 *** Exception: Bits.complement: Natural complement undefined
 }}}

 `setBit` and `complementBit` work as expected:
 {{{
 Prelude GHC.Natural Data.Bits> setBit (naturalFromInteger 0) 0
 1
 Prelude GHC.Natural Data.Bits> setBit  (naturalFromInteger 1) 0
 1
 Prelude GHC.Natural Data.Bits> complementBit (naturalFromInteger 0) 0
 1
 Prelude GHC.Natural Data.Bits> complementBit (naturalFromInteger 1) 0
 0
 }}}

 == Plan ==
 - Implement `clearBit` as proposed by vlopez.
 - Remove the todo.
 - Add test.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13203#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list