diff options
author | Gabriel Gonzalez <Gabriel439@gmail.com> | 2014-02-15 19:45:48 -0800 |
---|---|---|
committer | Gabriel Gonzalez <Gabriel439@gmail.com> | 2014-02-15 19:45:48 -0800 |
commit | 21eb409c2587f6ccefaa4c008789614298c84487 (patch) | |
tree | 22f1186e8be6a3f194ee9be87041ec3cc71b81b2 /Pipes/Text | |
parent | 327be7638ab8de6c0589b5fcb9177f5186ace4de (diff) | |
download | text-pipes-21eb409c2587f6ccefaa4c008789614298c84487.tar.gz text-pipes-21eb409c2587f6ccefaa4c008789614298c84487.tar.zst text-pipes-21eb409c2587f6ccefaa4c008789614298c84487.zip |
Simplified `Codec` type synonym
This implements it in terms of `Lens'` to make it more clear what is going on
Diffstat (limited to 'Pipes/Text')
-rw-r--r-- | Pipes/Text/Encoding.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Pipes/Text/Encoding.hs b/Pipes/Text/Encoding.hs index a8be8e4..21269cf 100644 --- a/Pipes/Text/Encoding.hs +++ b/Pipes/Text/Encoding.hs | |||
@@ -38,16 +38,18 @@ import Control.Monad (join) | |||
38 | import Data.Word (Word8) | 38 | import Data.Word (Word8) |
39 | import Pipes | 39 | import Pipes |
40 | 40 | ||
41 | 41 | type Lens' a b = forall f . Functor f => (b -> f b) -> (a -> f a) | |
42 | 42 | ||
43 | {- | A 'Codec' is just an improper lens into a byte stream that is expected to contain text. | 43 | {- | A 'Codec' is just an improper lens into a byte stream that is expected to contain text. |
44 | They are named in accordance with the expected encoding, 'utf8', 'utf16LE' etc. | 44 | They are named in accordance with the expected encoding, 'utf8', 'utf16LE' etc. |
45 | The stream of text they 'see' in a bytestream ends by returning the original byte stream | 45 | The stream of text they 'see' in a bytestream ends by returning the original byte stream |
46 | beginning at the point of failure, or the empty bytestream with its return value. | 46 | beginning at the point of failure, or the empty bytestream with its return value. |
47 | -} | 47 | -} |
48 | type Codec = forall f m r . (Functor f , Monad m ) => | 48 | type Codec |
49 | (Producer Text m (Producer ByteString m r) -> f (Producer Text m (Producer ByteString m r))) | 49 | = forall m r |
50 | -> Producer ByteString m r -> f (Producer ByteString m r ) | 50 | . Monad m |
51 | => Lens' (Producer ByteString m r) | ||
52 | (Producer Text m (Producer ByteString m r)) | ||
51 | 53 | ||
52 | decodeStream :: Monad m | 54 | decodeStream :: Monad m |
53 | => (B.ByteString -> DecodeResult) | 55 | => (B.ByteString -> DecodeResult) |