Make package work with base-4.3 and mtl-2
Ignore-this: 85b05556d0b7b5968d2d0340ea9daf5d darcs-hash:20110425123827-a4fee-dd4f4c2a305d9937316b57dbe50ce154494032ac
This commit is contained in:
parent
ce0aa549b7
commit
44f3f083aa
@ -101,20 +101,15 @@ instance ByteSink PutME where
|
|||||||
pushWord64be w = PutME $ Right (putWord64be w,())
|
pushWord64be w = PutME $ Right (putWord64be w,())
|
||||||
pushWord64le w = PutME $ Right (putWord64le w,())
|
pushWord64le w = PutME $ Right (putWord64le w,())
|
||||||
|
|
||||||
#ifndef MIN_VERSION_mtl(2,0,0,0)
|
#if MIN_VERSION_base(4,3,0)
|
||||||
|
#else
|
||||||
instance Monad (Either EncodingException) where
|
instance Monad (Either EncodingException) where
|
||||||
return x = Right x
|
return x = Right x
|
||||||
Left err >>= g = Left err
|
Left err >>= g = Left err
|
||||||
Right x >>= g = g x
|
Right x >>= g = g x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
instance Throws EncodingException (State (Seq Char)) where
|
instance (Monad m,Throws EncodingException m) => ByteSink (StateT (Seq Char) m) where
|
||||||
throwException = throw
|
|
||||||
|
|
||||||
instance ByteSink (State (Seq Char)) where
|
|
||||||
pushWord8 x = modify (|> (chr $ fromIntegral x))
|
|
||||||
|
|
||||||
instance ByteSink (StateT (Seq Char) (Either EncodingException)) where
|
|
||||||
pushWord8 x = modify (|> (chr $ fromIntegral x))
|
pushWord8 x = modify (|> (chr $ fromIntegral x))
|
||||||
|
|
||||||
newtype StrictSink a = StrictS (Ptr Word8 -> Int -> Int -> IO (a,Ptr Word8,Int,Int))
|
newtype StrictSink a = StrictS (Ptr Word8 -> Int -> Int -> IO (a,Ptr Word8,Int,Int))
|
||||||
|
|||||||
@ -103,10 +103,7 @@ instance ByteSource Get where
|
|||||||
fetchWord64be = getWord64be
|
fetchWord64be = getWord64be
|
||||||
fetchWord64le = getWord64le
|
fetchWord64le = getWord64le
|
||||||
|
|
||||||
instance Throws DecodingException (State [Char]) where
|
instance ByteSource (StateT [Char] Identity) where
|
||||||
throwException = throw
|
|
||||||
|
|
||||||
instance ByteSource (State [Char]) where
|
|
||||||
sourceEmpty = gets null
|
sourceEmpty = gets null
|
||||||
fetchWord8 = do
|
fetchWord8 = do
|
||||||
chs <- get
|
chs <- get
|
||||||
@ -121,7 +118,8 @@ instance ByteSource (State [Char]) where
|
|||||||
put chs
|
put chs
|
||||||
return res
|
return res
|
||||||
|
|
||||||
#ifndef MIN_VERSION_mtl(2,0,0,0)
|
#if MIN_VERSION_base(4,3,0)
|
||||||
|
#else
|
||||||
instance Monad (Either DecodingException) where
|
instance Monad (Either DecodingException) where
|
||||||
return = Right
|
return = Right
|
||||||
(Left err) >>= g = Left err
|
(Left err) >>= g = Left err
|
||||||
@ -143,31 +141,17 @@ instance ByteSource (StateT [Char] (Either DecodingException)) where
|
|||||||
put chs
|
put chs
|
||||||
return res
|
return res
|
||||||
|
|
||||||
instance Throws DecodingException (State BS.ByteString) where
|
instance (Monad m,Throws DecodingException m) => ByteSource (StateT BS.ByteString m) where
|
||||||
throwException = throw
|
|
||||||
|
|
||||||
instance ByteSource (State BS.ByteString) where
|
|
||||||
sourceEmpty = gets BS.null
|
sourceEmpty = gets BS.null
|
||||||
fetchWord8 = State (\str -> case BS.uncons str of
|
fetchWord8 = StateT (\str -> case BS.uncons str of
|
||||||
Nothing -> throw UnexpectedEnd
|
Nothing -> throw UnexpectedEnd
|
||||||
Just (c,cs) -> (c,cs))
|
Just (c,cs) -> return (c,cs))
|
||||||
fetchAhead act = do
|
fetchAhead act = do
|
||||||
str <- get
|
str <- get
|
||||||
res <- act
|
res <- act
|
||||||
put str
|
put str
|
||||||
return res
|
return res
|
||||||
|
|
||||||
instance ByteSource (StateT BS.ByteString (Either DecodingException)) where
|
|
||||||
sourceEmpty = gets BS.null
|
|
||||||
fetchWord8 = StateT (\str -> case BS.uncons str of
|
|
||||||
Nothing -> Left UnexpectedEnd
|
|
||||||
Just ns -> Right ns)
|
|
||||||
fetchAhead act = do
|
|
||||||
chs <- get
|
|
||||||
res <- act
|
|
||||||
put chs
|
|
||||||
return res
|
|
||||||
|
|
||||||
instance ByteSource (StateT LBS.ByteString (Either DecodingException)) where
|
instance ByteSource (StateT LBS.ByteString (Either DecodingException)) where
|
||||||
sourceEmpty = gets LBS.null
|
sourceEmpty = gets LBS.null
|
||||||
fetchWord8 = StateT (\str -> case LBS.uncons str of
|
fetchWord8 = StateT (\str -> case LBS.uncons str of
|
||||||
@ -193,4 +177,21 @@ instance ByteSource (ReaderT Handle IO) where
|
|||||||
pos <- liftIO $ hGetPosn h
|
pos <- liftIO $ hGetPosn h
|
||||||
res <- act
|
res <- act
|
||||||
liftIO $ hSetPosn pos
|
liftIO $ hSetPosn pos
|
||||||
return res
|
return res
|
||||||
|
sourcePos = do
|
||||||
|
h <- ask
|
||||||
|
p <- liftIO $ hTell h
|
||||||
|
return $ Just p
|
||||||
|
|
||||||
|
{-
|
||||||
|
instance Throws DecodingException (State st) => Throws DecodingException (State (Integer,st)) where
|
||||||
|
throwException = throw
|
||||||
|
|
||||||
|
instance ByteSource (State st) => ByteSource (State (Integer,st)) where
|
||||||
|
sourceEmpty = sourceEmpty
|
||||||
|
fetchWord8 = do
|
||||||
|
<- fetchWord8
|
||||||
|
fetchAhead = fetchAhead
|
||||||
|
sourcePos = do
|
||||||
|
(p,chs) <- get
|
||||||
|
return (Just p)-}
|
||||||
5
NEWS
5
NEWS
@ -1,3 +1,8 @@
|
|||||||
|
Changes from 0.6.4 to 0.6.5
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
* Make package work with >=base-4.3.0.0 and mtl-2
|
||||||
|
|
||||||
Changes from 0.6.3 to 0.6.4
|
Changes from 0.6.3 to 0.6.4
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
Name: encoding
|
Name: encoding
|
||||||
Version: 0.6.4
|
Version: 0.6.5
|
||||||
Author: Henning Günther
|
Author: Henning Günther
|
||||||
Maintainer: h.guenther@tu-bs.de
|
Maintainer: h.guenther@tu-bs.de
|
||||||
License: BSD3
|
License: BSD3
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user