summaryrefslogtreecommitdiff
path: root/libraries/base
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base')
-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
8 files changed, 67 insertions, 67 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)
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 ()