Moduleextra-1.8Haskell2010
Text.Read.Extra
Deprecated. Use Text.Read directly
This module provides Text.Read with functions added in later versions.
Currently this module has no functionality beyond Text.Read.
- 4 types
- 1 class
- 25 values
- Packageextra-1.8
- Exports30
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceExtra.hs
Parsing of Strings, producing values.
Derived instances of Read make the following assumptions, which
derived instances of Text.Show.Show obey:
If the constructor is defined to be an infix operator, then the derived Read instance will parse only infix applications of the constructor (not the prefix form).
Associativity is not used to reduce the occurrence of parentheses, although precedence may be.
If the constructor is defined using record syntax, the derived Read will parse only the record-syntax form, and furthermore, the fields must be given in the same order as the original declaration.
The derived Read instance allows arbitrary Haskell whitespace between tokens of the input string. Extra parentheses are also allowed.
For example, given the declarations
infixr 5 :^:
data Tree a = Leaf a | Tree a :^: Tree athe derived instance of Read in Haskell 2010 is equivalent to
instance (Read a) => Read (Tree a) where
readsPrec d r = readParen (d > app_prec)
(\r -> [(Leaf m,t) |
("Leaf",s) <- lex r,
(m,t) <- readsPrec (app_prec+1) s]) r
++ readParen (d > up_prec)
(\r -> [(u:^:v,w) |
(u,s) <- readsPrec (up_prec+1) r,
(":^:",t) <- lex s,
(v,w) <- readsPrec (up_prec+1) t]) r
where app_prec = 10
up_prec = 5Note that right-associativity of :^: is unused.
The derived instance in GHC is equivalent to
instance (Read a) => Read (Tree a) where
readPrec = parens $ (prec app_prec $ do
Ident "Leaf" <- lexP
m <- step readPrec
return (Leaf m))
+++ (prec up_prec $ do
u <- step readPrec
Symbol ":^:" <- lexP
v <- step readPrec
return (u :^: v))
where app_prec = 10
up_prec = 5
readListPrec = readListPrecDefaultWhy do both readsPrec and readPrec exist, and why does GHC opt to implement readPrec in derived Read instances instead of readsPrec? The reason is that readsPrec is based on the ReadS type, and although ReadS is mentioned in the Haskell 2010 Report, it is not a very efficient parser data structure.
readPrec, on the other hand, is based on a much more efficient ReadPrec
datatype (a.k.a "new-style parsers"), but its definition relies on the use
of the RankNTypes language extension. Therefore, readPrec (and its
cousin, readListPrec) are marked as GHC-only. Nevertheless, it is
recommended to use readPrec instead of readsPrec whenever possible
for the efficiency improvements it brings.
As mentioned above, derived Read instances in GHC will implement readPrec instead of readsPrec. The default implementations of readsPrec (and its cousin, readList) will simply use readPrec under the hood. If you are writing a Read instance by hand, it is recommended to write it like so:
instance Read T where
readPrec = ...
readListPrec = readListPrecDefault
Methods
readsPrec :: Int -> ReadS aattempts to parse a value from the front of the string, returning a list of (parsed value, remaining string) pairs. If there is no successful parse, the returned list is empty.
Derived instances of Read and
Text.Show.Showsatisfy the following:That is, readsPrec parses the string produced by showsPrec, and delivers the value that showsPrec started with.
readList :: ReadS [a]readPrec :: ReadPrec aProposed replacement for readsPrec using new-style parsers (GHC only).
readListPrec :: ReadPrec [a]Proposed replacement for readList using new-style parsers (GHC only). The default definition uses readList. Instances that define readPrec should also define readListPrec as readListPrecDefault.
Instances194Read, …
Read ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Internal.TypeRead ByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Lazy.InternalRead ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.InternalRead ClockDefined in clock-0.8.4 · System.ClockRead TimeSpecDefined in clock-0.8.4 · System.ClockRead SecondsDefined in clock-0.8.4 · System.Clock.SecondsRead FileTypeDefined in directory-1.3.8.5 · System.Directory.Internal.CommonRead PermissionsDefined in directory-1.3.8.5 · System.Directory.Internal.CommonRead XdgDirectoryDefined in directory-1.3.8.5 · System.Directory.Internal.CommonRead XdgDirectoryListDefined in directory-1.3.8.5 · System.Directory.Internal.CommonRead IntegerDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead NaturalDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead VoidDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead ByteOrderDefined in ghc-internal-9.1003.0 · GHC.Internal.ByteOrderRead AllDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalRead AnyDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalRead VersionDefined in ghc-internal-9.1003.0 · GHC.Internal.Data.VersionRead CBoolDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CClockDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CLLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CPtrdiffDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CSCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CSUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CSigAtomicDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CTimeDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CUCharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CUIntDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CUIntMaxDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CUIntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CULLongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CULongDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CUSecondsDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CUShortDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead CWcharDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRead IntPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.PtrRead WordPtrDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.PtrRead AssociativityDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead DecidedStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead FixityDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead SourceStrictnessDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead SourceUnpackednessDefined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead SeekModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.DeviceRead ExitCodeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.ExceptionRead BufferModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.TypesRead NewlineDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.TypesRead NewlineModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.Handle.TypesRead IOModeDefined in ghc-internal-9.1003.0 · GHC.Internal.IO.IOModeRead Int16Defined in ghc-internal-9.1003.0 · GHC.Internal.IntRead Int32Defined in ghc-internal-9.1003.0 · GHC.Internal.IntRead Int64Defined in ghc-internal-9.1003.0 · GHC.Internal.IntRead Int8Defined in ghc-internal-9.1003.0 · GHC.Internal.IntRead GCDetailsDefined in ghc-internal-9.1003.0 · GHC.Internal.StatsRead RTSStatsDefined in ghc-internal-9.1003.0 · GHC.Internal.StatsRead CBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CBlkSizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CCcDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CClockIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CDevDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CFsBlkCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CFsFilCntDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CGidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CIdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CInoDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CKeyDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CModeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CNfdsDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CNlinkDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead COffDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CPidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CRLimDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CSocklenDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CSpeedDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CSsizeDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CTcflagDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead CUidDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead FdDefined in ghc-internal-9.1003.0 · GHC.Internal.System.Posix.TypesRead LexemeDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead SomeCharDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLitsRead SomeSymbolDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeLitsRead SomeNatDefined in ghc-internal-9.1003.0 · GHC.Internal.TypeNatsRead GeneralCategoryDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead Word16Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead Word32Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead Word64Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead Word8Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead BoolDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead CharDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead IntDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead OrderingDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead WordDefined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead CommunicationHandleDefined in process-1.6.26.1 · System.Process.CommunicationHandle.InternalRead DayDefined in time-1.12.2 · Data.Time.Format.Parse · orphanRead MonthDefined in time-1.12.2 · Data.Time.Calendar.MonthRead as
yyyy-mm.Read QuarterDefined in time-1.12.2 · Data.Time.Calendar.QuarterRead as
yyyy-Qn.Read QuarterOfYearDefined in time-1.12.2 · Data.Time.Calendar.QuarterRead DayOfWeekDefined in time-1.12.2 · Data.Time.Calendar.WeekRead DiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.DiffTimeRead NominalDiffTimeDefined in time-1.12.2 · Data.Time.Clock.Internal.NominalDiffTimeRead UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphanRead UniversalTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphanRead LocalTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphanRead TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Parse · orphanRead TimeZoneDefined in time-1.12.2 · Data.Time.Format.Parse · orphanThis only works for
±HHMMformat, single-letter military time-zones, and these time-zones: "UTC", "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", per RFC 822 section 5.Read ZonedTimeDefined in time-1.12.2 · Data.Time.Format.Parse · orphanThis only works for a zonedTimeZone in
±HHMMformat, single-letter military time-zones, and these time-zones: "UTC", "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", per RFC 822 section 5.Read RTLDFlagsDefined in unix-2.8.7.0 · System.Posix.DynamicLinker.PrimRead CAttributesDefined in unix-2.8.7.0 · System.Posix.Files.CommonRead StatxFlagsDefined in unix-2.8.7.0 · System.Posix.Files.CommonRead StatxMaskDefined in unix-2.8.7.0 · System.Posix.Files.CommonRead OpenFileFlagsDefined in unix-2.8.7.0 · System.Posix.IO.CommonRead OpenModeDefined in unix-2.8.7.0 · System.Posix.IO.CommonRead GroupEntryDefined in unix-2.8.7.0 · System.Posix.User.CommonRead UserEntryDefined in unix-2.8.7.0 · System.Posix.User.CommonRead ()Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead a => Read (Complex a)Defined in base-4.20.2.0 · Data.ComplexRead a => Read (First a)Defined in base-4.20.2.0 · Data.SemigroupRead a => Read (Last a)Defined in base-4.20.2.0 · Data.SemigroupRead a => Read (Max a)Defined in base-4.20.2.0 · Data.SemigroupRead a => Read (Min a)Defined in base-4.20.2.0 · Data.SemigroupRead a => Read (NonEmpty a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead a => Read (And a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsRead a => Read (Iff a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsRead a => Read (Ior a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsRead a => Read (Xor a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.BitsRead a => Read (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityThis instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed
Read a => Read (First a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidRead a => Read (Last a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidRead a => Read (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.OrdRead a => Read (Dual a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalRead a => Read (Product a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalRead a => Read (Sum a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalRead a => Read (ZipList a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Functor.ZipListRead a => Read (Maybe a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead a => Read (a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead a => Read [a]Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead m => Read (WrappedMonoid m)Defined in base-4.20.2.0 · Data.SemigroupRead p => Read (Par1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Integral a, Read a) => Read (Ratio a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadHasResolution a => Read (Fixed a)Defined in base-4.20.2.0 · Data.FixedRead (Proxy t)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.ProxyRead (U1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead (V1 p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Read1 f, Read a) => Read (Lift f a)Defined in transformers-0.6.1.1 · Control.Applicative.Lift(Read1 m, Read a) => Read (MaybeT m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Maybe(Ix a, Read a, Read b) => Read (Array a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Ix ix, Read ix, Read e, IArray UArray e) => Read (UArray ix e)Defined in array-0.5.8.0 · Data.Array.Base(Read a, Read b) => Read (Arg a b)Defined in base-4.20.2.0 · Data.Semigroup(Read a, Read b) => Read (Either a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Either(Read a, Read b) => Read (a, b)Defined in ghc-internal-9.1003.0 · GHC.Internal.ReadRead (f a) => Read (Ap f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.MonoidRead (f a) => Read (Alt f a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Semigroup.InternalRead (f p) => Read (Rec1 f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead a => Read (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRead a => Read (Constant a b)Defined in transformers-0.6.1.1 · Data.Functor.ConstantCoercible a b => Read (Coercion a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.Coercion(Read1 f, Read a) => Read (Backwards f a)Defined in transformers-0.6.1.1 · Control.Applicative.Backwards(Read1 f, Read a) => Read (IdentityT f a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Identity(Read1 f, Read a) => Read (Reverse f a)Defined in transformers-0.6.1.1 · Data.Functor.Reverse(Read a, Read b, Read c) => Read (a, b, c)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read e, Read1 m, Read a) => Read (ExceptT e m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Except(Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Lazy(Read w, Read1 m, Read a) => Read (WriterT w m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.Writer.Stricta ~ b => Read (a :~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityRead c => Read (K1 i c p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Read (f a), Read (g a)) => Read (Product f g a)Defined in base-4.20.2.0 · Data.Functor.Product(Read (f a), Read (g a)) => Read (Sum f g a)Defined in base-4.20.2.0 · Data.Functor.Sum(Read (f p), Read (g p)) => Read ((:*:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Read (f p), Read (g p)) => Read ((:+:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Read a, Read b, Read c, Read d) => Read (a, b, c, d)Defined in ghc-internal-9.1003.0 · GHC.Internal.Reada ~~ b => Read (a :~~: b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Type.EqualityRead (f (g a)) => Read (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.ComposeRead (f (g p)) => Read ((:.:) f g p)Defined in ghc-internal-9.1003.0 · GHC.Internal.GenericsRead (f p) => Read (M1 i c f p)Defined in ghc-internal-9.1003.0 · GHC.Internal.Generics(Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f) => Read (a, b, c, d, e, f)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g) => Read (a, b, c, d, e, f, g)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) => Read (a, b, c, d, e, f, g, h)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i) => Read (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j) => Read (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k) => Read (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l) => Read (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h, Read i, Read j, Read k, Read l, Read m, Read n, Read o) => Read (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-9.1003.0 · GHC.Internal.Read
The lex function reads a single lexeme from the input, discarding
initial white space, and returning the characters that constitute the
lexeme. If the input string contains only white space, lex returns a
single successful `lexeme' consisting of the empty string. (Thus
lex "" = [("","")].) If there is no legal lexeme at the
beginning of the input string, lex fails (i.e. returns []).
This lexer is not completely faithful to the Haskell lexical syntax in the following respects:
Qualified names are not handled properly
Octal and hexadecimal numerics are not recognized as a single token
Comments are not treated properly
The read function reads input from a string, which must be completely consumed by the input process. read fails with an error if the parse is unsuccessful, and it is therefore discouraged from being used in real applications. Use readMaybe or readEither for safe alternatives.
read "123" :: Int123
read "hello" :: Int*** Exception: Prelude.read: no parse
equivalent to readsPrec with a precedence of 0.
Parse a single lexeme
(parens p) parses "P", "(P0)", "((P0))", etc,
where p parses "P" in the current precedence context
and parses "P0" in precedence context zero
A possible replacement definition for the readList method (GHC only). This is only needed for GHC, and even then only for Read instances where readListPrec isn't defined as readListPrecDefault.
A possible replacement definition for the readListPrec method, defined using readPrec (GHC only).
Symmetric choice.
Local, exclusive, left-biased choice: If left parser locally produces any result at all, then right parser is not used.
Combines all parsers in the specified list.
Consumes and returns the next character. Fails if there is no input left.
Look-ahead: returns the part of the input that is left, without consuming it.
Always fails.
(prec n p) checks whether the precedence context is
less than or equal to n, and
if not, fails
if so, parses
pin contextn.
Resets the precedence context to zero.
Increases the precedence context by one.
Parse a string using the Read instance. Succeeds if there is exactly one valid result.
readMaybe "123" :: Maybe IntJust 123
readMaybe "hello" :: Maybe IntNothing
Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
Monad ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecFunctor ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecMonadFail ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecApplicative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecAlternative ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrecMonadPlus ReadPrecDefined in ghc-internal-9.1003.0 · GHC.Internal.Text.ParserCombinators.ReadPrec