{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
{-# OPTIONS_GHC -Wno-unused-imports #-}

-- | 'NoThunks' invariant.
--
-- Due to its expensive nature, this invariant is gated behind the
-- @expensive-invariants@ flag from the @ouroboros-consensus@ package.
module Ouroboros.Consensus.Util.NormalForm.Invariant
  ( -- * Invariant
    noThunksInvariant
  ) where

import NoThunks.Class (NoThunks (..), unsafeNoThunks)

{-------------------------------------------------------------------------------
  Invariant
-------------------------------------------------------------------------------}

noThunksInvariant :: NoThunks a => a -> Maybe String
#ifdef ENABLE_EXPENSIVE_INVARIANTS
noThunksInvariant = fmap show . unsafeNoThunks
#else
noThunksInvariant :: forall a. NoThunks a => a -> Maybe String
noThunksInvariant = Maybe String -> a -> Maybe String
forall a b. a -> b -> a
const Maybe String
forall a. Maybe a
Nothing
#endif