Skip to content
Snippets Groups Projects
Commit 55e0bdb4 authored by sof's avatar sof
Browse files

[project @ 1999-01-14 16:55:16 by sof]

Added indexFS,

   indexFS :: FastString -> Int -> Char
parent 6e2d8924
No related merge requests found
......@@ -39,6 +39,7 @@ module FastString
tailFS, -- :: FastString -> FastString
concatFS, -- :: [FastString] -> FastString
consFS, -- :: Char -> FastString -> FastString
indexFS, -- :: FastString -> Int -> Char
hPutFS -- :: Handle -> FastString -> IO ()
) where
......@@ -176,6 +177,18 @@ headFS f@(FastString _ l# ba#) =
headFS f@(CharStr a# l#) =
if l# ># 0# then C# (indexCharOffAddr# a# 0#) else error ("headFS: empty FS: " ++ unpackFS f)
indexFS :: FastString -> Int -> Char
indexFS f i@(I# i#) =
case f of
FastString _ l# ba#
| l# ># 0# && l# ># i# -> C# (indexCharArray# ba# i#)
| otherwise -> error (msg (I# l#))
CharStr a# l#
| l# ># 0# && l# ># i# -> C# (indexCharOffAddr# a# i#)
| otherwise -> error (msg (I# l#))
where
msg l = "indexFS: out of range: " ++ show (l,i)
tailFS :: FastString -> FastString
tailFS (FastString _ l# ba#) = mkFastSubStringBA# ba# 1# (l# -# 1#)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment