mfmts-1.2.0.0: varint/MultiFormats/VarInt/Errors.hs
-- | Module : MultiFormats.VarInt.Errors
-- Description : Implements errors for MultiFormats.VarInt
-- Copyright : Zoey McBride (c) 2026
-- License : AGPL-3.0-or-later
-- Maintainer : zoeymcbride@mailbox.org
-- Stability : experimental
module MultiFormats.VarInt.Errors
( Error (..),
Okay,
)
where
import Control.DeepSeq (NFData (..))
-- | Functor for dealing with VarInt Error results.
type Okay a = Either Error a
-- | Errors for VarInts.
data Error
= -- | If the provided VarInt ByteString is empty.
EmptyBytes
| -- | If the VarInt's ByteString is missing the MSB=0 terminating byte.
MissingTermination
| -- | If the ByteString can't fit the VarInt type.
BytesOverflow
| -- | If the VarInt violates the minimal encoding property.
NotMinimal
| -- | If the encoded VarInt is larger than allowed maximum.
AboveMaxValue
deriving (Eq, Show)
-- | Evaluates Error into normal form.
instance NFData Error where
rnf _ = ()