module Ouroboros.Network.Handshake.Acceptable
  ( Accept (..)
  , Acceptable (..)
  ) where


import Data.Text

-- | A @'Maybe'@ like type which better explains its purpose.
--
data Accept vData
  = Accept vData
  | Refuse !Text
  deriving (Accept vData -> Accept vData -> Bool
(Accept vData -> Accept vData -> Bool)
-> (Accept vData -> Accept vData -> Bool) -> Eq (Accept vData)
forall vData. Eq vData => Accept vData -> Accept vData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall vData. Eq vData => Accept vData -> Accept vData -> Bool
== :: Accept vData -> Accept vData -> Bool
$c/= :: forall vData. Eq vData => Accept vData -> Accept vData -> Bool
/= :: Accept vData -> Accept vData -> Bool
Eq, Int -> Accept vData -> ShowS
[Accept vData] -> ShowS
Accept vData -> String
(Int -> Accept vData -> ShowS)
-> (Accept vData -> String)
-> ([Accept vData] -> ShowS)
-> Show (Accept vData)
forall vData. Show vData => Int -> Accept vData -> ShowS
forall vData. Show vData => [Accept vData] -> ShowS
forall vData. Show vData => Accept vData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall vData. Show vData => Int -> Accept vData -> ShowS
showsPrec :: Int -> Accept vData -> ShowS
$cshow :: forall vData. Show vData => Accept vData -> String
show :: Accept vData -> String
$cshowList :: forall vData. Show vData => [Accept vData] -> ShowS
showList :: [Accept vData] -> ShowS
Show)


class Acceptable v where
  -- | The 'acceptableVersion' function ought to be symmetric, this guarantees
  -- that local and remote sides will agree on the same data.
  acceptableVersion :: v -> v -> Accept v