Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,320
    • Issues 4,320
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 359
    • Merge Requests 359
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14839

Closed
Open
Opened Feb 22, 2018 by Andrew Martin@andrewthadDeveloper

Bits typeclass law for LSB

The documentation for the Bits typeclass claims:

Bits are numbered from 0 with bit 0 being the least significant bit.

However, there's no law specified in the typeclass that enforces this. I realized this recently because I've been adding the laws for Bits to a library of property tests I maintain: http://hackage.haskell.org/package/quickcheck-classes-0.3.3/docs/Test-QuickCheck-Classes.html\#v:bitsLaws

In another package of mine, someone requested to add a Bits instance for a type but with the MSB considered bit 0. (https://github.com/andrewthad/haskell-ip/issues/29) I thought this would fail to satisfy a law of Bits, but it doesn't. So at the least, I was thinking we could add the following laws to FiniteBits:

countTrailingZeros (bit 0) = 0
countLeadingZeros (bit 0) = finiteBitSize undefined - 1
Trac metadata
Trac field Value
Version 8.2.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14839