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

#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

#9816: Add function for size-checked conversion of Integral types -------------------------------------+------------------------------------- Reporter: spl | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.9 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by spl): Phab diff coming momentarily, I hope. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9816#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: | Keywords: libraries/base | 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 | -------------------------------------+------------------------------------- Changes (by spl): * status: new => patch * differential: => D512 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9816#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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 | -------------------------------------+------------------------------------- Changes (by simonpj): * cc: core-libraries-committee@… (added) * component: libraries/base => Core Libraries Comment: We need a ruling from the Core Libraries Committee. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9816#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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 |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#9816: Add function for size-checked conversion of Integral types -------------------------------------+------------------------------------- Reporter: spl | Owner: Type: feature | Status: closed request | Milestone: 7.10.1 Priority: normal | Version: 7.9 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: fixed | Difficulty: Unknown Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | Differential Revisions: D512 | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => closed * resolution: => fixed * milestone: => 7.10.1 Comment: Merged, thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9816#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC