Brandon Chinn pushed to branch wip/T26961 at Glasgow Haskell Compiler / GHC
Commits:
-
8bfdd5a8
by Brandon Chinn at 2026-02-25T08:59:16-08:00
-
28a74652
by Brandon Chinn at 2026-02-25T08:59:26-08:00
3 changed files:
Changes:
| ... | ... | @@ -111,6 +111,7 @@ Library |
| 111 | 111 | , Data.Monoid
|
| 112 | 112 | , Data.Ord
|
| 113 | 113 | , Data.Proxy
|
| 114 | + , Data.RealFloat
|
|
| 114 | 115 | , Data.STRef
|
| 115 | 116 | , Data.STRef.Strict
|
| 116 | 117 | , Data.String
|
| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | * Add `Data.List.NonEmpty.mapMaybe`. ([CLC proposal #337](https://github.com/haskell/core-libraries-committee/issues/337))
|
| 10 | 10 | * Fix issues with toRational for types capable to represent infinite and not-a-number values ([CLC proposal #338](https://github.com/haskell/core-libraries-committee/issues/338))
|
| 11 | 11 | * Ensure that `rationalToFloat` and `rationalToDouble` always inline in the end. ([CLC proposal #356](https://github.com/haskell/core-libraries-committee/issues/356))
|
| 12 | + * Add new `Data.RealFloat` module re-exporting `RealFloat` operations from `GHC.Float`
|
|
| 13 | + * Add `Infinity`, `NegInfinity`, and `NaN` pattern synonyms to `Data.RealFloat`
|
|
| 12 | 14 | * Modify the implementation of `Data.List.sortOn` to use `(>)` instead of `compare`. ([CLC proposal #332](https://github.com/haskell/core-libraries-committee/issues/332))
|
| 13 | 15 | * Add `thenA` and `thenM`. ([CLC proposal #351](https://github.com/haskell/core-libraries-committee/issues/351))
|
| 14 | 16 | * Fix bug where `naturalAndNot` was incorrectly truncating results ([CLC proposal #350](github.com/haskell/core-libraries-committee/issues/350))
|
| 1 | +{-# LANGUAGE PatternSynonyms #-}
|
|
| 2 | +{-# LANGUAGE Safe #-}
|
|
| 3 | +{-# LANGUAGE ViewPatterns #-}
|
|
| 4 | + |
|
| 5 | +-- |
|
|
| 6 | +--
|
|
| 7 | +-- Module : Data.RealFloat
|
|
| 8 | +-- Copyright : (c) The University of Glasgow 2026
|
|
| 9 | +-- License : BSD-style (see the file libraries/base/LICENSE)
|
|
| 10 | +--
|
|
| 11 | +-- Maintainer : libraries@haskell.org
|
|
| 12 | +-- Stability : stable
|
|
| 13 | +-- Portability : portable
|
|
| 14 | +--
|
|
| 15 | + |
|
| 16 | +module Data.RealFloat (
|
|
| 17 | + RealFloat (..),
|
|
| 18 | + |
|
| 19 | + -- * Infinity + NaN
|
|
| 20 | + pattern Infinity,
|
|
| 21 | + pattern NegInfinity,
|
|
| 22 | + pattern NaN,
|
|
| 23 | +) where
|
|
| 24 | + |
|
| 25 | +import GHC.Internal.Float
|
|
| 26 | + |
|
| 27 | +pattern Infinity :: (RealFloat a) => a
|
|
| 28 | +pattern Infinity <- ((\x -> isInfinite x && x > 0) -> True) where Infinity = 1/0
|
|
| 29 | + |
|
| 30 | +-- | Negative infinity
|
|
| 31 | +--
|
|
| 32 | +-- Provided for convenience. Could also use the following instead:
|
|
| 33 | +-- * Pattern matching: @(negate -> Infinity)@
|
|
| 34 | +-- * Expressions: @-Infinity@
|
|
| 35 | +pattern NegInfinity :: (RealFloat a) => a
|
|
| 36 | +pattern NegInfinity <- ((\x -> isInfinite x && x < 0) -> True) where NegInfinity = -1/0
|
|
| 37 | + |
|
| 38 | +pattern NaN :: (RealFloat a) => a
|
|
| 39 | +pattern NaN <- (isNaN -> True) where NaN = 0/0 |