summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Builtin/Names.hs5
-rw-r--r--libraries/base/Data/Data.hs3
-rw-r--r--libraries/base/Data/Void.hs68
-rw-r--r--libraries/base/GHC/Base.hs38
-rw-r--r--libraries/base/GHC/Exception/Type.hs3
-rw-r--r--libraries/base/GHC/Generics.hs5
-rw-r--r--libraries/base/GHC/Ix.hs8
-rw-r--r--libraries/base/GHC/Read.hs6
-rw-r--r--libraries/base/GHC/Show.hs3
9 files changed, 69 insertions, 70 deletions
diff --git a/compiler/GHC/Builtin/Names.hs b/compiler/GHC/Builtin/Names.hs
index a9802e3e95..acc402b4a3 100644
--- a/compiler/GHC/Builtin/Names.hs
+++ b/compiler/GHC/Builtin/Names.hs
@@ -547,7 +547,7 @@ gHC_PRIM, gHC_PRIM_PANIC,
gHC_GHCI, gHC_GHCI_HELPERS, gHC_CSTRING,
gHC_SHOW, gHC_READ, gHC_NUM, gHC_MAYBE,
gHC_NUM_INTEGER, gHC_NUM_NATURAL, gHC_NUM_BIGNAT,
- gHC_LIST, gHC_TUPLE, gHC_TUPLE_PRIM, dATA_EITHER, dATA_VOID, dATA_LIST, dATA_STRING,
+ gHC_LIST, gHC_TUPLE, gHC_TUPLE_PRIM, dATA_EITHER, dATA_LIST, dATA_STRING,
dATA_FOLDABLE, dATA_TRAVERSABLE,
gHC_CONC, gHC_IO, gHC_IO_Exception,
gHC_ST, gHC_IX, gHC_STABLE, gHC_PTR, gHC_ERR, gHC_REAL,
@@ -583,7 +583,6 @@ gHC_LIST = mkBaseModule (fsLit "GHC.List")
gHC_TUPLE = mkPrimModule (fsLit "GHC.Tuple")
gHC_TUPLE_PRIM = mkPrimModule (fsLit "GHC.Tuple.Prim")
dATA_EITHER = mkBaseModule (fsLit "Data.Either")
-dATA_VOID = mkBaseModule (fsLit "Data.Void")
dATA_LIST = mkBaseModule (fsLit "Data.List")
dATA_STRING = mkBaseModule (fsLit "Data.String")
dATA_FOLDABLE = mkBaseModule (fsLit "Data.Foldable")
@@ -964,7 +963,7 @@ leftDataConName = dcQual dATA_EITHER (fsLit "Left") leftDataConKey
rightDataConName = dcQual dATA_EITHER (fsLit "Right") rightDataConKey
voidTyConName :: Name
-voidTyConName = tcQual dATA_VOID (fsLit "Void") voidTyConKey
+voidTyConName = tcQual gHC_BASE (fsLit "Void") voidTyConKey
-- Generics (types)
v1TyConName, u1TyConName, par1TyConName, rec1TyConName,
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)
diff --git a/libraries/base/GHC/Base.hs b/libraries/base/GHC/Base.hs
index 6cc195d362..ca815f246d 100644
--- a/libraries/base/GHC/Base.hs
+++ b/libraries/base/GHC/Base.hs
@@ -65,6 +65,8 @@ Other Prelude modules are much easier with fewer complex dependencies.
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE EmptyCase #-}
+{-# LANGUAGE EmptyDataDeriving #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE NoImplicitPrelude #-}
@@ -199,6 +201,37 @@ build = errorWithoutStackTrace "urk"
foldr = errorWithoutStackTrace "urk"
#endif
+-- | Uninhabited data type
+--
+-- @since 4.8.0.0
+data Void deriving
+ ( Eq -- ^ @since 4.8.0.0
+ , Ord -- ^ @since 4.8.0.0
+ )
+
+-- | 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
+
infixr 6 <>
-- | The class of semigroups (types with an associative binary operation).
@@ -328,6 +361,11 @@ instance Monoid [a] where
mconcat xss = [x | xs <- xss, x <- xs]
-- See Note: [List comprehensions and inlining]
+-- | @since 4.9.0.0
+instance Semigroup Void where
+ a <> _ = a
+ stimes _ a = a
+
{-
Note: [List comprehensions and inlining]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/libraries/base/GHC/Exception/Type.hs b/libraries/base/GHC/Exception/Type.hs
index 642e1a9889..7f915b0c5a 100644
--- a/libraries/base/GHC/Exception/Type.hs
+++ b/libraries/base/GHC/Exception/Type.hs
@@ -143,6 +143,9 @@ class (Typeable e, Show e) => Exception e where
displayException :: e -> String
displayException = show
+-- | @since 4.8.0.0
+instance Exception Void
+
-- | @since 3.0
instance Exception SomeException where
toException se = se
diff --git a/libraries/base/GHC/Generics.hs b/libraries/base/GHC/Generics.hs
index 66ee8ba300..d020bc7b32 100644
--- a/libraries/base/GHC/Generics.hs
+++ b/libraries/base/GHC/Generics.hs
@@ -746,7 +746,7 @@ import GHC.Types
import GHC.Ix ( Ix )
import GHC.Base ( Alternative(..), Applicative(..), Functor(..)
, Monad(..), MonadPlus(..), NonEmpty(..), String, coerce
- , Semigroup(..), Monoid(..) )
+ , Semigroup(..), Monoid(..), Void )
import GHC.Classes ( Eq(..), Ord(..) )
import GHC.Enum ( Bounded, Enum )
import GHC.Read ( Read(..) )
@@ -1553,6 +1553,9 @@ data Meta = MetaData Symbol Symbol Symbol Bool
-- Derived instances
--------------------------------------------------------------------------------
+-- | @since 4.8.0.0
+deriving instance Generic Void
+
-- | @since 4.6.0.0
deriving instance Generic [a]
diff --git a/libraries/base/GHC/Ix.hs b/libraries/base/GHC/Ix.hs
index abbe62c2f1..27cd703e42 100644
--- a/libraries/base/GHC/Ix.hs
+++ b/libraries/base/GHC/Ix.hs
@@ -273,6 +273,14 @@ instance Ix Ordering where -- as derived
inRange (l,u) i = fromEnum i >= fromEnum l && fromEnum i <= fromEnum u
----------------------------------------------------------------------
+-- | @since 4.8.0.0
+instance Ix Void where
+ range _ = []
+ index _ = absurd
+ inRange _ = absurd
+ rangeSize _ = 0
+
+----------------------------------------------------------------------
-- | @since 2.01
instance Ix () where
{-# INLINE range #-}
diff --git a/libraries/base/GHC/Read.hs b/libraries/base/GHC/Read.hs
index 2c9aec08cd..75ccb0c5da 100644
--- a/libraries/base/GHC/Read.hs
+++ b/libraries/base/GHC/Read.hs
@@ -656,6 +656,12 @@ instance (Integral a, Read a) => Read (Ratio a) where
-- Tuple instances of Read, up to size 15
------------------------------------------------------------------------
+-- | Reading a 'Void' value is always a parse error, considering
+-- 'Void' as a data type with no constructors.
+--
+-- @since 4.8.0.0
+deriving instance Read Void
+
-- | @since 2.01
instance Read () where
readPrec =
diff --git a/libraries/base/GHC/Show.hs b/libraries/base/GHC/Show.hs
index 04fbcb6112..0d3f1a926d 100644
--- a/libraries/base/GHC/Show.hs
+++ b/libraries/base/GHC/Show.hs
@@ -165,6 +165,9 @@ appPrec1 = I# 11# -- appPrec + 1
-- Simple Instances
--------------------------------------------------------------
+-- | @since 4.8.0.0
+deriving instance Show Void
+
-- | @since 2.01
deriving instance Show ()