Re: Proposal: Determining whether a Bits instance is FiniteBits
Carter Schonwald <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.libraries |
|---|---|
| Message-ID | <CAHYVw0z4WzWP-PJSkx-UxwcMtO2fuLZw_pz4X6CZdL6GLwNdow@mail.gmail.com> |
What would the final / eventual instance be defined as? Or do you mean that would be a default stub so code doesn’t crash immediately on upgrade if it doesn’t have a definition? On Tue, May 18, 2021 at 12:30 PM Zemyla <[email protected]> wrote: > Every Bits instance has to know that whether it's a FiniteBits > instance as well, due to bitSizeMaybe. Therefore, it should also be > able to tell a program that it is in fact a FiniteBits instance. There > should be a function added to Data.Bits.Bits: > > withFiniteBits :: Bits a => a -> (FiniteBits a => r) -> r -> r > > The default should be withFiniteBits _ _ x = x, at least for the next > several versions. bitSizeMaybe can be defined as > > bitSizeMaybe x = withFiniteBits x (Just (finiteBitSize x)) Nothing > > once everyone is on board with properly defining the value. > _______________________________________________ > Libraries mailing list > [email protected] > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > _______________________________________________ Libraries mailing list [email protected] http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries