aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.DS_Storebin6148 -> 12292 bytes
-rw-r--r--Pipes/Text/Internal.hs16
-rw-r--r--Pipes/Text/Internal/Codec.hs16
-rw-r--r--Pipes/Text/Internal/Decoding.hs23
-rw-r--r--changelog15
-rw-r--r--pipes-text.cabal4
6 files changed, 41 insertions, 33 deletions
diff --git a/.DS_Store b/.DS_Store
index 5008ddf..a67b8b2 100644
--- a/.DS_Store
+++ b/.DS_Store
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 @@
1module Pipes.Text.Internal 1module 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
14import Pipes.Text.Internal.Decoding 6import Pipes.Text.Internal.Codec
15import Pipes.Text.Internal.Codec \ No newline at end of file 7import 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
13module Pipes.Text.Internal.Codec 14module 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
6This module lifts assorted materials from Brian O'Sullivan's text package 6-- especially @Data.Text.Encoding@ in order to define a pipes-appropriate
7especially @Data.Text.Encoding@ in order to define a pipes-appropriate 7-- 'streamDecodeUtf8'
8'streamDecodeUtf8' 8
9-}
10module Pipes.Text.Internal.Decoding 9module 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
47data Decoding = Some Text ByteString (ByteString -> Decoding) -- | Text, continuation and any undecoded fragment. 46
48 | Other Text ByteString -- | Text followed by an undecodable ByteString 47data 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
49instance Show Decoding where 52instance 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
61newtype CodePoint = CodePoint Word32 deriving (Eq, Show, Num, Storable) 64newtype CodePoint = CodePoint Word32 deriving (Eq, Show, Num, Storable)
62newtype DecoderState = DecoderState Word32 deriving (Eq, Show, Num, Storable) 65newtype 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'.
65streamDecodeUtf8 :: ByteString -> Decoding 68streamDecodeUtf8 :: ByteString -> Decoding
66streamDecodeUtf8 = decodeChunkUtf8 B.empty 0 0 69streamDecodeUtf8 = 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
99decodeSomeUtf8 :: ByteString -> (Text, ByteString) 102decodeSomeUtf8 :: ByteString -> (Text, ByteString)
100decodeSomeUtf8 bs@(PS fp off len) = runST $ do 103decodeSomeUtf8 bs@(PS fp off len) = runST $ do
101 dest <- A.new (len+1) 104 dest <- A.new (len+1)
diff --git a/changelog b/changelog
index 631aed3..6569002 100644
--- a/changelog
+++ b/changelog
@@ -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 @@
1name: pipes-text 1name: pipes-text
2version: 0.0.0.2 2version: 0.0.0.4
3synopsis: Text pipes. 3synopsis: Text pipes.
4description: Many of the pipes and other operations defined here mirror those in 4description: 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
31build-type: Simple 31build-type: Simple
32cabal-version: >=1.10 32cabal-version: >=1.10
33 33
34extra-source-files: README.md include/*.h 34extra-source-files: README.md include/*.h changelog
35source-repository head 35source-repository head
36 type: git 36 type: git
37 location: https://github.com/michaelt/text-pipes 37 location: https://github.com/michaelt/text-pipes