Copyright | (c) 2025 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | [email protected] |
Stability | develop |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Synopsis
- newtype Port = Port {}
- data DnsName
- data Network
- class Bounded r ⇒ BoundedRational r where
- boundRational ∷ Rational → Maybe r
- unboundRational ∷ r → Rational
- data UnitInterval
- data ProtVer = ProtVer {}
- module Cardano.Ledger.Binary.Version
Documentation
Instances
FromJSON Port | |
Defined in Cardano.Ledger.BaseTypes | |
ToJSON Port | |
Generic Port | |
Num Port | |
Show Port | |
DecCBOR Port | |
EncCBOR Port | |
NFData Port | |
Defined in Cardano.Ledger.BaseTypes | |
Eq Port | |
Ord Port | |
NoThunks Port | |
type Rep Port | |
Defined in Cardano.Ledger.BaseTypes type Rep Port = D1 ('MetaData "Port" "Cardano.Ledger.BaseTypes" "cardano-ledger-core-1.15.0.0-1046d1b1904b07389ef0faa5b38408cc4c76b23815c29933c8ff4d80bd3043da" 'True) (C1 ('MetaCons "Port" 'PrefixI 'True) (S1 ('MetaSel ('Just "portToWord16") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word16))) |
Instances
FromJSON DnsName | |
Defined in Cardano.Ledger.BaseTypes | |
ToJSON DnsName | |
Generic DnsName | |
Show DnsName | |
DecCBOR DnsName | |
EncCBOR DnsName | |
NFData DnsName | |
Defined in Cardano.Ledger.BaseTypes | |
Eq DnsName | |
Ord DnsName | |
NoThunks DnsName | |
type Rep DnsName | |
Defined in Cardano.Ledger.BaseTypes type Rep DnsName = D1 ('MetaData "DnsName" "Cardano.Ledger.BaseTypes" "cardano-ledger-core-1.15.0.0-1046d1b1904b07389ef0faa5b38408cc4c76b23815c29933c8ff4d80bd3043da" 'True) (C1 ('MetaCons "DnsName" 'PrefixI 'True) (S1 ('MetaSel ('Just "dnsToText") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) |
Instances
FromJSON Network | |
Defined in Cardano.Ledger.BaseTypes | |
ToJSON Network | |
Bounded Network | |
Enum Network | |
Defined in Cardano.Ledger.BaseTypes | |
Generic Network | |
Show Network | |
DecCBOR Network | |
EncCBOR Network | |
Default Network | |
Defined in Cardano.Ledger.BaseTypes | |
NFData Network | |
Defined in Cardano.Ledger.BaseTypes | |
Eq Network | |
Ord Network | |
NoThunks Network | |
type Rep Network | |
Defined in Cardano.Ledger.BaseTypes |
class Bounded r ⇒ BoundedRational r where #
Type clases that allows conversion between Rational
and some form of bounded
rational type. Bounds can be restricted by both the Bounded
type class and underlyng
representation.
maybe True (\br -> minBound <= br && br <= maxBound) . boundRational
Roundtrip properties must hold:
\r -> maybe True ((r ==) . unboundRational) (boundRational r) \br -> Just br == boundRational (unboundRational br)
boundRational ∷ Rational → Maybe r #
Returns Nothing
when supplied value is not within bounds or when precision is
too high to be represented by the underlying type
Example
>>>
:set -XTypeApplications
>>>
import Data.Ratio
>>>
boundRational @UnitInterval $ 2 % 3
Just (2 % 3)>>>
boundRational @UnitInterval (-0.5)
Nothing>>>
boundRational @UnitInterval (1.5)
Nothing>>>
boundRational @UnitInterval 0
Just (0 % 1)>>>
boundRational @PositiveUnitInterval 0
Nothing
unboundRational ∷ r → Rational #
Promote bounded rational type into the unbounded Rational
.
Instances
BoundedRational NonNegativeInterval | |
BoundedRational PositiveInterval | |
Defined in Cardano.Ledger.BaseTypes | |
BoundedRational PositiveUnitInterval | |
BoundedRational UnitInterval | |
Defined in Cardano.Ledger.BaseTypes | |
(Bounded (BoundedRatio b a), Bounded a, Integral a) ⇒ BoundedRational (BoundedRatio b a) | |
Defined in Cardano.Ledger.BaseTypes boundRational ∷ Rational → Maybe (BoundedRatio b a) # unboundRational ∷ BoundedRatio b a → Rational # |
data UnitInterval #
Type to represent a value in the unit interval [0; 1]
Instances
Instances
FromJSON ProtVer | |
Defined in Cardano.Ledger.BaseTypes | |
ToJSON ProtVer | |
Generic ProtVer | |
Show ProtVer | |
FromCBOR ProtVer | |
ToCBOR ProtVer | |
DecCBOR ProtVer | |
EncCBOR ProtVer | |
DecCBORGroup ProtVer | |
Defined in Cardano.Ledger.BaseTypes decCBORGroup ∷ Decoder s ProtVer # | |
EncCBORGroup ProtVer | |
NFData ProtVer | |
Defined in Cardano.Ledger.BaseTypes | |
Eq ProtVer | |
Ord ProtVer | |
NoThunks ProtVer | |
type Rep ProtVer | |
Defined in Cardano.Ledger.BaseTypes type Rep ProtVer = D1 ('MetaData "ProtVer" "Cardano.Ledger.BaseTypes" "cardano-ledger-core-1.15.0.0-1046d1b1904b07389ef0faa5b38408cc4c76b23815c29933c8ff4d80bd3043da" 'False) (C1 ('MetaCons "ProtVer" 'PrefixI 'True) (S1 ('MetaSel ('Just "pvMajor") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Version) :*: S1 ('MetaSel ('Just "pvMinor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Natural))) |