cardano-ledger-core-1.23.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellNone
LanguageHaskell2010

Cardano.Ledger.Huddle.Gen

Synopsis

MonadGen

Custom core

Term generators

data Term Source #

A general CBOR term, which can be used to serialise or deserialise arbitrary CBOR terms for interoperability or debugging. This type is essentially a direct reflection of the CBOR abstract syntax tree as a Haskell data type.

The Term type also comes with a Serialise instance, so you can easily use decode :: Decoder Term to directly decode any arbitrary CBOR value into Haskell with ease, and likewise with encode.

Since: cborg-0.2.0.0

Instances

Instances details
EncCBOR Term 
Instance details

Defined in Cardano.Ledger.Binary.Encoding.EncCBOR

Methods

encCBOR ∷ Term → Encoding Source #

Read Term 
Instance details

Defined in Codec.CBOR.Term

Show Term 
Instance details

Defined in Codec.CBOR.Term

Methods

showsPrec ∷ Int → Term → ShowS #

show ∷ Term → String #

showList ∷ [Term] → ShowS #

Eq Term 
Instance details

Defined in Codec.CBOR.Term

Methods

(==) ∷ Term → Term → Bool #

(/=) ∷ Term → Term → Bool #

Ord Term 
Instance details

Defined in Codec.CBOR.Term

Methods

compare ∷ Term → Term → Ordering #

(<) ∷ Term → Term → Bool #

(<=) ∷ Term → Term → Bool #

(>) ∷ Term → Term → Bool #

(>=) ∷ Term → Term → Bool #

max ∷ Term → Term → Term #

min ∷ Term → Term → Term #

data RuleTerm Source #

Instances

Instances details
Show RuleTerm 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Custom.Core

Methods

showsPrec ∷ Int → RuleTerm → ShowS #

show ∷ RuleTerm → String #

showList ∷ [RuleTerm] → ShowS #

Eq RuleTerm 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Custom.Core

Methods

(==) ∷ RuleTerm → RuleTerm → Bool #

(/=) ∷ RuleTerm → RuleTerm → Bool #

Ord RuleTerm 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Custom.Core

newtype Name Source #

A name can consist of any of the characters from the set {A to Z, "a" to "z", "0" to "9", "_", "-", "", ".", "$"}, starting with an alphabetic character (including "", "_", "$") and ending in such a character or a digit.

  • Names are case sensitive.
  • It is preferred style to start a name with a lowercase letter.
  • The hyphen is preferred over the underscore (except in a "bareword" (Section 3.5.1), where the semantics may actually require an underscore).
  • The period may be useful for larger specifications, to express some module structure (as in "tcp.throughput" vs. "udp.throughput").
  • A number of names are predefined in the CDDL prelude, as listed in Appendix D.
  • Rule names (types or groups) do not appear in the actual CBOR encoding, but names used as "barewords" in member keys do.

Constructors

Name 

Fields

Instances

Instances details
HasName Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

getName ∷ Name → Name Source #

CollectComments Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Monoid Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

mempty ∷ Name #

mappend ∷ Name → Name → Name #

mconcat ∷ [Name] → Name #

Semigroup Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

(<>) ∷ Name → Name → Name #

sconcat ∷ NonEmpty Name → Name #

stimes ∷ Integral b ⇒ b → Name → Name #

IsString Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

fromString ∷ String → Name #

Generic Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Associated Types

type Rep Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

type Rep Name = D1 ('MetaData "Name" "Codec.CBOR.Cuddle.CDDL" "cuddle-1.8.1.0-6d6f49035376ff1b66823530ccf8d05eb564893857346e360bb08bd8c384b020" 'True) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "unName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Methods

from ∷ Name → Rep Name x #

to ∷ Rep Name x → Name #

Show Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

showsPrec ∷ Int → Name → ShowS #

show ∷ Name → String #

showList ∷ [Name] → ShowS #

Eq Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

(==) ∷ Name → Name → Bool #

(/=) ∷ Name → Name → Bool #

Ord Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

compare ∷ Name → Name → Ordering #

(<) ∷ Name → Name → Bool #

(<=) ∷ Name → Name → Bool #

(>) ∷ Name → Name → Bool #

(>=) ∷ Name → Name → Bool #

max ∷ Name → Name → Name #

min ∷ Name → Name → Name #

Hashable Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

Methods

hashWithSalt ∷ Int → Name → Int Source #

hash ∷ Name → Int Source #

Pretty Name 
Instance details

Defined in Codec.CBOR.Cuddle.Pretty

