[GHC] #9816: Add function for size-checked conversion of Integral types

GHC ghc-devs at haskell.org
Fri Nov 21 06:50:45 UTC 2014


#9816: Add function for size-checked conversion of Integral types
-------------------------------------+-------------------------------------
              Reporter:  spl         |            Owner:
                  Type:  feature     |           Status:  patch
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.9
             Component:  Core        |         Keywords:
  Libraries                          |     Architecture:  Unknown/Multiple
            Resolution:              |       Difficulty:  Unknown
      Operating System:              |       Blocked By:
  Unknown/Multiple                   |  Related Tickets:
       Type of failure:              |
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:  D512        |
-------------------------------------+-------------------------------------
Description changed by spl:

Old description:

> 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.

New description:

 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 optimally with
 conversions like {{{Int<->Word}}}/{{{Int8<->Word8}}}/etc. as well as
 {{{intCastMaybe}}} does and would need specialized versions that
 {{{intCastMaybe}}} provides automatically.

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9816#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list