generic-data-1.1.0.2: Deriving instances with GHC.Generics and related utilities

Safe Haskell | Trustworthy
Language | Haskell2010

Generic.Data.Internal.Read

Description

Generic implementation of Read

### Warning

This is an internal module: it is not subject to any versioning policy, breaking changes can happen at any time.

If something here seems useful, please report it or create a pull request to export it from an external module.

Synopsis

- greadPrec :: (Generic a, GRead0 (Rep a)) => ReadPrec a
- type GRead0 = GRead (Proxy :: Type -> Type)
- gliftReadPrec :: (Generic1 f, GRead1 (Rep1 f)) => ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)
- type GRead1 = GRead Identity
- class GRead (p :: Type -> Type) (f :: Type -> Type) where
  - gPrecRead :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a)
- class IsNullaryDataType (f :: Type -> Type) where
  - isNullaryDataType :: f a -> Bool
- class GReadC (p :: Type -> Type) (c :: Meta) (f :: Type -> Type) where
  - gPrecReadC :: p (ReadPrec a, ReadPrec [a]) -> String -> Fixity -> ReadPrec (M1 C c f a)
- class GReadFields (p :: Type -> Type) (f :: Type -> Type) where
  - gPrecReadFields :: p (ReadPrec a, ReadPrec [a]) -> ReadPrecTree (f a)
- class GReadNamed (p :: Type -> Type) (f :: Type -> Type) where
  - gPrecReadNamed :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a)
- class GReadSingle (p :: Type -> Type) (f :: Type -> Type) where
  - gPrecReadSingle :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a)
- coerceM1 :: forall f p i (c :: Meta). ReadPrec (f p) -> ReadPrec (M1 i c f p)
- liftReadPrecCompat :: Read1 f => (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a)
- data ReadPrecTree a where
  - U1Leaf :: forall a1. ReadPrecTree (U1 a1)
  - M1Leaf :: forall (f :: Type -> Type) a1 i (c :: Meta). ReadPrec (f a1) -> ReadPrecTree (M1 i c f a1)
  - Branch :: forall (f :: Type -> Type) a1 (g :: Type -> Type). ReadPrecTree (f a1) -> ReadPrecTree (g a1) -> ReadPrecTree ((f :*: g) a1)
- toReadPrec :: ReadPrecTree a -> ReadPrec a
- identHLexemes :: String -> [Lexeme]
- readPrefixCon :: String -> ReadPrec ()
- readSurround :: Char -> ReadPrec a -> Char -> ReadPrec a
- snocView :: [a] -> Maybe ([a], a)

# Documentation

greadPrec :: (Generic a, GRead0 (Rep a)) => ReadPrec a Source #

Generic `readPrec`.

    instance Read MyType where
      readPrec = greadPrec
      readListPrec = readListPrecDefault

type GRead0 = GRead (Proxy :: Type -> Type) Source #

Generic representation of `Read` types.

gliftReadPrec :: (Generic1 f, GRead1 (Rep1 f)) => ReadPrec a -> ReadPrec [a] -> ReadPrec (f a) Source #

Generic `liftReadPrec`.

type GRead1 = GRead Identity Source #

Generic representation of `Read1` types.

class GRead (p :: Type -> Type) (f :: Type -> Type) where Source #

Methods

gPrecRead :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a) Source #

#### Instances

Instances details

