{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

{-# HLINT ignore "Use camelCase" #-}
module Cardano.Ledger.CanonicalState.Namespace.GovCommittee.V0.CDDL where

import Cardano.Ledger.CanonicalState.Namespace.CDDL.Common
import Codec.CBOR.Cuddle.Huddle
import Data.Function (($))
import Text.Heredoc (str)

record_entry :: Rule
record_entry :: Rule
record_entry =
  Comment -> Rule -> Rule
forall a. HasComment a => Comment -> a -> a
comment
    Comment
[str| The key for the namespace
        |
        | ```
        | meta:
        |   endian: be
        |
        | seq:
        |   - id: key
        |     type: gov_committee
        |
        | types:
        |   gov_committee:
        |     seq:
        |       - id: singleton
        |         doc: singleton key with value 0
        |         type: u1
        |         valid: 0
        | ```
        |]
    (Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Name
"record_entry" Name -> Choice Type2 -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= Rule
committee Rule -> Value Void -> Choice Type2
forall a c b.
(IsChoosable a c, IsChoosable b c) =>
a -> b -> Choice c
/ Value Void
VNil

committee :: Rule
committee :: Rule
committee =
  Comment -> Rule -> Rule
forall a. HasComment a => Comment -> a -> a
comment
    Comment
[str| Storage of the committee members
        |]
    (Rule -> Rule) -> Rule -> Rule
forall a b. (a -> b) -> a -> b
$ Name
"committee"
      Name -> ArrayChoice -> Rule
forall a. IsType0 a => Name -> a -> Rule
=:= ArrayChoice -> ArrayChoice
arr
        [ MapChoice -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a (MapChoice -> MapChoice
mp [Word64
0 Word64 -> MapEntry -> MapEntry
forall a. CanQuantify a => Word64 -> a -> a
<+ Rule -> Key
forall r. IsType0 r => r -> Key
asKey Rule
credential Key -> Rule -> MapEntry
forall a me. (IsType0 a, IsEntryLike me) => Key -> a -> me
==> Rule
epoch_no])
        , Rule -> ArrayEntry
forall a e. (IsType0 a, IsGroupOrArrayEntry e) => a -> e
a Rule
unit_interval
        ]