[project @ 2002-05-10 08:58:34 by simonmar]
authorsimonmar <unknown>
Fri, 10 May 2002 08:58:35 +0000 (08:58 +0000)
committersimonmar <unknown>
Fri, 10 May 2002 08:58:35 +0000 (08:58 +0000)
Convert these files from .lhs to .hs, and give them proper headers to
match the style used in the rest of the libraries.

Text/ParserCombinators/ReadP.hs [moved from Text/ParserCombinators/ReadP.lhs with 74% similarity]
Text/ParserCombinators/ReadPrec.hs [moved from Text/ParserCombinators/ReadPrec.lhs with 73% similarity]
Text/Read/Lex.hs [moved from Text/Read/Lex.lhs with 89% similarity]

similarity index 74%
rename from Text/ParserCombinators/ReadP.lhs
rename to Text/ParserCombinators/ReadP.hs
index 98565b6..d926ef1 100644 (file)
@@ -1,20 +1,27 @@
-% -------------------------------------------------------------
-% $Id: ReadP.lhs
-%
-% (c) The University of Glasgow, 1994-2000
-%
-
-\begin{code}
-{-# OPTIONS -fglasgow-exts -fno-implicit-prelude #-}
+{-# OPTIONS -fno-implicit-prelude #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Text.ParserCombinators.ReadP
+-- Copyright   :  (c) The University of Glasgow 2002
+-- License     :  BSD-style (see the file libraries/base/LICENSE)
+-- 
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-----------------------------------------------------------------------------
+
 module Text.ParserCombinators.ReadP
-  ( ReadP      -- :: * -> *; instance Functor, Monad, MonadPlus
+  ( 
+  -- * The 'ReadP' type
+    ReadP      -- :: * -> *; instance Functor, Monad, MonadPlus
   
-  -- primitive operations
+  -- * Primitive operations
   , get        -- :: ReadP Char
   , look       -- :: ReadP String
   , (+++)      -- :: ReadP a -> ReadP a -> ReadP a
   
-  -- other operations
+  -- * Other operations
   , pfail      -- :: ReadP a
   , satisfy    -- :: (Char -> Bool) -> ReadP Char
   , char       -- :: Char -> ReadP Char
@@ -24,7 +31,7 @@ module Text.ParserCombinators.ReadP
   , skipSpaces -- :: ReadP ()
   , choice     -- :: [ReadP a] -> ReadP a
   
-  -- converting
+  -- * Conversions
   , readP_to_S -- :: ReadP a -> ReadS a
   , readS_to_P -- :: ReadS a -> ReadP a
   )
@@ -33,16 +40,10 @@ module Text.ParserCombinators.ReadP
 import Control.Monad( MonadPlus(..) )
 import GHC.Show( isSpace  )
 import GHC.Base
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{The @ReadP@ type}
-%*                                                     *
-%*********************************************************
+-- ---------------------------------------------------------------------------
+-- The ReadP type
 
-\begin{code}
 newtype ReadP a = R (forall b . (a -> P b) -> P b)
 
 data P a
@@ -69,16 +70,10 @@ instance Monad ReadP where
 instance MonadPlus ReadP where
   mzero = pfail
   mplus = (+++)
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{Operations over ReadP}
-%*                                                     *
-%*********************************************************
+-- ---------------------------------------------------------------------------
+-- Operations over ReadP
 
-\begin{code}
 get :: ReadP Char
 get = R (\k -> Get k)
 
@@ -105,16 +100,10 @@ run (Look f)     s     = run (f s) s
 run (Result x p) s     = (x,s) : run p s
 run (ReadS r)    s     = r s
 run Fail         _     = []
-\end{code}
 
+-- ---------------------------------------------------------------------------
+-- Derived operations
 
-%*********************************************************
-%*                                                     *
-\subsection{Derived operations}
-%*                                                     *
-%*********************************************************
-
-\begin{code}
 pfail :: ReadP a
 pfail = fail ""
 
@@ -155,16 +144,10 @@ skipSpaces =
  where
   skip (c:s) | isSpace c = do get; skip s
   skip _                 = do return ()
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{Converting between ReadP and ReadS
-%*                                                     *
-%*********************************************************
+-- ---------------------------------------------------------------------------
+-- Converting between ReadP and Read
 
-\begin{code}
 readP_to_S :: ReadP a -> ReadS a
 readP_to_S (R f) = run (f (\x -> Result x Fail))
 
@@ -173,4 +156,3 @@ readS_to_P r = R (\k -> ReadS (\s -> [ bs''
                                      | (a,s') <- r s
                                      , bs''   <- run (k a) s'
                                      ]))
-\end{code}
\ No newline at end of file
similarity index 73%
rename from Text/ParserCombinators/ReadPrec.lhs
rename to Text/ParserCombinators/ReadPrec.hs
index dcfef79..bfb4fc2 100644 (file)
@@ -1,26 +1,30 @@
-% ----------------------------------------------------------------
-% $Id: ReadPrec.lhs
-%
-% (c) The University of Glasgow, 1994-2000
-%
-
-\begin{code}
 {-# OPTIONS -fno-implicit-prelude #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Text.ParserCombinators.ReadPrec
+-- Copyright   :  (c) The University of Glasgow 2002
+-- License     :  BSD-style (see the file libraries/base/LICENSE)
+-- 
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-----------------------------------------------------------------------------
 
 module Text.ParserCombinators.ReadPrec
   ( ReadPrec      -- :: * -> *; instance Functor, Monad, MonadPlus
   
-  -- precedences
+  -- * Precedences
   , Prec          -- :: *; = Int
   , minPrec       -- :: Prec; = 0
 
-  -- primitive operations
+  -- * Primitive operations
   , lift          -- :: ReadP a -> ReadPrec a
   , prec          -- :: Prec -> ReadPrec a -> ReadPrec a
   , step          -- :: ReadPrec a -> ReadPrec a
   , reset         -- :: ReadPrec a -> ReadPrec a
 
-  -- other operations
+  -- * Other operations
   , get           -- :: ReadPrec Char
   , look          -- :: ReadPrec String
   , (+++)         -- :: ReadPrec a -> ReadPrec a -> ReadPrec a
@@ -53,16 +57,10 @@ import qualified Text.ParserCombinators.ReadP as ReadP
 import Control.Monad( MonadPlus(..) )
 import GHC.Num( Num(..) )
 import GHC.Base
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{The readPrec type}
-%*                                                     *
-%*********************************************************
+-- ---------------------------------------------------------------------------
+-- The readPrec type
 
-\begin{code}
 newtype ReadPrec a = P { unP :: Prec -> ReadP a }
 
 -- Functor, Monad, MonadPlus
@@ -85,16 +83,10 @@ type Prec = Int
 
 minPrec :: Prec
 minPrec = 0
-\end{code}
 
+-- ---------------------------------------------------------------------------
+-- Operations over ReadPrec
 
-%*********************************************************
-%*                                                     *
-\subsection{Operations over ReadPrec
-%*                                                     *
-%*********************************************************
-
-\begin{code}
 lift :: ReadP a -> ReadPrec a
 lift m = P (\_ -> m)
 
@@ -112,15 +104,10 @@ prec :: Prec -> ReadPrec a -> ReadPrec a
 --     if not, fails
 --     if so, parses p in context n
 prec n (P f) = P (\c -> if c <= n then f n else ReadP.pfail)
-\end{code}
 
-%*********************************************************
-%*                                                     *
-\subsection{Derived operations}
-%*                                                     *
-%*********************************************************
+-- ---------------------------------------------------------------------------
+-- Derived operations
 
-\begin{code}
 get :: ReadPrec Char
 get = lift ReadP.get
 
@@ -135,16 +122,10 @@ pfail = lift ReadP.pfail
 
 choice :: [ReadPrec a] -> ReadPrec a
 choice ps = foldr (+++) pfail ps
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{Converting between ReadPrec and ReadS
-%*                                                     *
-%*********************************************************
+-- ---------------------------------------------------------------------------
+-- Converting between ReadPrec and Read
 
-\begin{code}
 -- We define a local version of ReadS here,
 -- because its "real" definition site is in GHC.Read
 type ReadS a = String -> [(a,String)]
@@ -160,4 +141,3 @@ readPrec_to_S (P f) n = readP_to_S (f n)
 
 readS_to_Prec :: (Int -> ReadS a) -> ReadPrec a
 readS_to_Prec f = P (\n -> readS_to_P (f n))
-\end{code}
similarity index 89%
rename from Text/Read/Lex.lhs
rename to Text/Read/Lex.hs
index 6ad7ce0..5442f36 100644 (file)
@@ -1,11 +1,17 @@
-% ----------------------------------------------------------------
-% $Id: Lex.lhs
-%
-% (c) The University of Glasgow, 1994-2000
-%
-
-\begin{code}
 {-# OPTIONS -fno-implicit-prelude #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Text.Read.Lex
+-- Copyright   :  (c) The University of Glasgow 2002
+-- License     :  BSD-style (see the file libraries/base/LICENSE)
+-- 
+-- Maintainer  :  libraries@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- The cut-down Haskell lexer, used by Text.Read
+--
+-----------------------------------------------------------------------------
 
 module Text.Read.Lex
   -- lexing types
@@ -48,15 +54,10 @@ import GHC.Enum( minBound, maxBound )
 import Data.Maybe
 import Data.Either
 import Control.Monad
-\end{code}
 
-%*********************************************************
-%*                                                     *
-\subsection{Lexing types}
-%*                                                     *
-%*********************************************************
+-- -----------------------------------------------------------------------------
+-- Lexing types
 
-\begin{code}
 type LexP = ReadP Lexeme
 
 data Lexeme
@@ -75,16 +76,10 @@ instance Show Lexeme where
   showsPrec _ (Ident s)  = showString s
   showsPrec _ (Symbol s) = showString s
   showsPrec n (Number x) = showsPrec n x
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{Lexing}
-%*                                                     *
-%*********************************************************
+-- -----------------------------------------------------------------------------
+-- Lexing
 
-\begin{code}
 lex :: LexP
 lex =
   do skipSpaces
@@ -94,10 +89,8 @@ lex =
            +++ lexSymbol
              +++ lexIdf
                +++ lexNumber)
-\end{code}
 
-\begin{code}
-------------------------------------------------------------------------
+-- ----------------------------------------------------------------------
 -- symbols
 
 lexSymbol :: LexP
@@ -107,7 +100,7 @@ lexSymbol =
  where
   isSymbolChar c = c `elem` "!@#$%&*+./<=>?\\^|:-~"
 
-------------------------------------------------------------------------
+-- ----------------------------------------------------------------------
 -- identifiers
 
 lexIdf :: LexP
@@ -117,18 +110,9 @@ lexIdf =
      return (Ident (c:s))
  where
   isIdfChar c = isAlphaNum c || c `elem` "_'"
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{Lexing characters and strings}
-%*                                                     *
-%*********************************************************
-
-\begin{code}
-------------------------------------------------------------------------
--- char literal
+-- ---------------------------------------------------------------------------
+-- Lexing character literals
 
 lexLitChar :: LexP
 lexLitChar =
@@ -255,7 +239,8 @@ lexChar =
          , string "DEL" >> return '\DEL'
          ]
 
-------------------------------------------------------------------------
+
+-- ---------------------------------------------------------------------------
 -- string literal
 
 lexString :: LexP
@@ -281,7 +266,7 @@ lexString =
          _ | isSpace c -> do skipSpaces; char '\\'; return ()
          _             -> do pfail
 
-------------------------------------------------------------------------
+-- ---------------------------------------------------------------------------
 -- single character lexemes
 
 lexSingle :: LexP
@@ -290,16 +275,10 @@ lexSingle =
      return (Single c)
  where
   isSingleChar c = c `elem` ",;()[]{=}_`"
-\end{code}
-
 
-%*********************************************************
-%*                                                     *
-\subsection{Lexing numbers}
-%*                                                     *
-%*********************************************************
+-- ---------------------------------------------------------------------------
+--  Lexing numbers
 
-\begin{code}
 data Number
   = MkNumber
     { value    :: Either Integer Rational
@@ -445,7 +424,7 @@ valDig 16 c
   | 'A' <= c && c <= 'F' = Just (ord c - ord 'A' + 10)
   | otherwise            = Nothing
 
-------------------------------------------------------------------------
+-- ----------------------------------------------------------------------
 -- conversion
 
 numberToInt :: Number -> Maybe Int
@@ -481,7 +460,7 @@ numberToDouble x =
     Left n  -> Just (fromInteger n)
     Right r -> Just (fromRational r)
 
-------------------------------------------------------------------------
+-- ----------------------------------------------------------------------
 -- other numeric lexing functions
 
 readIntP :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadP a
@@ -499,4 +478,3 @@ readOctP, readDecP, readHexP :: Num a => ReadP a
 readOctP = readIntP' 8
 readDecP = readIntP' 10
 readHexP = readIntP' 16
-\end{code}