{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}

module Codec.CBOR.Cuddle.CDDL.CtlOp where

import Data.Hashable (Hashable)
import Data.TreeDiff (ToExpr)
import GHC.Generics (Generic)

-- | A _control_ allows relating a _target_ type with a _controller_ type
--  via a _control operator_.

--  The syntax for a control type is "target .control-operator
--  controller", where control operators are special identifiers prefixed
--  by a dot.  (Note that _target_ or _controller_ might need to be
--  parenthesized.)

--  A number of control operators are defined at this point.  Further
--  control operators may be defined by new versions of this
--  specification or by registering them according to the procedures in
--  Section 6.1.
data CtlOp
  = Size
  | Bits
  | Regexp
  | Cbor
  | Cborseq
  | Within
  | And
  | Lt
  | Le
  | Gt
  | Ge
  | Eq
  | Ne
  | Default
  deriving (CtlOp -> CtlOp -> Bool
(CtlOp -> CtlOp -> Bool) -> (CtlOp -> CtlOp -> Bool) -> Eq CtlOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CtlOp -> CtlOp -> Bool
== :: CtlOp -> CtlOp -> Bool
$c/= :: CtlOp -> CtlOp -> Bool
/= :: CtlOp -> CtlOp -> Bool
Eq, (forall x. CtlOp -> Rep CtlOp x)
-> (forall x. Rep CtlOp x -> CtlOp) -> Generic CtlOp
forall x. Rep CtlOp x -> CtlOp
forall x. CtlOp -> Rep CtlOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CtlOp -> Rep CtlOp x
from :: forall x. CtlOp -> Rep CtlOp x
$cto :: forall x. Rep CtlOp x -> CtlOp
to :: forall x. Rep CtlOp x -> CtlOp
Generic, Int -> CtlOp -> ShowS
[CtlOp] -> ShowS
CtlOp -> String
(Int -> CtlOp -> ShowS)
-> (CtlOp -> String) -> ([CtlOp] -> ShowS) -> Show CtlOp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CtlOp -> ShowS
showsPrec :: Int -> CtlOp -> ShowS
$cshow :: CtlOp -> String
show :: CtlOp -> String
$cshowList :: [CtlOp] -> ShowS
showList :: [CtlOp] -> ShowS
Show)
  deriving anyclass ([CtlOp] -> Expr
CtlOp -> Expr
(CtlOp -> Expr) -> ([CtlOp] -> Expr) -> ToExpr CtlOp
forall a. (a -> Expr) -> ([a] -> Expr) -> ToExpr a
$ctoExpr :: CtlOp -> Expr
toExpr :: CtlOp -> Expr
$clistToExpr :: [CtlOp] -> Expr
listToExpr :: [CtlOp] -> Expr
ToExpr)

instance Hashable CtlOp