module Data.Void
( Void
, absurd
, vacuous
, vacuousM
) where
import Data.Ix
import Control.Monad (liftM)
import Data.Semigroup (Semigroup(..))
#ifdef LANGUAGE_DeriveDataTypeable
import Data.Data
#endif
#if __GLASGOW_HASKELL__ < 700
data Void = Void !Void
#else
newtype Void = Void Void
#endif
deriving
( Show, Read
#ifdef LANGUAGE_DeriveDataTypeable
, Data, Typeable
#endif
)
instance Eq Void where
_ == _ = True
instance Ord Void where
compare _ _ = EQ
absurd :: Void -> a
absurd a = a `seq` spin a where
spin (Void b) = spin b
vacuous :: Functor f => f Void -> f a
vacuous = fmap absurd
vacuousM :: Monad m => m Void -> m a
vacuousM = liftM absurd
instance Semigroup Void where
a <> _ = a
times1p _ a = a
instance Ix Void where
range _ = []
index _ = absurd
inRange _ = absurd
rangeSize _ = 0