Deprecating fromIntegral
Mikolaj Konarski
mikolaj at well-typed.com
Thu Aug 13 15:09:23 UTC 2020
This doesn't work when the target type is, e.g., Double (Num, but not
Integral), but thank you for the tip, I've already used it in my code
to fail when wrapping, etc., would occur for integral types.
On Thu, Aug 13, 2020 at 3:10 PM Andrew Lelechenko
<andrew.lelechenko at gmail.com> wrote:
>
> > From: Edward Kmett <ekmett at gmail.com>
> >
> > fromIntegralMaybe :: (Integral a, Num b) => a -> Maybe b
> > fromIntegralMaybe = fromIntegerMaybe . toInteger
>
> I’m late to the party, so might be missing something. Did someone already proposed using http://hackage.haskell.org/package/base-4.14.0.0/docs/Data-Bits.html#v:toIntegralSized, which has a very similar signature?
>
> toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
>
> No need for O(n^2) instances and it is already in `base`.
>
> Best regards,
> Andrew
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
More information about the Libraries
mailing list