{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >=704
{-# LANGUAGE Safe              #-}
#elif __GLASGOW_HASKELL__ >=702
{-# LANGUAGE Trustworthy       #-}
#endif
-- | Absurd i.e. not inhabited types.
module RERE.Absurd (Absurd (..), vacuous) where

import qualified Data.Void as Void

-- | A vendored 'Absurd' from https://hackage.haskell.org/package/boring
--
-- We only need 'Void' instance.
class Absurd a where
    absurd :: a -> b

instance Absurd Void.Void where
    absurd :: Void -> b
absurd = Void -> b
forall b. Void -> b
Void.absurd

-- | @fmap absurd@.
vacuous :: (Functor f, Absurd a) => f a -> f b
vacuous :: f a -> f b
vacuous = (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
forall a b. Absurd a => a -> b
absurd