ouroboros-consensus-0.21.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ouroboros.Consensus.Util.Args

Contents

Description

Utilities for arguments record with defaults

Useful for when you want to define a default value of an arguments record consisting of a mix of arguments with/without defaults.

The following code example explains it best:

data Args f = Args {
      hasNoDefault :: HKD f Int
    , hasDefault   :: Bool
    }

defaultArgs :: Incomplete Args
defaultArgs = Args {
      hasNoDefault = noDefault
    , hasDefault   = False
    }

theArgs :: Complete Args
theArgs = defaultArgs {
      hasNoDefault = 0
    }

useArgs :: Complete Args -> (Int, Bool)
useArgs (Args a b) = (a, b)

Leaving out the hasNoDefault field from theArgs will result in a type error.

Synopsis

Documentation

data Defaults t Source #

Constructors

NoDefault 

Instances

Instances details
Functor (DefaultsTypeType) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Args

Methods

fmap ∷ (a → b) → Defaults a → Defaults b #

(<$) ∷ a → Defaults b → Defaults a #

MapHKD (DefaultsTypeType) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Args

Methods

mapHKD ∷ proxy (Defaults b) → (a → b) → HKD Defaults a → HKD Defaults b Source #

type family HKD f a where ... Source #

Equations

HKD Identity a = a 
HKD f a = f a 

class MapHKD f where Source #

Methods

mapHKD ∷ proxy (f b) → (a → b) → HKD f a → HKD f b Source #

Instances

Instances details
MapHKD Identity Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Args

Methods

mapHKD ∷ proxy (Identity b) → (a → b) → HKD Identity a → HKD Identity b Source #

MapHKD (DefaultsTypeType) Source # 
Instance details

Defined in Ouroboros.Consensus.Util.Args

Methods

mapHKD ∷ proxy (Defaults b) → (a → b) → HKD Defaults a → HKD Defaults b Source #

Types

type Complete (args ∷ (TypeType) → k) = args Identity Source #

type Incomplete (args ∷ (TypeType) → k) = args Defaults Source #