diff options
-rw-r--r-- | .DS_Store | bin | 6148 -> 12292 bytes | |||
-rw-r--r-- | Pipes/Text/Internal.hs | 16 | ||||
-rw-r--r-- | Pipes/Text/Internal/Codec.hs | 16 | ||||
-rw-r--r-- | Pipes/Text/Internal/Decoding.hs | 23 | ||||
-rw-r--r-- | changelog | 15 | ||||
-rw-r--r-- | pipes-text.cabal | 4 |
6 files changed, 41 insertions, 33 deletions
Binary files differ | |||
diff --git a/Pipes/Text/Internal.hs b/Pipes/Text/Internal.hs index 2530b23..582ef14 100644 --- a/Pipes/Text/Internal.hs +++ b/Pipes/Text/Internal.hs | |||
@@ -1,15 +1,7 @@ | |||
1 | module Pipes.Text.Internal | 1 | module Pipes.Text.Internal |
2 | ( Decoding(..) | 2 | (module Pipes.Text.Internal.Codec |
3 | , streamDecodeUtf8 | 3 | , module Pipes.Text.Internal.Decoding |
4 | , decodeSomeUtf8 | ||
5 | , Codec(..) | ||
6 | , TextException(..) | ||
7 | , utf8 | ||
8 | , utf16_le | ||
9 | , utf16_be | ||
10 | , utf32_le | ||
11 | , utf32_be | ||
12 | ) where | 4 | ) where |
13 | 5 | ||
14 | import Pipes.Text.Internal.Decoding | 6 | import Pipes.Text.Internal.Codec |
15 | import Pipes.Text.Internal.Codec \ No newline at end of file | 7 | import Pipes.Text.Internal.Decoding \ No newline at end of file |
diff --git a/Pipes/Text/Internal/Codec.hs b/Pipes/Text/Internal/Codec.hs index 63cbd74..075a152 100644 --- a/Pipes/Text/Internal/Codec.hs +++ b/Pipes/Text/Internal/Codec.hs | |||
@@ -4,17 +4,15 @@ | |||
4 | -- Copyright: 2014 Michael Thompson, 2011 Michael Snoyman, 2010-2011 John Millikin | 4 | -- Copyright: 2014 Michael Thompson, 2011 Michael Snoyman, 2010-2011 John Millikin |
5 | -- License: MIT | 5 | -- License: MIT |
6 | -- This Parts of this code were taken from enumerator and conduits, and adapted for pipes | 6 | -- This Parts of this code were taken from enumerator and conduits, and adapted for pipes |
7 | {- | This module follows the model of the enumerator and conduits libraries, and defines | 7 | |
8 | 'Codec' s for various encodings. Note that we do not export a 'Codec' for ascii and | 8 | -- This module follows the model of the enumerator and conduits libraries, and defines |
9 | iso8859_1. A 'Lens' in the sense of the pipes library cannot be defined for these, so | 9 | -- 'Codec' s for various encodings. Note that we do not export a 'Codec' for ascii and |
10 | special functions appear in @Pipes.Text@ | 10 | -- iso8859_1. A 'Lens' in the sense of the pipes library cannot be defined for these, so |
11 | -} | 11 | -- special functions appear in @Pipes.Text@ |
12 | |||
12 | 13 | ||
13 | module Pipes.Text.Internal.Codec | 14 | module Pipes.Text.Internal.Codec |
14 | ( Decoding(..) | 15 | ( Codec(..) |
15 | , streamDecodeUtf8 | ||
16 | , decodeSomeUtf8 | ||
17 | , Codec(..) | ||
18 | , TextException(..) | 16 | , TextException(..) |
19 | , utf8 | 17 | , utf8 |
20 | , utf16_le | 18 | , utf16_le |
diff --git a/Pipes/Text/Internal/Decoding.hs b/Pipes/Text/Internal/Decoding.hs index 4b4bbe6..b5d928a 100644 --- a/Pipes/Text/Internal/Decoding.hs +++ b/Pipes/Text/Internal/Decoding.hs | |||
@@ -2,11 +2,10 @@ | |||
2 | {-# LANGUAGE GeneralizedNewtypeDeriving, MagicHash, UnliftedFFITypes #-} | 2 | {-# LANGUAGE GeneralizedNewtypeDeriving, MagicHash, UnliftedFFITypes #-} |
3 | {-# LANGUAGE DeriveDataTypeable, RankNTypes #-} | 3 | {-# LANGUAGE DeriveDataTypeable, RankNTypes #-} |
4 | 4 | ||
5 | {- | | 5 | -- This module lifts assorted materials from Brian O'Sullivan's text package |
6 | This module lifts assorted materials from Brian O'Sullivan's text package | 6 | -- especially @Data.Text.Encoding@ in order to define a pipes-appropriate |
7 | especially @Data.Text.Encoding@ in order to define a pipes-appropriate | 7 | -- 'streamDecodeUtf8' |
8 | 'streamDecodeUtf8' | 8 | |
9 | -} | ||
10 | module Pipes.Text.Internal.Decoding | 9 | module Pipes.Text.Internal.Decoding |
11 | ( Decoding(..) | 10 | ( Decoding(..) |
12 | , streamDecodeUtf8 | 11 | , streamDecodeUtf8 |
@@ -43,9 +42,13 @@ import Data.Maybe (catMaybes) | |||
43 | 42 | ||
44 | 43 | ||
45 | 44 | ||
46 | -- | A stream oriented decoding result. Distinct from the similar type in @Data.Text.Encoding@ | 45 | -- A stream oriented decoding result. Distinct from the similar type in Data.Text.Encoding |
47 | data Decoding = Some Text ByteString (ByteString -> Decoding) -- | Text, continuation and any undecoded fragment. | 46 | |
48 | | Other Text ByteString -- | Text followed by an undecodable ByteString | 47 | data Decoding = Some Text ByteString (ByteString -> Decoding) |
48 | -- Text, continuation and any undecoded fragment. | ||
49 | | Other Text ByteString | ||
50 | -- Text followed by an undecodable ByteString | ||
51 | |||
49 | instance Show Decoding where | 52 | instance Show Decoding where |
50 | showsPrec d (Some t bs _) = showParen (d > prec) $ | 53 | showsPrec d (Some t bs _) = showParen (d > prec) $ |
51 | showString "Some " . showsPrec prec' t . | 54 | showString "Some " . showsPrec prec' t . |
@@ -61,7 +64,7 @@ instance Show Decoding where | |||
61 | newtype CodePoint = CodePoint Word32 deriving (Eq, Show, Num, Storable) | 64 | newtype CodePoint = CodePoint Word32 deriving (Eq, Show, Num, Storable) |
62 | newtype DecoderState = DecoderState Word32 deriving (Eq, Show, Num, Storable) | 65 | newtype DecoderState = DecoderState Word32 deriving (Eq, Show, Num, Storable) |
63 | 66 | ||
64 | -- | Resolve a 'ByteString' into 'Text' and a continuation that can handle further 'ByteStrings'. | 67 | -- Resolve a 'ByteString' into 'Text' and a continuation that can handle further 'ByteStrings'. |
65 | streamDecodeUtf8 :: ByteString -> Decoding | 68 | streamDecodeUtf8 :: ByteString -> Decoding |
66 | streamDecodeUtf8 = decodeChunkUtf8 B.empty 0 0 | 69 | streamDecodeUtf8 = decodeChunkUtf8 B.empty 0 0 |
67 | where | 70 | where |
@@ -95,7 +98,7 @@ streamDecodeUtf8 = decodeChunkUtf8 B.empty 0 0 | |||
95 | {-# INLINE decodeChunkUtf8 #-} | 98 | {-# INLINE decodeChunkUtf8 #-} |
96 | {-# INLINE streamDecodeUtf8 #-} | 99 | {-# INLINE streamDecodeUtf8 #-} |
97 | 100 | ||
98 | -- | Resolve a ByteString into an initial segment of intelligible 'Text' and whatever is unintelligble | 101 | -- Resolve a ByteString into an initial segment of intelligible 'Text' and whatever is unintelligble |
99 | decodeSomeUtf8 :: ByteString -> (Text, ByteString) | 102 | decodeSomeUtf8 :: ByteString -> (Text, ByteString) |
100 | decodeSomeUtf8 bs@(PS fp off len) = runST $ do | 103 | decodeSomeUtf8 bs@(PS fp off len) = runST $ do |
101 | dest <- A.new (len+1) | 104 | dest <- A.new (len+1) |
@@ -1,3 +1,18 @@ | |||
1 | # Version 0.0.0.5 | ||
2 | |||
3 | * Rearranged internal modules | ||
4 | |||
5 | |||
6 | # Version 0.0.0.4 | ||
7 | |||
8 | * Altered bad haddock markup | ||
9 | |||
10 | |||
11 | # Version 0.0.0.3 | ||
12 | |||
13 | * Actually added changelog | ||
14 | |||
15 | |||
1 | # Version 0.0.0.2 | 16 | # Version 0.0.0.2 |
2 | 17 | ||
3 | * Omit `stdinLn` as likely to be dangerous through misunderstanding. | 18 | * Omit `stdinLn` as likely to be dangerous through misunderstanding. |
diff --git a/pipes-text.cabal b/pipes-text.cabal index cb828a7..c5b47d0 100644 --- a/pipes-text.cabal +++ b/pipes-text.cabal | |||
@@ -1,5 +1,5 @@ | |||
1 | name: pipes-text | 1 | name: pipes-text |
2 | version: 0.0.0.2 | 2 | version: 0.0.0.4 |
3 | synopsis: Text pipes. | 3 | synopsis: Text pipes. |
4 | description: Many of the pipes and other operations defined here mirror those in | 4 | description: Many of the pipes and other operations defined here mirror those in |
5 | the `pipes-bytestring` library. Folds like `length` and grouping | 5 | the `pipes-bytestring` library. Folds like `length` and grouping |
@@ -31,7 +31,7 @@ category: Text, Pipes | |||
31 | build-type: Simple | 31 | build-type: Simple |
32 | cabal-version: >=1.10 | 32 | cabal-version: >=1.10 |
33 | 33 | ||
34 | extra-source-files: README.md include/*.h | 34 | extra-source-files: README.md include/*.h changelog |
35 | source-repository head | 35 | source-repository head |
36 | type: git | 36 | type: git |
37 | location: https://github.com/michaelt/text-pipes | 37 | location: https://github.com/michaelt/text-pipes |