[GHC] #9816: Add function for size-checked conversion of Integral types
GHC
ghc-devs at haskell.org
Thu Nov 20 21:12:56 UTC 2014
#9816: Add function for size-checked conversion of Integral types
-------------------------------------+-------------------------------------
Reporter: spl | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 7.9
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure:
Blocked By: | None/Unknown
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Based on the discussion in
[http://thread.gmane.org/gmane.comp.lang.haskell.libraries/23338 this
thread], I would like to add a function to the {{{base}}} library that is
similar to {{{fromIntegral}}} but only successful if the argument fits in
the result type.
If possible, I would like to get this into 7.10. My apologies for running
late on it. Hopefully, since it is a relatively small change overall, the
"only" controversy will be bikeshedding.
I have concluded that adding @hvr's {{{intCastMaybe}}} from
[http://hackage.haskell.org/package/int-cast int-cast] is the best
possible option. Previously, I thought a {{{Bounded}}}-based version was
also useful; however, I realized that it did not deal properly with
conversions like {{{Int<->Word}}}/{{{Int8<->Word8}}}/etc. as well as
{{{intCastMaybe}}} and would need specialized versions that
{{{intCastMaybe}}} provides automatically.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9816>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list