string-variants-0.2.0.0: Constrained text newtypes
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.StringVariants.NullableNonEmptyText

Synopsis

Documentation

newtype NullableNonEmptyText n Source #

Newtype wrapper around Maybe NonEmptyText that converts empty string to Nothing.

This is aimed primarily at JSON parsing: make it possible to parse empty string and turn it into Nothing, in order to convert everything into Maybe NonEmptyText at the edge of the system.

While using this for JSON parsing, use Maybe NullableNonEmptyText. Aeson special-cases Maybe to allow nulls, so Maybe catches the nulls and NullableNonEmptyText catches the empty strings.

To extract Maybe NonEmptyText values from Maybe NullableNonEmptyText, use nullableNonEmptyTextToMaybeNonEmptyText.

Instances

Instances details
(KnownNat n, 1 <= n) => FromJSON (NullableNonEmptyText n) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

ToJSON (NullableNonEmptyText n) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

Generic (NullableNonEmptyText n) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

Associated Types

type Rep (NullableNonEmptyText n) :: Type -> Type #

Read (NullableNonEmptyText n) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

Show (NullableNonEmptyText n) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

Eq (NullableNonEmptyText n) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

Lift (NullableNonEmptyText n :: TYPE LiftedRep) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

Methods

lift :: Quote m => NullableNonEmptyText n -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => NullableNonEmptyText n -> Code m (NullableNonEmptyText n) #

type Rep (NullableNonEmptyText n) Source # 
Instance details

Defined in Data.StringVariants.NullableNonEmptyText

type Rep (NullableNonEmptyText n) = D1 ('MetaData "NullableNonEmptyText" "Data.StringVariants.NullableNonEmptyText" "string-variants-0.2.0.0-Ibj8xjKMcicJdCv0IWSIjz" 'True) (C1 ('MetaCons "NullableNonEmptyText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (NonEmptyText n)))))

Constructing

literalNullableNonEmptyText :: forall (s :: Symbol) (n :: Nat). (KnownSymbol s, KnownNat n, SymbolNonEmpty s, SymbolWithNoSpaceAround s, SymbolNoLongerThan s n) => NullableNonEmptyText n Source #

This requires the text to be non-empty. For the empty text just use the constructor `NullableNonEmptyText Nothing`

Conversion

Functions