lazyReadChar :: Handle -> PrimIO String
lazyReadBlock handle =
- ioToST (readHandle handle) >>= \ htype ->
+ ioToST (readHandle handle) >>= \ htype ->
case htype of
-- There cannae be an ErrorHandle here
ClosedHandle ->
returnPrimIO (unpackPS some ++ more)
lazyReadLine handle =
- ioToST (readHandle handle) >>= \ htype ->
+ ioToST (readHandle handle) >>= \ htype ->
case htype of
-- There cannae be an ErrorHandle here
ClosedHandle ->
returnPrimIO (unpackPS some ++ more)
lazyReadChar handle =
- ioToST (readHandle handle) >>= \ htype ->
+ ioToST (readHandle handle) >>= \ htype ->
case htype of
-- There cannae be an ErrorHandle here
ClosedHandle ->
unsafeInterleavePrimIO (lazyReadChar handle)
>>= \ more ->
returnPrimIO (chr char : more)
+
\end{code}
writeHandle handle htype >>
fail (IOError (Just handle) IllegalOperation "handle is not open for writing")
other ->
+ {-
+ The code below is not correct for line-buffered terminal streams,
+ as the output stream is not flushed when terminal input is requested
+ again, just upon seeing a newline character. A temporary fix for the
+ most common line-buffered output stream, stdout, is to assume the
+ buffering it was given when created (no buffering). This is not
+ as bad as it looks, since stdio buffering sits underneath this.
+
+ ToDo: fix me
+ -}
getBufferMode other `thenIO_Prim` \ other ->
(case bufferMode other of
Just LineBuffering ->
- writeLines (filePtr other) str
+ writeChars (filePtr other) str
+ --writeLines (filePtr other) str
Just (BlockBuffering (Just size)) ->
writeBlocks (filePtr other) size str
Just (BlockBuffering Nothing) ->
((C# x):xs) ->
write_char arr# n x >>
- {- Flushing lines - should we bother? -}
- if n ==# bufLen {- || (chopOnNewLine && (x `eqChar#` '\n'#)) -} then
+ {- Flushing lines - should we bother? Yes, for line-buffered output. -}
+ if n ==# bufLen || (chopOnNewLine && (x `eqChar#` '\n'#)) then
_ccall_ writeFile arr fp (I# (n +# 1#)) >>= \ rc ->
if rc == 0 then
shoveString 0# xs
--- /dev/null
+%
+% (c) The GRASP/AQUA Project, Glasgow University, 1995-97
+%
+\section[Time]{Haskell 1.4 Locale Library}
+
+
+\begin{code}
+module Locale(TimeLocale(..), defaultTimeLocale) where
+
+data TimeLocale = TimeLocale {
+ wDays :: [(String, String)], -- full and abbreviated week days
+ months :: [(String, String)], -- full and abbreviated months
+ amPm :: (String, String), -- AM/PM symbols
+ dateTimeFmt, dateFmt, -- formatting strings
+ timeFmt, time12Fmt :: String
+ } deriving (Eq, Ord, Show)
+
+defaultTimeLocale :: TimeLocale
+defaultTimeLocale = TimeLocale {
+ wDays = [("Sunday", "Sun"), ("Monday", "Mon"),
+ ("Tuesday", "Tue"), ("Wednesday", "Wed"),
+ ("Thursday", "Thu"), ("Friday", "Fri"),
+ ("Saturday", "Sat")],
+
+ months = [("January", "Jan"), ("February", "Feb"),
+ ("March", "Mar"), ("April", "Apr"),
+ ("May", "May"), ("June", "Jun"),
+ ("July", "Jul"), ("August", "Aug"),
+ ("September", "Sep"), ("October", "Oct"),
+ ("November", "Nov"), ("December", "Dec")],
+
+ amPm = ("AM", "PM"),
+ dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y",
+ dateFmt = "%m/%d/%y",
+ timeFmt = "%H:%M:%S",
+ time12Fmt = "%I:%M:%S %p"
+ }
+
+\end{code}