Movatterモバイル変換


[0]ホーム

URL:


{-# LANGUAGE Trustworthy #-}{-# LANGUAGE CPP, NoImplicitPrelude #-}------------------------------------------------------------------------------- |-- Module      :  Text.Read-- Copyright   :  (c) The University of Glasgow 2001-- License     :  BSD-style (see the file libraries/base/LICENSE)---- Maintainer  :  libraries@haskell.org-- Stability   :  provisional-- Portability :  non-portable (uses Text.ParserCombinators.ReadP)---- Converting strings to values.---- The "Text.Read" library is the canonical library to import for-- 'Read'-class facilities.  For GHC only, it offers an extended and much-- improved 'Read' class, which constitutes a proposed alternative to the-- Haskell 98 'Read'.  In particular, writing parsers is easier, and-- the parsers are much more efficient.-------------------------------------------------------------------------------moduleText.Read(-- * The 'Read' classRead(..),-- The Read classReadS,-- String -> Maybe (a,String)-- * Haskell 98 functionsreads,-- :: (Read a) => ReadS aread,-- :: (Read a) => String -> areadParen,-- :: Bool -> ReadS a -> ReadS alex,-- :: ReadS String#if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)-- * New parsing functionsmoduleText.ParserCombinators.ReadPrec,L.Lexeme(..),lexP,-- :: ReadPrec Lexemeparens,-- :: ReadPrec a -> ReadPrec a#endif#ifdef __GLASGOW_HASKELL__readListDefault,-- :: Read a => ReadS [a]readListPrecDefault,-- :: Read a => ReadPrec [a]#endif)where#ifdef __GLASGOW_HASKELL__importGHC.BaseimportGHC.ReadimportData.EitherimportText.ParserCombinators.ReadPasP#endif#if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)importText.ParserCombinators.ReadPrecimportqualifiedText.Read.LexasL#endif#ifdef __HUGS__-- copied from GHC.ReadlexP::ReadPrecL.LexemelexP=liftL.lexparens::ReadPreca->ReadPrecaparensp=optionalwhereoptional=p+++mandatorymandatory=doL.Punc"("<-lexPx<-resetoptionalL.Punc")"<-lexPreturnx#endif#ifdef __GLASGOW_HASKELL__-------------------------------------------------------------------------- utility functions-- | equivalent to 'readsPrec' with a precedence of 0.reads::Reada=>ReadSareads=readsPrecminPrecreadEither::Reada=>String->EitherStringareadEithers=case[x|(x,"")<-readPrec_to_Sread'minPrecs]of[x]->Rightx[]->Left"Prelude.read: no parse"_->Left"Prelude.read: ambiguous parse"whereread'=dox<-readPrecliftP.skipSpacesreturnx-- | The 'read' function reads input from a string, which must be-- completely consumed by the input process.read::Reada=>String->areads=eithererrorid(readEithers)#endif

[8]ページ先頭

©2009-2025 Movatter.jp