{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
module Ouroboros.Consensus.Block.EBB (
IsEBB (..)
, fromIsEBB
, toIsEBB
) where
import Codec.Serialise (Serialise (..))
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Ouroboros.Consensus.Util.Condense
data IsEBB
= IsEBB
| IsNotEBB
deriving (IsEBB -> IsEBB -> Bool
(IsEBB -> IsEBB -> Bool) -> (IsEBB -> IsEBB -> Bool) -> Eq IsEBB
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IsEBB -> IsEBB -> Bool
== :: IsEBB -> IsEBB -> Bool
$c/= :: IsEBB -> IsEBB -> Bool
/= :: IsEBB -> IsEBB -> Bool
Eq, Int -> IsEBB -> ShowS
[IsEBB] -> ShowS
IsEBB -> String
(Int -> IsEBB -> ShowS)
-> (IsEBB -> String) -> ([IsEBB] -> ShowS) -> Show IsEBB
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IsEBB -> ShowS
showsPrec :: Int -> IsEBB -> ShowS
$cshow :: IsEBB -> String
show :: IsEBB -> String
$cshowList :: [IsEBB] -> ShowS
showList :: [IsEBB] -> ShowS
Show, (forall x. IsEBB -> Rep IsEBB x)
-> (forall x. Rep IsEBB x -> IsEBB) -> Generic IsEBB
forall x. Rep IsEBB x -> IsEBB
forall x. IsEBB -> Rep IsEBB x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. IsEBB -> Rep IsEBB x
from :: forall x. IsEBB -> Rep IsEBB x
$cto :: forall x. Rep IsEBB x -> IsEBB
to :: forall x. Rep IsEBB x -> IsEBB
Generic, Context -> IsEBB -> IO (Maybe ThunkInfo)
Proxy IsEBB -> String
(Context -> IsEBB -> IO (Maybe ThunkInfo))
-> (Context -> IsEBB -> IO (Maybe ThunkInfo))
-> (Proxy IsEBB -> String)
-> NoThunks IsEBB
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> IsEBB -> IO (Maybe ThunkInfo)
noThunks :: Context -> IsEBB -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> IsEBB -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> IsEBB -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy IsEBB -> String
showTypeOf :: Proxy IsEBB -> String
NoThunks)
instance Serialise IsEBB where
encode :: IsEBB -> Encoding
encode = Bool -> Encoding
forall a. Serialise a => a -> Encoding
encode (Bool -> Encoding) -> (IsEBB -> Bool) -> IsEBB -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsEBB -> Bool
fromIsEBB
decode :: forall s. Decoder s IsEBB
decode = Bool -> IsEBB
toIsEBB (Bool -> IsEBB) -> Decoder s Bool -> Decoder s IsEBB
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decoder s Bool
forall s. Decoder s Bool
forall a s. Serialise a => Decoder s a
decode
instance Condense IsEBB where
condense :: IsEBB -> String
condense = IsEBB -> String
forall a. Show a => a -> String
show
toIsEBB :: Bool -> IsEBB
toIsEBB :: Bool -> IsEBB
toIsEBB Bool
b = if Bool
b then IsEBB
IsEBB else IsEBB
IsNotEBB
fromIsEBB :: IsEBB -> Bool
fromIsEBB :: IsEBB -> Bool
fromIsEBB IsEBB
IsEBB = Bool
True
fromIsEBB IsEBB
IsNotEBB = Bool
False