summaryrefslogtreecommitdiff
path: root/libraries/base/Data
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2022-10-05 18:20:21 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-30 14:51:39 -0500
commit10a2a7de64c52fcff07572bc0cd396393829a487 (patch)
tree0a76a60a850a722850a5c70d399818a8b2e79ab0 /libraries/base/Data
parent31462d98c31e3ef48af2f6c6f2d379d74ccc63f5 (diff)
downloadhaskell-10a2a7de64c52fcff07572bc0cd396393829a487.tar.gz
Move Void to GHC.Base...
This change would allow `Void` to be used deeper in module graph. For example exported from `Prelude` (though that might be already possible). Also this change includes a change `stimes @Void _ x = x`, https://github.com/haskell/core-libraries-committee/issues/95 While the above is not required, maintaining old stimes behavior would be tricky as `GHC.Base` doesn't know about `Num` or `Integral`, which would require more hs-boot files.
Diffstat (limited to 'libraries/base/Data')
-rw-r--r--libraries/base/Data/Data.hs3
-rw-r--r--libraries/base/Data/Void.hs68
2 files changed, 5 insertions, 66 deletions
diff --git a/libraries/base/Data/Data.hs b/libraries/base/Data/Data.hs
index 4ef7d00d03..b6102d4cf3 100644
--- a/libraries/base/Data/Data.hs
+++ b/libraries/base/Data/Data.hs
@@ -1187,6 +1187,9 @@ deriving instance Data Ordering
-- | @since 4.0.0.0
deriving instance (Data a, Data b) => Data (Either a b)
+-- | @since 4.8.0.0
+deriving instance Data Void
+
-- | @since 4.0.0.0
deriving instance Data ()
diff --git a/libraries/base/Data/Void.hs b/libraries/base/Data/Void.hs
index 299b4c78bf..226a9ad994 100644
--- a/libraries/base/Data/Void.hs
+++ b/libraries/base/Data/Void.hs
@@ -1,8 +1,4 @@
-{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE DeriveGeneric #-}
-{-# LANGUAGE EmptyCase #-}
-{-# LANGUAGE EmptyDataDeriving #-}
-{-# LANGUAGE Safe #-}
+{-# LANGUAGE Trustworthy #-}
-----------------------------------------------------------------------------
-- |
@@ -24,64 +20,4 @@ module Data.Void
, vacuous
) where
-import Control.Exception
-import Data.Data
-import Data.Ix
-import GHC.Generics
-import Data.Semigroup (Semigroup(..), stimesIdempotent)
-
--- $setup
--- >>> import Prelude
-
--- | Uninhabited data type
---
--- @since 4.8.0.0
-data Void deriving
- ( Eq -- ^ @since 4.8.0.0
- , Data -- ^ @since 4.8.0.0
- , Generic -- ^ @since 4.8.0.0
- , Ord -- ^ @since 4.8.0.0
- , Read -- ^ Reading a 'Void' value is always a parse error, considering
- -- 'Void' as a data type with no constructors.
- --
- -- @since 4.8.0.0
- , Show -- ^ @since 4.8.0.0
- )
-
--- | @since 4.8.0.0
-instance Ix Void where
- range _ = []
- index _ = absurd
- inRange _ = absurd
- rangeSize _ = 0
-
--- | @since 4.8.0.0
-instance Exception Void
-
--- | @since 4.9.0.0
-instance Semigroup Void where
- a <> _ = a
- stimes = stimesIdempotent
-
--- | Since 'Void' values logically don't exist, this witnesses the
--- logical reasoning tool of \"ex falso quodlibet\".
---
--- >>> let x :: Either Void Int; x = Right 5
--- >>> :{
--- case x of
--- Right r -> r
--- Left l -> absurd l
--- :}
--- 5
---
--- @since 4.8.0.0
-absurd :: Void -> a
-absurd a = case a of {}
-
--- | If 'Void' is uninhabited then any 'Functor' that holds only
--- values of type 'Void' is holding no values.
--- It is implemented in terms of @fmap absurd@.
---
--- @since 4.8.0.0
-vacuous :: Functor f => f Void -> f a
-vacuous = fmap absurd
+import GHC.Base (Void, absurd, vacuous)