Movatterモバイル変換
[0]ホーム
{-# LANGUAGE Trustworthy #-}{-# LANGUAGE CPP, NoImplicitPrelude, StandaloneDeriving, ScopedTypeVariables #-}{-# OPTIONS_HADDOCK not-home #-}------------------------------------------------------------------------------- |-- Module : GHC.Read-- Copyright : (c) The University of Glasgow, 1994-2002-- License : see libraries/base/LICENSE---- Maintainer : cvs-ghc@haskell.org-- Stability : internal-- Portability : non-portable (GHC Extensions)---- The 'Read' class and instances for basic data types.-------------------------------------------------------------------------------moduleGHC.Read(Read(..)-- class-- ReadS type,ReadS-- H2010 compatibility,lex,lexLitChar,readLitChar,lexDigits-- defining readers,lexP,expectP,paren,parens,list,choose,readListDefault,readListPrecDefault,readNumber,readField,readFieldHash,readSymField-- Temporary,readParen)where#include "MachDeps.h"importqualifiedText.ParserCombinators.ReadPasPimportText.ParserCombinators.ReadP(ReadS,readP_to_S)importqualifiedText.Read.LexasL-- Lex exports 'lex', which is also defined here,-- hence the qualified import.-- We can't import *anything* unqualified, because that-- confuses Haddock.importText.ParserCombinators.ReadPrecimportData.MaybeimportGHC.UnicodeimportGHC.NumimportGHC.RealimportGHC.FloatimportGHC.ShowimportGHC.BaseimportGHC.ArrimportGHC.WordimportGHC.List(filter)-- | @'readParen' 'True' p@ parses what @p@ parses, but surrounded with-- parentheses.---- @'readParen' 'False' p@ parses what @p@ parses, but optionally-- surrounded with parentheses.readParen::Bool->ReadSa->ReadSa-- A Haskell 2010 functionreadParen :: Bool -> ReadS a -> ReadS areadParenBoolbReadS ag=ifBoolbthenReadS amandatoryelseReadS aoptionalwhereoptional :: ReadS aoptionalStringr=ReadS agStringr[(a, String)] -> [(a, String)] -> [(a, String)]forall a. [a] -> [a] -> [a]++ReadS amandatoryStringrmandatory :: ReadS amandatoryStringr=do(String"(",Strings)<-ReadS StringlexStringr(ax,Stringt)<-ReadS aoptionalStrings(String")",Stringu)<-ReadS StringlexStringt(a, String) -> [(a, String)]forall (m :: * -> *) a. Monad m => a -> m areturn(ax,Stringu)-- | Parsing of 'String's, 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 a---- the 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 = 5---- Note 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 = readListPrecDefault---- Why 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'-- @classReadawhere{-# MINIMALreadsPrec|readPrec#-}-- | attempts 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.Show' satisfy the following:---- * @(x,\"\")@ is an element of-- @('readsPrec' d ('Text.Show.showsPrec' d x \"\"))@.---- That is, 'readsPrec' parses the string produced by-- 'Text.Show.showsPrec', and delivers the value that-- 'Text.Show.showsPrec' started with.readsPrec::Int-- ^ the operator precedence of the enclosing-- context (a number from @0@ to @11@).-- Function application has precedence @10@.->ReadSa-- | The method 'readList' is provided to allow the programmer to-- give a specialised way of parsing lists of values.-- For example, this is used by the predefined 'Read' instance of-- the 'Char' type, where values of type 'String' should be are-- expected to use double quotes, rather than square brackets.readList::ReadS[a]-- | Proposed replacement for 'readsPrec' using new-style parsers (GHC only).readPrec::ReadPreca-- | 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'.readListPrec::ReadPrec[a]-- default definitionsreadsPrec=ReadPrec a -> Int -> ReadS aforall a. ReadPrec a -> Int -> ReadS areadPrec_to_SReadPrec aforall a. Read a => ReadPrec areadPrecreadList=ReadPrec [a] -> Int -> ReadS [a]forall a. ReadPrec a -> Int -> ReadS areadPrec_to_S(ReadPrec a -> ReadPrec [a]forall a. ReadPrec a -> ReadPrec [a]listReadPrec aforall a. Read a => ReadPrec areadPrec)Int0readPrec=(Int -> ReadS a) -> ReadPrec aforall a. (Int -> ReadS a) -> ReadPrec areadS_to_PrecInt -> ReadS aforall a. Read a => Int -> ReadS areadsPrecreadListPrec=(Int -> ReadS [a]) -> ReadPrec [a]forall a. (Int -> ReadS a) -> ReadPrec areadS_to_Prec(\Int_->ReadS [a]forall a. Read a => ReadS [a]readList)readListDefault::Reada=>ReadS[a]-- ^ 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'.readListDefault :: ReadS [a]readListDefault=ReadPrec [a] -> Int -> ReadS [a]forall a. ReadPrec a -> Int -> ReadS areadPrec_to_SReadPrec [a]forall a. Read a => ReadPrec [a]readListPrecInt0readListPrecDefault::Reada=>ReadPrec[a]-- ^ A possible replacement definition for the 'readListPrec' method,-- defined using 'readPrec' (GHC only).readListPrecDefault :: ReadPrec [a]readListPrecDefault=ReadPrec a -> ReadPrec [a]forall a. ReadPrec a -> ReadPrec [a]listReadPrec aforall a. Read a => ReadPrec areadPrec-------------------------------------------------------------------------- H2010 compatibility-- | 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 properlylex::ReadSString-- As defined by H2010lex :: ReadS StringlexStrings=ReadP String -> ReadS Stringforall a. ReadP a -> ReadS areadP_to_SReadP StringL.hsLexStrings-- | Read a string representation of a character, using Haskell-- source-language escape conventions. For example:---- > lexLitChar "\\nHello" = [("\\n", "Hello")]--lexLitChar::ReadSString-- As defined by H2010lexLitChar :: ReadS StringlexLitChar=ReadP String -> ReadS Stringforall a. ReadP a -> ReadS areadP_to_S(do{(Strings,Char_)<-ReadP Char -> ReadP (String, Char)forall a. ReadP a -> ReadP (String, a)P.gatherReadP CharL.lexChar;lets' :: Strings'=String -> StringremoveNullsStringsinString -> ReadP Stringforall (m :: * -> *) a. Monad m => a -> m areturnStrings'})where-- remove nulls from end of the character if they existremoveNulls :: String -> StringremoveNulls[]=[]removeNulls(Char'\\':Char'&':Stringxs)=String -> StringremoveNullsStringxsremoveNulls(Charfirst:Stringrest)=CharfirstChar -> String -> Stringforall a. a -> [a] -> [a]:String -> StringremoveNullsStringrest-- There was a skipSpaces before the P.gather L.lexChar,-- but that seems inconsistent with readLitChar-- | Read a string representation of a character, using Haskell-- source-language escape conventions, and convert it to the character-- that it encodes. For example:---- > readLitChar "\\nHello" = [('\n', "Hello")]--readLitChar::ReadSChar-- As defined by H2010readLitChar :: ReadS CharreadLitChar=ReadP Char -> ReadS Charforall a. ReadP a -> ReadS areadP_to_SReadP CharL.lexChar-- | Reads a non-empty string of decimal digits.lexDigits::ReadSStringlexDigits :: ReadS StringlexDigits=ReadP String -> ReadS Stringforall a. ReadP a -> ReadS areadP_to_S((Char -> Bool) -> ReadP StringP.munch1Char -> BoolisDigit)-------------------------------------------------------------------------- utility parserslexP::ReadPrecL.Lexeme-- ^ Parse a single lexemelexP :: ReadPrec LexemelexP=ReadP Lexeme -> ReadPrec Lexemeforall a. ReadP a -> ReadPrec aliftReadP LexemeL.lexexpectP::L.Lexeme->ReadPrec()expectP :: Lexeme -> ReadPrec ()expectPLexemelexeme=ReadP () -> ReadPrec ()forall a. ReadP a -> ReadPrec alift(Lexeme -> ReadP ()L.expectLexemelexeme)expectCharP::Char->ReadPreca->ReadPrecaexpectCharP :: Char -> ReadPrec a -> ReadPrec aexpectCharPCharcReadPrec aa=doCharq<-ReadPrec ChargetifCharqChar -> Char -> Boolforall a. Eq a => a -> a -> Bool==CharcthenReadPrec aaelseReadPrec aforall a. ReadPrec apfail{-# INLINEexpectCharP#-}skipSpacesThenP::ReadPreca->ReadPrecaskipSpacesThenP :: ReadPrec a -> ReadPrec askipSpacesThenPReadPrec am=doStrings<-ReadPrec StringlookString -> ReadPrec askipStringswhereskip :: String -> ReadPrec askip(Charc:Strings)|Char -> BoolisSpaceCharc=ReadPrec ChargetReadPrec Char -> ReadPrec a -> ReadPrec aforall (f :: * -> *) a b. Applicative f => f a -> f b -> f b*>String -> ReadPrec askipStringsskipString_=ReadPrec amparen::ReadPreca->ReadPreca-- ^ @(paren p)@ parses \"(P0)\"-- where @p@ parses \"P0\" in precedence context zeroparen :: ReadPrec a -> ReadPrec aparenReadPrec ap=ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec askipSpacesThenP(ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec aparen'ReadPrec ap)paren'::ReadPreca->ReadPrecaparen' :: ReadPrec a -> ReadPrec aparen'ReadPrec ap=Char -> ReadPrec a -> ReadPrec aforall a. Char -> ReadPrec a -> ReadPrec aexpectCharPChar'('(ReadPrec a -> ReadPrec a) -> ReadPrec a -> ReadPrec aforall a b. (a -> b) -> a -> b$ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec aresetReadPrec apReadPrec a -> (a -> ReadPrec a) -> ReadPrec aforall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b>>=\ax->ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec askipSpacesThenP(Char -> ReadPrec a -> ReadPrec aforall a. Char -> ReadPrec a -> ReadPrec aexpectCharPChar')'(a -> ReadPrec aforall (f :: * -> *) a. Applicative f => a -> f apureax))parens::ReadPreca->ReadPreca-- ^ @(parens p)@ parses \"P\", \"(P0)\", \"((P0))\", etc,-- where @p@ parses \"P\" in the current precedence context-- and parses \"P0\" in precedence context zeroparens :: ReadPrec a -> ReadPrec aparensReadPrec ap=ReadPrec aoptionalwhereoptional :: ReadPrec aoptional=ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec askipSpacesThenP(ReadPrec apReadPrec a -> ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec a -> ReadPrec a+++ReadPrec amandatory)mandatory :: ReadPrec amandatory=ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec aparen'ReadPrec aoptionallist::ReadPreca->ReadPrec[a]-- ^ @(list p)@ parses a list of things parsed by @p@,-- using the usual square-bracket syntax.list :: ReadPrec a -> ReadPrec [a]listReadPrec areadx=ReadPrec [a] -> ReadPrec [a]forall a. ReadPrec a -> ReadPrec aparens(doLexeme -> ReadPrec ()expectP(String -> LexemeL.PuncString"[")(Bool -> ReadPrec [a]listRestBoolFalseReadPrec [a] -> ReadPrec [a] -> ReadPrec [a]forall a. ReadPrec a -> ReadPrec a -> ReadPrec a+++ReadPrec [a]listNext))wherelistRest :: Bool -> ReadPrec [a]listRestBoolstarted=doL.PuncStringc<-ReadPrec LexemelexPcaseStringcofString"]"->[a] -> ReadPrec [a]forall (m :: * -> *) a. Monad m => a -> m areturn[]String","|Boolstarted->ReadPrec [a]listNextString_->ReadPrec [a]forall a. ReadPrec apfaillistNext :: ReadPrec [a]listNext=doax<-ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec aresetReadPrec areadx[a]xs<-Bool -> ReadPrec [a]listRestBoolTrue[a] -> ReadPrec [a]forall (m :: * -> *) a. Monad m => a -> m areturn(axa -> [a] -> [a]forall a. a -> [a] -> [a]:[a]xs)choose::[(String,ReadPreca)]->ReadPreca-- ^ Parse the specified lexeme and continue as specified.-- Esp useful for nullary constructors; e.g.-- @choose [(\"A\", return A), (\"B\", return B)]@-- We match both Ident and Symbol because the constructor-- might be an operator eg @(:~:)@choose :: [(String, ReadPrec a)] -> ReadPrec achoose[(String, ReadPrec a)]sps=((String, ReadPrec a) -> ReadPrec a -> ReadPrec a)-> ReadPrec a -> [(String, ReadPrec a)] -> ReadPrec aforall a b. (a -> b -> b) -> b -> [a] -> bfoldr(ReadPrec a -> ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec a -> ReadPrec a(+++)(ReadPrec a -> ReadPrec a -> ReadPrec a)-> ((String, ReadPrec a) -> ReadPrec a)-> (String, ReadPrec a)-> ReadPrec a-> ReadPrec aforall b c a. (b -> c) -> (a -> b) -> a -> c.(String, ReadPrec a) -> ReadPrec aforall b. (String, ReadPrec b) -> ReadPrec btry_one)ReadPrec aforall a. ReadPrec apfail[(String, ReadPrec a)]spswheretry_one :: (String, ReadPrec b) -> ReadPrec btry_one(Strings,ReadPrec bp)=do{Lexemetoken<-ReadPrec LexemelexP;caseLexemetokenofL.IdentStrings'|StringsString -> String -> Boolforall a. Eq a => a -> a -> Bool==Strings'->ReadPrec bpL.SymbolStrings'|StringsString -> String -> Boolforall a. Eq a => a -> a -> Bool==Strings'->ReadPrec bpLexeme_other->ReadPrec bforall a. ReadPrec apfail}-- See Note [Why readField]-- | 'Read' parser for a record field, of the form @fieldName=value@. The-- @fieldName@ must be an alphanumeric identifier; for symbols (operator-style)-- field names, e.g. @(#)@, use 'readSymField'). The second argument is a-- parser for the field value.readField::String->ReadPreca->ReadPrecareadField :: String -> ReadPrec a -> ReadPrec areadFieldStringfieldNameReadPrec areadVal=doLexeme -> ReadPrec ()expectP(String -> LexemeL.IdentStringfieldName)Lexeme -> ReadPrec ()expectP(String -> LexemeL.PuncString"=")ReadPrec areadVal{-# NOINLINEreadField#-}-- See Note [Why readField]-- | 'Read' parser for a record field, of the form @fieldName#=value@. That is,-- an alphanumeric identifier @fieldName@ followed by the symbol @#@. The-- second argument is a parser for the field value.---- Note that 'readField' does not suffice for this purpose due to-- <https://gitlab.haskell.org/ghc/ghc/issues/5041 #5041>.readFieldHash::String->ReadPreca->ReadPrecareadFieldHash :: String -> ReadPrec a -> ReadPrec areadFieldHashStringfieldNameReadPrec areadVal=doLexeme -> ReadPrec ()expectP(String -> LexemeL.IdentStringfieldName)Lexeme -> ReadPrec ()expectP(String -> LexemeL.SymbolString"#")Lexeme -> ReadPrec ()expectP(String -> LexemeL.PuncString"=")ReadPrec areadVal{-# NOINLINEreadFieldHash#-}-- See Note [Why readField]-- | 'Read' parser for a symbol record field, of the form @(###)=value@ (where-- @###@ is the field name). The field name must be a symbol (operator-style),-- e.g. @(#)@. For regular (alphanumeric) field names, use 'readField'. The-- second argument is a parser for the field value.readSymField::String->ReadPreca->ReadPrecareadSymField :: String -> ReadPrec a -> ReadPrec areadSymFieldStringfieldNameReadPrec areadVal=doLexeme -> ReadPrec ()expectP(String -> LexemeL.PuncString"(")Lexeme -> ReadPrec ()expectP(String -> LexemeL.SymbolStringfieldName)Lexeme -> ReadPrec ()expectP(String -> LexemeL.PuncString")")Lexeme -> ReadPrec ()expectP(String -> LexemeL.PuncString"=")ReadPrec areadVal{-# NOINLINEreadSymField#-}-- Note [Why readField]---- Previously, the code for automatically deriving Read instance (in-- typecheck/TcGenDeriv.hs) would generate inline code for parsing fields;-- this, however, turned out to produce massive amounts of intermediate code,-- and produced a considerable performance hit in the code generator.-- Since Read instances are not generally supposed to be perfomance critical,-- the readField and readSymField functions have been factored out, and the-- code generator now just generates calls rather than manually inlining the-- parsers. For large record types (e.g. 500 fields), this produces a-- significant performance boost.---- See also #14364.---------------------------------------------------------------- Simple instances of Read---------------------------------------------------------------- | @since 2.01derivinginstanceReadGeneralCategory-- | @since 2.01instanceReadCharwherereadPrec :: ReadPrec CharreadPrec=ReadPrec Char -> ReadPrec Charforall a. ReadPrec a -> ReadPrec aparens(doL.CharCharc<-ReadPrec LexemelexPChar -> ReadPrec Charforall (m :: * -> *) a. Monad m => a -> m areturnCharc)readListPrec :: ReadPrec StringreadListPrec=ReadPrec String -> ReadPrec Stringforall a. ReadPrec a -> ReadPrec aparens(doL.StringStrings<-ReadPrec LexemelexP-- Looks for "foo"String -> ReadPrec Stringforall (m :: * -> *) a. Monad m => a -> m areturnStringsReadPrec String -> ReadPrec String -> ReadPrec Stringforall a. ReadPrec a -> ReadPrec a -> ReadPrec a+++ReadPrec Stringforall a. Read a => ReadPrec [a]readListPrecDefault-- Looks for ['f','o','o'])-- (more generous than H2010 spec)readList :: ReadS StringreadList=ReadS Stringforall a. Read a => ReadS [a]readListDefault-- | @since 2.01instanceReadBoolwherereadPrec :: ReadPrec BoolreadPrec=ReadPrec Bool -> ReadPrec Boolforall a. ReadPrec a -> ReadPrec aparens(doL.IdentStrings<-ReadPrec LexemelexPcaseStringsofString"True"->Bool -> ReadPrec Boolforall (m :: * -> *) a. Monad m => a -> m areturnBoolTrueString"False"->Bool -> ReadPrec Boolforall (m :: * -> *) a. Monad m => a -> m areturnBoolFalseString_->ReadPrec Boolforall a. ReadPrec apfail)readListPrec :: ReadPrec [Bool]readListPrec=ReadPrec [Bool]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Bool]readList=ReadS [Bool]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instanceReadOrderingwherereadPrec :: ReadPrec OrderingreadPrec=ReadPrec Ordering -> ReadPrec Orderingforall a. ReadPrec a -> ReadPrec aparens(doL.IdentStrings<-ReadPrec LexemelexPcaseStringsofString"LT"->Ordering -> ReadPrec Orderingforall (m :: * -> *) a. Monad m => a -> m areturnOrderingLTString"EQ"->Ordering -> ReadPrec Orderingforall (m :: * -> *) a. Monad m => a -> m areturnOrderingEQString"GT"->Ordering -> ReadPrec Orderingforall (m :: * -> *) a. Monad m => a -> m areturnOrderingGTString_->ReadPrec Orderingforall a. ReadPrec apfail)readListPrec :: ReadPrec [Ordering]readListPrec=ReadPrec [Ordering]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Ordering]readList=ReadS [Ordering]forall a. Read a => ReadS [a]readListDefault-- | @since 4.11.0.0derivinginstanceReada=>Read(NonEmptya)---------------------------------------------------------------- Structure instances of Read: Maybe, List etc--------------------------------------------------------------{-For structured instances of Read we start using the precedences. Theidea is then that 'parens (prec k p)' will fail immediately when tryingto parse it in a context with a higher precedence level than k. But ifthere is one parenthesis parsed, then the required precedence leveldrops to 0 again, and parsing inside p may succeed.'appPrec' is just the precedence level of function application. So,if we are parsing function application, we'd better require theprecedence level to be at least 'appPrec'. Otherwise, we have to putparentheses around it.'step' is used to increase the precedence levels inside aparser, and can be used to express left- or right- associativity. Forexample, % is defined to be left associative, so we only increaseprecedence on the right hand side.Note how step is used in for example the Maybe parser to increase theprecedence beyond appPrec, so that basically only literals andparenthesis-like objects such as (...) and [...] can be an argument to'Just'.-}-- | @since 2.01instanceReada=>Read(Maybea)wherereadPrec :: ReadPrec (Maybe a)readPrec=ReadPrec (Maybe a) -> ReadPrec (Maybe a)forall a. ReadPrec a -> ReadPrec aparens(doLexeme -> ReadPrec ()expectP(String -> LexemeL.IdentString"Nothing")Maybe a -> ReadPrec (Maybe a)forall (m :: * -> *) a. Monad m => a -> m areturnMaybe aforall a. Maybe aNothingReadPrec (Maybe a) -> ReadPrec (Maybe a) -> ReadPrec (Maybe a)forall a. ReadPrec a -> ReadPrec a -> ReadPrec a+++Int -> ReadPrec (Maybe a) -> ReadPrec (Maybe a)forall a. Int -> ReadPrec a -> ReadPrec aprecIntappPrec(doLexeme -> ReadPrec ()expectP(String -> LexemeL.IdentString"Just")ax<-ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec astepReadPrec aforall a. Read a => ReadPrec areadPrecMaybe a -> ReadPrec (Maybe a)forall (m :: * -> *) a. Monad m => a -> m areturn(a -> Maybe aforall a. a -> Maybe aJustax)))readListPrec :: ReadPrec [Maybe a]readListPrec=ReadPrec [Maybe a]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Maybe a]readList=ReadS [Maybe a]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instanceReada=>Read[a]where{-# SPECIALISEinstanceRead[String]#-}{-# SPECIALISEinstanceRead[Char]#-}{-# SPECIALISEinstanceRead[Int]#-}readPrec :: ReadPrec [a]readPrec=ReadPrec [a]forall a. Read a => ReadPrec [a]readListPrecreadListPrec :: ReadPrec [[a]]readListPrec=ReadPrec [[a]]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [[a]]readList=ReadS [[a]]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Ixa,Reada,Readb)=>Read(Arrayab)wherereadPrec :: ReadPrec (Array a b)readPrec=ReadPrec (Array a b) -> ReadPrec (Array a b)forall a. ReadPrec a -> ReadPrec aparens(ReadPrec (Array a b) -> ReadPrec (Array a b))-> ReadPrec (Array a b) -> ReadPrec (Array a b)forall a b. (a -> b) -> a -> b$Int -> ReadPrec (Array a b) -> ReadPrec (Array a b)forall a. Int -> ReadPrec a -> ReadPrec aprecIntappPrec(ReadPrec (Array a b) -> ReadPrec (Array a b))-> ReadPrec (Array a b) -> ReadPrec (Array a b)forall a b. (a -> b) -> a -> b$doLexeme -> ReadPrec ()expectP(String -> LexemeL.IdentString"array")(a, a)theBounds<-ReadPrec (a, a) -> ReadPrec (a, a)forall a. ReadPrec a -> ReadPrec astepReadPrec (a, a)forall a. Read a => ReadPrec areadPrec[(a, b)]vals<-ReadPrec [(a, b)] -> ReadPrec [(a, b)]forall a. ReadPrec a -> ReadPrec astepReadPrec [(a, b)]forall a. Read a => ReadPrec areadPrecArray a b -> ReadPrec (Array a b)forall (m :: * -> *) a. Monad m => a -> m areturn((a, a) -> [(a, b)] -> Array a bforall i e. Ix i => (i, i) -> [(i, e)] -> Array i earray(a, a)theBounds[(a, b)]vals)readListPrec :: ReadPrec [Array a b]readListPrec=ReadPrec [Array a b]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Array a b]readList=ReadS [Array a b]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instanceReadL.LexemewherereadPrec :: ReadPrec LexemereadPrec=ReadPrec LexemelexPreadListPrec :: ReadPrec [Lexeme]readListPrec=ReadPrec [Lexeme]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Lexeme]readList=ReadS [Lexeme]forall a. Read a => ReadS [a]readListDefault---------------------------------------------------------------- Numeric instances of Read--------------------------------------------------------------readNumber::Numa=>(L.Lexeme->ReadPreca)->ReadPreca-- Read a signed numberreadNumber :: (Lexeme -> ReadPrec a) -> ReadPrec areadNumberLexeme -> ReadPrec aconvert=ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec aparens(doLexemex<-ReadPrec LexemelexPcaseLexemexofL.SymbolString"-"->doLexemey<-ReadPrec LexemelexPan<-Lexeme -> ReadPrec aconvertLexemeya -> ReadPrec aforall (m :: * -> *) a. Monad m => a -> m areturn(a -> aforall a. Num a => a -> anegatean)Lexeme_->Lexeme -> ReadPrec aconvertLexemex)convertInt::Numa=>L.Lexeme->ReadPrecaconvertInt :: Lexeme -> ReadPrec aconvertInt(L.NumberNumbern)|JustIntegeri<-Number -> Maybe IntegerL.numberToIntegerNumbern=a -> ReadPrec aforall (m :: * -> *) a. Monad m => a -> m areturn(Integer -> aforall a. Num a => Integer -> afromIntegerIntegeri)convertIntLexeme_=ReadPrec aforall a. ReadPrec apfailconvertFrac::foralla.RealFloata=>L.Lexeme->ReadPrecaconvertFrac :: Lexeme -> ReadPrec aconvertFrac(L.IdentString"NaN")=a -> ReadPrec aforall (m :: * -> *) a. Monad m => a -> m areturn(a0a -> a -> aforall a. Fractional a => a -> a -> a/a0)convertFrac(L.IdentString"Infinity")=a -> ReadPrec aforall (m :: * -> *) a. Monad m => a -> m areturn(a1a -> a -> aforall a. Fractional a => a -> a -> a/a0)convertFrac(L.NumberNumbern)=letresRange :: (Int, Int)resRange=a -> (Int, Int)forall a. RealFloat a => a -> (Int, Int)floatRange(aforall a. HasCallStack => aundefined::a)incase(Int, Int) -> Number -> Maybe RationalL.numberToRangedRational(Int, Int)resRangeNumbernofMaybe RationalNothing->a -> ReadPrec aforall (m :: * -> *) a. Monad m => a -> m areturn(a1a -> a -> aforall a. Fractional a => a -> a -> a/a0)JustRationalrat->a -> ReadPrec aforall (m :: * -> *) a. Monad m => a -> m areturn(a -> ReadPrec a) -> a -> ReadPrec aforall a b. (a -> b) -> a -> b$Rational -> aforall a. Fractional a => Rational -> afromRationalRationalratconvertFracLexeme_=ReadPrec aforall a. ReadPrec apfail-- | @since 2.01instanceReadIntwherereadPrec :: ReadPrec IntreadPrec=(Lexeme -> ReadPrec Int) -> ReadPrec Intforall a. Num a => (Lexeme -> ReadPrec a) -> ReadPrec areadNumberLexeme -> ReadPrec Intforall a. Num a => Lexeme -> ReadPrec aconvertIntreadListPrec :: ReadPrec [Int]readListPrec=ReadPrec [Int]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Int]readList=ReadS [Int]forall a. Read a => ReadS [a]readListDefault-- | @since 4.5.0.0instanceReadWordwherereadsPrec :: Int -> ReadS WordreadsPrecIntpStrings=[(Integer -> Wordforall a. Num a => Integer -> afromIntegerIntegerx,Stringr)|(Integerx,Stringr)<-Int -> ReadS Integerforall a. Read a => Int -> ReadS areadsPrecIntpStrings]-- | @since 2.01instanceReadWord8wherereadsPrec :: Int -> ReadS Word8readsPrecIntpStrings=[(Int -> Word8forall a b. (Integral a, Num b) => a -> bfromIntegral(Intx::Int),Stringr)|(Intx,Stringr)<-Int -> ReadS Intforall a. Read a => Int -> ReadS areadsPrecIntpStrings]-- | @since 2.01instanceReadWord16wherereadsPrec :: Int -> ReadS Word16readsPrecIntpStrings=[(Int -> Word16forall a b. (Integral a, Num b) => a -> bfromIntegral(Intx::Int),Stringr)|(Intx,Stringr)<-Int -> ReadS Intforall a. Read a => Int -> ReadS areadsPrecIntpStrings]-- | @since 2.01instanceReadWord32where#if WORD_SIZE_IN_BITS < 33readsPrecps=[(fromIntegerx,r)|(x,r)<-readsPrecps]#elsereadsPrec :: Int -> ReadS Word32readsPrecIntpStrings=[(Int -> Word32forall a b. (Integral a, Num b) => a -> bfromIntegral(Intx::Int),Stringr)|(Intx,Stringr)<-Int -> ReadS Intforall a. Read a => Int -> ReadS areadsPrecIntpStrings]#endif-- | @since 2.01instanceReadWord64wherereadsPrec :: Int -> ReadS Word64readsPrecIntpStrings=[(Integer -> Word64forall a. Num a => Integer -> afromIntegerIntegerx,Stringr)|(Integerx,Stringr)<-Int -> ReadS Integerforall a. Read a => Int -> ReadS areadsPrecIntpStrings]-- | @since 2.01instanceReadIntegerwherereadPrec :: ReadPrec IntegerreadPrec=(Lexeme -> ReadPrec Integer) -> ReadPrec Integerforall a. Num a => (Lexeme -> ReadPrec a) -> ReadPrec areadNumberLexeme -> ReadPrec Integerforall a. Num a => Lexeme -> ReadPrec aconvertIntreadListPrec :: ReadPrec [Integer]readListPrec=ReadPrec [Integer]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Integer]readList=ReadS [Integer]forall a. Read a => ReadS [a]readListDefault-- | @since 4.8.0.0instanceReadNaturalwherereadsPrec :: Int -> ReadS NaturalreadsPrecIntd=((Integer, String) -> (Natural, String))-> [(Integer, String)] -> [(Natural, String)]forall a b. (a -> b) -> [a] -> [b]map(\(Integern,Strings)->(Integer -> Naturalforall a. Num a => Integer -> afromIntegerIntegern,Strings))([(Integer, String)] -> [(Natural, String)])-> ReadS Integer -> ReadS Naturalforall b c a. (b -> c) -> (a -> b) -> a -> c.((Integer, String) -> Bool)-> [(Integer, String)] -> [(Integer, String)]forall a. (a -> Bool) -> [a] -> [a]filter((Integer -> Integer -> Boolforall a. Ord a => a -> a -> Bool>=Integer0)(Integer -> Bool)-> ((Integer, String) -> Integer) -> (Integer, String) -> Boolforall b c a. (b -> c) -> (a -> b) -> a -> c.(\(Integerx,String_)->Integerx))([(Integer, String)] -> [(Integer, String)])-> ReadS Integer -> ReadS Integerforall b c a. (b -> c) -> (a -> b) -> a -> c.Int -> ReadS Integerforall a. Read a => Int -> ReadS areadsPrecIntd-- | @since 2.01instanceReadFloatwherereadPrec :: ReadPrec FloatreadPrec=(Lexeme -> ReadPrec Float) -> ReadPrec Floatforall a. Num a => (Lexeme -> ReadPrec a) -> ReadPrec areadNumberLexeme -> ReadPrec Floatforall a. RealFloat a => Lexeme -> ReadPrec aconvertFracreadListPrec :: ReadPrec [Float]readListPrec=ReadPrec [Float]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Float]readList=ReadS [Float]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instanceReadDoublewherereadPrec :: ReadPrec DoublereadPrec=(Lexeme -> ReadPrec Double) -> ReadPrec Doubleforall a. Num a => (Lexeme -> ReadPrec a) -> ReadPrec areadNumberLexeme -> ReadPrec Doubleforall a. RealFloat a => Lexeme -> ReadPrec aconvertFracreadListPrec :: ReadPrec [Double]readListPrec=ReadPrec [Double]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Double]readList=ReadS [Double]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Integrala,Reada)=>Read(Ratioa)wherereadPrec :: ReadPrec (Ratio a)readPrec=ReadPrec (Ratio a) -> ReadPrec (Ratio a)forall a. ReadPrec a -> ReadPrec aparens(Int -> ReadPrec (Ratio a) -> ReadPrec (Ratio a)forall a. Int -> ReadPrec a -> ReadPrec aprecIntratioPrec(doax<-ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec astepReadPrec aforall a. Read a => ReadPrec areadPrecLexeme -> ReadPrec ()expectP(String -> LexemeL.SymbolString"%")ay<-ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec astepReadPrec aforall a. Read a => ReadPrec areadPrecRatio a -> ReadPrec (Ratio a)forall (m :: * -> *) a. Monad m => a -> m areturn(axa -> a -> Ratio aforall a. Integral a => a -> a -> Ratio a%ay)))readListPrec :: ReadPrec [Ratio a]readListPrec=ReadPrec [Ratio a]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [Ratio a]readList=ReadS [Ratio a]forall a. Read a => ReadS [a]readListDefault-------------------------------------------------------------------------- Tuple instances of Read, up to size 15-------------------------------------------------------------------------- | @since 2.01instanceRead()wherereadPrec :: ReadPrec ()readPrec=ReadPrec () -> ReadPrec ()forall a. ReadPrec a -> ReadPrec aparens(ReadPrec () -> ReadPrec ()forall a. ReadPrec a -> ReadPrec aparen(() -> ReadPrec ()forall (m :: * -> *) a. Monad m => a -> m areturn()))readListPrec :: ReadPrec [()]readListPrec=ReadPrec [()]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [()]readList=ReadS [()]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb)=>Read(a,b)wherereadPrec :: ReadPrec (a, b)readPrec=ReadPrec (a, b) -> ReadPrec (a, b)forall a. ReadPrec a -> ReadPrec awrap_tupReadPrec (a, b)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2readListPrec :: ReadPrec [(a, b)]readListPrec=ReadPrec [(a, b)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b)]readList=ReadS [(a, b)]forall a. Read a => ReadS [a]readListDefaultwrap_tup::ReadPreca->ReadPrecawrap_tup :: ReadPrec a -> ReadPrec awrap_tupReadPrec ap=ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec aparens(ReadPrec a -> ReadPrec aforall a. ReadPrec a -> ReadPrec aparenReadPrec ap)read_comma::ReadPrec()read_comma :: ReadPrec ()read_comma=Lexeme -> ReadPrec ()expectP(String -> LexemeL.PuncString",")read_tup2::(Reada,Readb)=>ReadPrec(a,b)-- Reads "a , b" no parens!read_tup2 :: ReadPrec (a, b)read_tup2=doax<-ReadPrec aforall a. Read a => ReadPrec areadPrecReadPrec ()read_commaby<-ReadPrec bforall a. Read a => ReadPrec areadPrec(a, b) -> ReadPrec (a, b)forall (m :: * -> *) a. Monad m => a -> m areturn(ax,by)read_tup4::(Reada,Readb,Readc,Readd)=>ReadPrec(a,b,c,d)read_tup4 :: ReadPrec (a, b, c, d)read_tup4=do(aa,bb)<-ReadPrec (a, b)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2ReadPrec ()read_comma(cc,dd)<-ReadPrec (c, d)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2(a, b, c, d) -> ReadPrec (a, b, c, d)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd)read_tup8::(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh)=>ReadPrec(a,b,c,d,e,f,g,h)read_tup8 :: ReadPrec (a, b, c, d, e, f, g, h)read_tup8=do(aa,bb,cc,dd)<-ReadPrec (a, b, c, d)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4ReadPrec ()read_comma(ee,ff,gg,hh)<-ReadPrec (e, f, g, h)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4(a, b, c, d, e, f, g, h) -> ReadPrec (a, b, c, d, e, f, g, h)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh)-- | @since 2.01instance(Reada,Readb,Readc)=>Read(a,b,c)wherereadPrec :: ReadPrec (a, b, c)readPrec=ReadPrec (a, b, c) -> ReadPrec (a, b, c)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb)<-ReadPrec (a, b)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2;ReadPrec ()read_comma;cc<-ReadPrec cforall a. Read a => ReadPrec areadPrec;(a, b, c) -> ReadPrec (a, b, c)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc)})readListPrec :: ReadPrec [(a, b, c)]readListPrec=ReadPrec [(a, b, c)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c)]readList=ReadS [(a, b, c)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd)=>Read(a,b,c,d)wherereadPrec :: ReadPrec (a, b, c, d)readPrec=ReadPrec (a, b, c, d) -> ReadPrec (a, b, c, d)forall a. ReadPrec a -> ReadPrec awrap_tupReadPrec (a, b, c, d)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4readListPrec :: ReadPrec [(a, b, c, d)]readListPrec=ReadPrec [(a, b, c, d)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d)]readList=ReadS [(a, b, c, d)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade)=>Read(a,b,c,d,e)wherereadPrec :: ReadPrec (a, b, c, d, e)readPrec=ReadPrec (a, b, c, d, e) -> ReadPrec (a, b, c, d, e)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd)<-ReadPrec (a, b, c, d)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4;ReadPrec ()read_comma;ee<-ReadPrec eforall a. Read a => ReadPrec areadPrec;(a, b, c, d, e) -> ReadPrec (a, b, c, d, e)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee)})readListPrec :: ReadPrec [(a, b, c, d, e)]readListPrec=ReadPrec [(a, b, c, d, e)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e)]readList=ReadS [(a, b, c, d, e)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf)=>Read(a,b,c,d,e,f)wherereadPrec :: ReadPrec (a, b, c, d, e, f)readPrec=ReadPrec (a, b, c, d, e, f) -> ReadPrec (a, b, c, d, e, f)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd)<-ReadPrec (a, b, c, d)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4;ReadPrec ()read_comma;(ee,ff)<-ReadPrec (e, f)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2;(a, b, c, d, e, f) -> ReadPrec (a, b, c, d, e, f)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff)})readListPrec :: ReadPrec [(a, b, c, d, e, f)]readListPrec=ReadPrec [(a, b, c, d, e, f)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f)]readList=ReadS [(a, b, c, d, e, f)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg)=>Read(a,b,c,d,e,f,g)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g)readPrec=ReadPrec (a, b, c, d, e, f, g) -> ReadPrec (a, b, c, d, e, f, g)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd)<-ReadPrec (a, b, c, d)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4;ReadPrec ()read_comma;(ee,ff)<-ReadPrec (e, f)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2;ReadPrec ()read_comma;gg<-ReadPrec gforall a. Read a => ReadPrec areadPrec;(a, b, c, d, e, f, g) -> ReadPrec (a, b, c, d, e, f, g)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g)]readListPrec=ReadPrec [(a, b, c, d, e, f, g)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g)]readList=ReadS [(a, b, c, d, e, f, g)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh)=>Read(a,b,c,d,e,f,g,h)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h)readPrec=ReadPrec (a, b, c, d, e, f, g, h)-> ReadPrec (a, b, c, d, e, f, g, h)forall a. ReadPrec a -> ReadPrec awrap_tupReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h)]readList=ReadS [(a, b, c, d, e, f, g, h)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh,Readi)=>Read(a,b,c,d,e,f,g,h,i)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h, i)readPrec=ReadPrec (a, b, c, d, e, f, g, h, i)-> ReadPrec (a, b, c, d, e, f, g, h, i)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd,ee,ff,gg,hh)<-ReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8;ReadPrec ()read_comma;ii<-ReadPrec iforall a. Read a => ReadPrec areadPrec;(a, b, c, d, e, f, g, h, i) -> ReadPrec (a, b, c, d, e, f, g, h, i)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh,ii)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h, i)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h, i)]readList=ReadS [(a, b, c, d, e, f, g, h, i)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh,Readi,Readj)=>Read(a,b,c,d,e,f,g,h,i,j)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j)readPrec=ReadPrec (a, b, c, d, e, f, g, h, i, j)-> ReadPrec (a, b, c, d, e, f, g, h, i, j)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd,ee,ff,gg,hh)<-ReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8;ReadPrec ()read_comma;(ii,jj)<-ReadPrec (i, j)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2;(a, b, c, d, e, f, g, h, i, j)-> ReadPrec (a, b, c, d, e, f, g, h, i, j)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh,ii,jj)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h, i, j)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h, i, j)]readList=ReadS [(a, b, c, d, e, f, g, h, i, j)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh,Readi,Readj,Readk)=>Read(a,b,c,d,e,f,g,h,i,j,k)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k)readPrec=ReadPrec (a, b, c, d, e, f, g, h, i, j, k)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd,ee,ff,gg,hh)<-ReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8;ReadPrec ()read_comma;(ii,jj)<-ReadPrec (i, j)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2;ReadPrec ()read_comma;kk<-ReadPrec kforall a. Read a => ReadPrec areadPrec;(a, b, c, d, e, f, g, h, i, j, k)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h, i, j, k)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k)]readList=ReadS [(a, b, c, d, e, f, g, h, i, j, k)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh,Readi,Readj,Readk,Readl)=>Read(a,b,c,d,e,f,g,h,i,j,k,l)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l)readPrec=ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd,ee,ff,gg,hh)<-ReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8;ReadPrec ()read_comma;(ii,jj,kk,ll)<-ReadPrec (i, j, k, l)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4;(a, b, c, d, e, f, g, h, i, j, k, l)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l)]readList=ReadS [(a, b, c, d, e, f, g, h, i, j, k, l)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh,Readi,Readj,Readk,Readl,Readm)=>Read(a,b,c,d,e,f,g,h,i,j,k,l,m)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m)readPrec=ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd,ee,ff,gg,hh)<-ReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8;ReadPrec ()read_comma;(ii,jj,kk,ll)<-ReadPrec (i, j, k, l)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4;ReadPrec ()read_comma;mm<-ReadPrec mforall a. Read a => ReadPrec areadPrec;(a, b, c, d, e, f, g, h, i, j, k, l, m)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m)]readList=ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh,Readi,Readj,Readk,Readl,Readm,Readn)=>Read(a,b,c,d,e,f,g,h,i,j,k,l,m,n)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n)readPrec=ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd,ee,ff,gg,hh)<-ReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8;ReadPrec ()read_comma;(ii,jj,kk,ll)<-ReadPrec (i, j, k, l)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4;ReadPrec ()read_comma;(mm,nn)<-ReadPrec (m, n)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2;(a, b, c, d, e, f, g, h, i, j, k, l, m, n)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)]readList=ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n)]forall a. Read a => ReadS [a]readListDefault-- | @since 2.01instance(Reada,Readb,Readc,Readd,Reade,Readf,Readg,Readh,Readi,Readj,Readk,Readl,Readm,Readn,Reado)=>Read(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)wherereadPrec :: ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)readPrec=ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)forall a. ReadPrec a -> ReadPrec awrap_tup(do{(aa,bb,cc,dd,ee,ff,gg,hh)<-ReadPrec (a, b, c, d, e, f, g, h)forall a b c d e f g h.(Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h) =>ReadPrec (a, b, c, d, e, f, g, h)read_tup8;ReadPrec ()read_comma;(ii,jj,kk,ll)<-ReadPrec (i, j, k, l)forall a b c d.(Read a, Read b, Read c, Read d) =>ReadPrec (a, b, c, d)read_tup4;ReadPrec ()read_comma;(mm,nn)<-ReadPrec (m, n)forall a b. (Read a, Read b) => ReadPrec (a, b)read_tup2;ReadPrec ()read_comma;oo<-ReadPrec oforall a. Read a => ReadPrec areadPrec;(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)-> ReadPrec (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)forall (m :: * -> *) a. Monad m => a -> m areturn(aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,kk,ll,mm,nn,oo)})readListPrec :: ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)]readListPrec=ReadPrec [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)]forall a. Read a => ReadPrec [a]readListPrecDefaultreadList :: ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)]readList=ReadS [(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)]forall a. Read a => ReadS [a]readListDefault
[8]ページ先頭