{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}

module Zuul.Nodeset (Nodeset (..), Node (..)) where

import Data.Aeson (FromJSON (..), ToJSON (..))
import Data.Text (Text)
import GHC.Generics (Generic)
import Zuul.Aeson (zuulParseJSON, zuulToJSON)

data Node = Node
  { Node -> Text
nodeName :: Text,
    Node -> Text
nodeLabel :: Text
  }
  deriving (Int -> Node -> ShowS
[Node] -> ShowS
Node -> String
(Int -> Node -> ShowS)
-> (Node -> String) -> ([Node] -> ShowS) -> Show Node
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Node] -> ShowS
$cshowList :: [Node] -> ShowS
show :: Node -> String
$cshow :: Node -> String
showsPrec :: Int -> Node -> ShowS
$cshowsPrec :: Int -> Node -> ShowS
Show, Node -> Node -> Bool
(Node -> Node -> Bool) -> (Node -> Node -> Bool) -> Eq Node
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Node -> Node -> Bool
$c/= :: Node -> Node -> Bool
== :: Node -> Node -> Bool
$c== :: Node -> Node -> Bool
Eq, Eq Node
Eq Node
-> (Node -> Node -> Ordering)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Bool)
-> (Node -> Node -> Node)
-> (Node -> Node -> Node)
-> Ord Node
Node -> Node -> Bool
Node -> Node -> Ordering
Node -> Node -> Node
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Node -> Node -> Node
$cmin :: Node -> Node -> Node
max :: Node -> Node -> Node
$cmax :: Node -> Node -> Node
>= :: Node -> Node -> Bool
$c>= :: Node -> Node -> Bool
> :: Node -> Node -> Bool
$c> :: Node -> Node -> Bool
<= :: Node -> Node -> Bool
$c<= :: Node -> Node -> Bool
< :: Node -> Node -> Bool
$c< :: Node -> Node -> Bool
compare :: Node -> Node -> Ordering
$ccompare :: Node -> Node -> Ordering
$cp1Ord :: Eq Node
Ord, (forall x. Node -> Rep Node x)
-> (forall x. Rep Node x -> Node) -> Generic Node
forall x. Rep Node x -> Node
forall x. Node -> Rep Node x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Node x -> Node
$cfrom :: forall x. Node -> Rep Node x
Generic)

data Nodeset = Nodeset
  { Nodeset -> Text
nodesetName :: Text,
    Nodeset -> [Node]
nodesetNodes :: [Node]
  }
  deriving (Int -> Nodeset -> ShowS
[Nodeset] -> ShowS
Nodeset -> String
(Int -> Nodeset -> ShowS)
-> (Nodeset -> String) -> ([Nodeset] -> ShowS) -> Show Nodeset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Nodeset] -> ShowS
$cshowList :: [Nodeset] -> ShowS
show :: Nodeset -> String
$cshow :: Nodeset -> String
showsPrec :: Int -> Nodeset -> ShowS
$cshowsPrec :: Int -> Nodeset -> ShowS
Show, Nodeset -> Nodeset -> Bool
(Nodeset -> Nodeset -> Bool)
-> (Nodeset -> Nodeset -> Bool) -> Eq Nodeset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Nodeset -> Nodeset -> Bool
$c/= :: Nodeset -> Nodeset -> Bool
== :: Nodeset -> Nodeset -> Bool
$c== :: Nodeset -> Nodeset -> Bool
Eq, Eq Nodeset
Eq Nodeset
-> (Nodeset -> Nodeset -> Ordering)
-> (Nodeset -> Nodeset -> Bool)
-> (Nodeset -> Nodeset -> Bool)
-> (Nodeset -> Nodeset -> Bool)
-> (Nodeset -> Nodeset -> Bool)
-> (Nodeset -> Nodeset -> Nodeset)
-> (Nodeset -> Nodeset -> Nodeset)
-> Ord Nodeset
Nodeset -> Nodeset -> Bool
Nodeset -> Nodeset -> Ordering
Nodeset -> Nodeset -> Nodeset
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Nodeset -> Nodeset -> Nodeset
$cmin :: Nodeset -> Nodeset -> Nodeset
max :: Nodeset -> Nodeset -> Nodeset
$cmax :: Nodeset -> Nodeset -> Nodeset
>= :: Nodeset -> Nodeset -> Bool
$c>= :: Nodeset -> Nodeset -> Bool
> :: Nodeset -> Nodeset -> Bool
$c> :: Nodeset -> Nodeset -> Bool
<= :: Nodeset -> Nodeset -> Bool
$c<= :: Nodeset -> Nodeset -> Bool
< :: Nodeset -> Nodeset -> Bool
$c< :: Nodeset -> Nodeset -> Bool
compare :: Nodeset -> Nodeset -> Ordering
$ccompare :: Nodeset -> Nodeset -> Ordering
$cp1Ord :: Eq Nodeset
Ord, (forall x. Nodeset -> Rep Nodeset x)
-> (forall x. Rep Nodeset x -> Nodeset) -> Generic Nodeset
forall x. Rep Nodeset x -> Nodeset
forall x. Nodeset -> Rep Nodeset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Nodeset x -> Nodeset
$cfrom :: forall x. Nodeset -> Rep Nodeset x
Generic)

instance ToJSON Node where
  toJSON :: Node -> Value
toJSON = Text -> Node -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Text -> a -> Value
zuulToJSON Text
"node"

instance FromJSON Node where
  parseJSON :: Value -> Parser Node
parseJSON = Text -> Value -> Parser Node
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Text -> Value -> Parser a
zuulParseJSON Text
"node"

instance ToJSON Nodeset where
  toJSON :: Nodeset -> Value
toJSON = Text -> Nodeset -> Value
forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Text -> a -> Value
zuulToJSON Text
"nodeset"

instance FromJSON Nodeset where
  parseJSON :: Value -> Parser Nodeset
parseJSON = Text -> Value -> Parser Nodeset
forall a.
(Generic a, GFromJSON Zero (Rep a)) =>
Text -> Value -> Parser a
zuulParseJSON Text
"nodeset"