registry-options-0.2.0.0: application options parsing
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Registry.Options.Decoder

Description

This module contains the definition of a Decoder and some default decoders

A Decoder reads a string and return a Haskell value or a failure

Synopsis

Documentation

newtype Decoder a Source #

Decode a value of type a from Text

Constructors

Decoder 

Fields

Instances

Instances details
Applicative Decoder Source # 
Instance details

Defined in Data.Registry.Options.Decoder

Methods

pure :: a -> Decoder a #

(<*>) :: Decoder (a -> b) -> Decoder a -> Decoder b #

liftA2 :: (a -> b -> c) -> Decoder a -> Decoder b -> Decoder c #

(*>) :: Decoder a -> Decoder b -> Decoder b #

(<*) :: Decoder a -> Decoder b -> Decoder a #

Functor Decoder Source # 
Instance details

Defined in Data.Registry.Options.Decoder

Methods

fmap :: (a -> b) -> Decoder a -> Decoder b #

(<$) :: a -> Decoder b -> Decoder a #

Monad Decoder Source # 
Instance details

Defined in Data.Registry.Options.Decoder

Methods

(>>=) :: Decoder a -> (a -> Decoder b) -> Decoder b #

(>>) :: Decoder a -> Decoder b -> Decoder b #

return :: a -> Decoder a #

decoderOf :: forall a b. (ApplyVariadic Decoder a b, Typeable a, Typeable b) => a -> Typed b Source #

Create a Decoder a for a given constructor of type a

addDecoder :: forall a. Typeable a => (Text -> Either Text a) -> Typed (Decoder a) Source #

Add a Decoder to a registry

Common decoders

intDecoder :: Text -> Either Text Int Source #

Decoder for an Int

boolDecoder :: Text -> Either Text Bool Source #

Decoder for a Bool

textDecoder :: Text -> Either Text Text Source #

Decoder for some Text

stringDecoder :: Text -> Either Text String Source #

Decoder for some String

manyOf :: forall a. Typeable a => Typed (Decoder a -> Decoder [a]) Source #

Create a Decoder for [a]

decodeMany :: forall a. Typeable a => Decoder a -> Decoder [a] Source #

Create a Decoder for [a] as a comma-separated string

decodeManySeparated :: forall a. Typeable a => Text -> Decoder a -> Decoder [a] Source #

Create a Decoder for [a] as a separated string