<div dir="ltr">This does seem like a strict improvement over the status quo.<div><br></div><div>Users can then conditionally get access to count(Trailing|Leading)Zeros by refining the type information available to them using this combinator, which offers a bunch of bit twiddling usecases.</div><div><br></div><div>-Edward</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 18, 2021 at 9:30 AM Zemyla <<a href="mailto:zemyla@gmail.com">zemyla@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Every Bits instance has to know that whether it's a FiniteBits<br>
instance as well, due to bitSizeMaybe. Therefore, it should also be<br>
able to tell a program that it is in fact a FiniteBits instance. There<br>
should be a function added to Data.Bits.Bits:<br>
<br>
withFiniteBits :: Bits a => a -> (FiniteBits a => r) -> r -> r<br>
<br>
The default should be withFiniteBits _ _ x = x, at least for the next<br>
several versions. bitSizeMaybe can be defined as<br>
<br>
bitSizeMaybe x = withFiniteBits x (Just (finiteBitSize x)) Nothing<br>
<br>
once everyone is on board with properly defining the value.<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>