Methods

pretty ∷ Name → Doc ann Source #

prettyList ∷ [Name] → Doc ann Source #

HasSink "synth" MonoState MonoM 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Resolve

Methods

yield_ ∷ Proxy# "synth" → MonoState → MonoM () Source #

HasSource "synth" MonoState MonoM 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Resolve

Methods

await_ ∷ Proxy# "synth" → MonoM MonoState Source #

HasState "synth" MonoState MonoM 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Resolve

Methods

state_ ∷ Proxy# "synth" → (MonoState → (a, MonoState)) → MonoM a Source #

HasReader "global" (Map Name (ProvidedParameters (CTree DistReferenced))) MonoM 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Resolve

Methods

local_ ∷ Proxy# "global" → (Map Name (ProvidedParameters (CTree DistReferenced)) → Map Name (ProvidedParameters (CTree DistReferenced))) → MonoM a → MonoM a Source #

reader_ ∷ Proxy# "global" → (Map Name (ProvidedParameters (CTree DistReferenced)) → a) → MonoM a Source #

HasReader "local" (Map Name (CTree MonoReferenced)) MonoM 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Resolve

Methods

local_ ∷ Proxy# "local" → (Map Name (CTree MonoReferenced) → Map Name (CTree MonoReferenced)) → MonoM a → MonoM a Source #

reader_ ∷ Proxy# "local" → (Map Name (CTree MonoReferenced) → a) → MonoM a Source #

HasSource "global" (Map Name (ProvidedParameters (CTree DistReferenced))) MonoM 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Resolve

Methods

await_ ∷ Proxy# "global" → MonoM (Map Name (ProvidedParameters (CTree DistReferenced))) Source #

HasSource "local" (Map Name (CTree MonoReferenced)) MonoM 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL.Resolve

Methods

await_ ∷ Proxy# "local" → MonoM (Map Name (CTree MonoReferenced)) Source #

type Rep Name 
Instance details

Defined in Codec.CBOR.Cuddle.CDDL

type Rep Name = D1 ('MetaData "Name" "Codec.CBOR.Cuddle.CDDL" "cuddle-1.8.1.0-6d6f49035376ff1b66823530ccf8d05eb564893857346e360bb08bd8c384b020" 'True) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "unName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

genRule ∷ ∀ (rule ∷ Symbol) era. HuddleRule rule era ⇒ CBORGen Term Source #

A function for generating a term from a rule. The HuddleRule constraint ensures that the rule is actually defined in that era.

generateFromName ∷ HasCallStack ⇒ Name → CBORGen Term Source #

Generate a CBOR Term corresponding to a top-level name.

Since we apply this to a monomorphised CTree, the names must be monomorphic terms in the original CDDL.

This will throw an error if the generated item does not correspond to a single CBOR term (e.g. if the name resolves to a group, which cannot be generated outside a context).

generateFromGRef ∷ HasCallStack ⇒ GRef → CBORGen RuleTerm Source #

Generate a RuleTerm for the type bound to the given generic parameter at the enclosing rule. Use this from inside a custom generator attached to a generic rule.

Term validators

validateFromName ∷ HasCallStack ⇒ Name → Term → Validator () Source #

Validate a CBOR Term against a top-level rule from inside a custom validator.

validateFromGRef ∷ HasCallStack ⇒ GRef → Term → Validator () Source #

Validate a CBOR Term against the type bound to the given generic parameter at the enclosing rule. Use this from inside a custom validator attached to a generic rule.

Lifted generators

arbitrary ∷ ∀ a m. (MonadGen m, Arbitrary a) ⇒ m a Source #

scale ∷ MonadGen m ⇒ (Int → Int) → m a → m a Source #

shuffle ∷ MonadGen m ⇒ [a] → m [a] Source #

Antigen

antiVectorOfUnique ∷ Eq a ⇒ Int → AntiGen a → AntiGen (Maybe [a]) Source #

Generate a list of n pairwise-distinct elements. Returns Nothing if the underlying generator could not produce enough distinct elements within the per-element retry budget.

antiVectorOfUniqueBy ∷ (a → a → Bool) → Int → AntiGen a → AntiGen (Maybe [a]) Source #

Like antiVectorOfUnique, but takes a user-supplied equivalence relation.

antiVectorOfUniqueOn ∷ Eq b ⇒ (a → b) → Int → AntiGen a → AntiGen (Maybe [a]) Source #

Like antiVectorOfUnique, but compares elements by a key projection.