GRead p (V1 :: Type -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecRead :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (V1 a) Source #
(GRead p f, GRead p g) => GRead p (f :+: g) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecRead :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec ((f :+: g) a) Source #
(Constructor c, GReadC p c f) => GRead p (M1 C c f) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecRead :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (M1 C c f a) Source #
(GRead p f, IsNullaryDataType f) => GRead p (M1 D d f) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecRead :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (M1 D d f a) Source #

class IsNullaryDataType (f :: Type -> Type) where Source #

Methods

isNullaryDataType :: f a -> Bool Source #

#### Instances

Instances details

IsNullaryDataType (V1 :: Type -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods isNullaryDataType :: V1 a -> Bool Source #
IsNullaryDataType (f :+: g) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods isNullaryDataType :: (f :+: g) a -> Bool Source #
IsNullaryDataType (C1 c f) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods isNullaryDataType :: C1 c f a -> Bool Source #

class GReadC (p :: Type -> Type) (c :: Meta) (f :: Type -> Type) where Source #

Methods

gPrecReadC :: p (ReadPrec a, ReadPrec [a]) -> String -> Fixity -> ReadPrec (M1 C c f a) Source #

#### Instances

Instances details

GReadFields p f => GReadC p ('MetaCons s y 'False) f Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadC :: p (ReadPrec a, ReadPrec [a]) -> String -> Fixity -> ReadPrec (M1 C ('MetaCons s y 'False) f a) Source #
GReadNamed p f => GReadC p ('MetaCons s y 'True) f Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadC :: p (ReadPrec a, ReadPrec [a]) -> String -> Fixity -> ReadPrec (M1 C ('MetaCons s y 'True) f a) Source #

class GReadFields (p :: Type -> Type) (f :: Type -> Type) where Source #

Methods

gPrecReadFields :: p (ReadPrec a, ReadPrec [a]) -> ReadPrecTree (f a) Source #

#### Instances

Instances details

GReadFields p (U1 :: Type -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadFields :: p (ReadPrec a, ReadPrec [a]) -> ReadPrecTree (U1 a) Source #
(GReadFields p f, GReadFields p g) => GReadFields p (f :*: g) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadFields :: p (ReadPrec a, ReadPrec [a]) -> ReadPrecTree ((f :*: g) a) Source #
GReadSingle p f => GReadFields p (M1 S c f) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadFields :: p (ReadPrec a, ReadPrec [a]) -> ReadPrecTree (M1 S c f a) Source #

class GReadNamed (p :: Type -> Type) (f :: Type -> Type) where Source #

Methods

gPrecReadNamed :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a) Source #

#### Instances

Instances details

GReadNamed p (U1 :: Type -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadNamed :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (U1 a) Source #
(GReadNamed p f, GReadNamed p g) => GReadNamed p (f :*: g) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadNamed :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec ((f :*: g) a) Source #
(Selector c, GReadSingle p f) => GReadNamed p (M1 S c f) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadNamed :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (M1 S c f a) Source #

class GReadSingle (p :: Type -> Type) (f :: Type -> Type) where Source #

Methods

gPrecReadSingle :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a) Source #

#### Instances

Instances details

GReadSingle Identity Par1 Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadSingle :: Identity (ReadPrec a, ReadPrec [a]) -> ReadPrec (Par1 a) Source #
Read1 f => GReadSingle Identity (Rec1 f) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadSingle :: Identity (ReadPrec a, ReadPrec [a]) -> ReadPrec (Rec1 f a) Source #
Read a => GReadSingle p (K1 i a :: Type -> Type) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadSingle :: p (ReadPrec a0, ReadPrec [a0]) -> ReadPrec (K1 i a a0) Source #
(Read1 f, GReadSingle p g) => GReadSingle p (f :.: g) Source # |
Instance details Defined in Generic.Data.Internal.Read Methods gPrecReadSingle :: p (ReadPrec a, ReadPrec [a]) -> ReadPrec ((f :.: g) a) Source #

coerceM1 :: forall f p i (c :: Meta). ReadPrec (f p) -> ReadPrec (M1 i c f p) Source #

liftReadPrecCompat :: Read1 f => (ReadPrec a, ReadPrec [a]) -> ReadPrec (f a) Source #

A backwards-compatible version of `liftReadPrec`. This is needed for compatibility with `base-4.9`, where `Read1` only offers `liftReadsPrec`, not `liftReadPrec`.

data ReadPrecTree a where Source #

Constructors

U1Leaf :: forall a1. ReadPrecTree (U1 a1) |
M1Leaf :: forall (f :: Type -> Type) a1 i (c :: Meta). ReadPrec (f a1) -> ReadPrecTree (M1 i c f a1) |
Branch :: forall (f :: Type -> Type) a1 (g :: Type -> Type). ReadPrecTree (f a1) -> ReadPrecTree (g a1) -> ReadPrecTree ((f :*: g) a1) |

toReadPrec :: ReadPrecTree a -> ReadPrec a Source #

identHLexemes :: String -> [Lexeme] Source #

readPrefixCon :: String -> ReadPrec () Source #

readSurround :: Char -> ReadPrec a -> Char -> ReadPrec a Source #

snocView :: [a] -> Maybe ([a], a) Source #