From 21eb409c2587f6ccefaa4c008789614298c84487 Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Sat, 15 Feb 2014 19:45:48 -0800 Subject: Simplified `Codec` type synonym This implements it in terms of `Lens'` to make it more clear what is going on --- Pipes/Text/Encoding.hs | 10 ++++++---- 1 file 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) import Data.Word (Word8) import Pipes - +type Lens' a b = forall f . Functor f => (b -> f b) -> (a -> f a) {- | A 'Codec' is just an improper lens into a byte stream that is expected to contain text. They are named in accordance with the expected encoding, 'utf8', 'utf16LE' etc. The stream of text they 'see' in a bytestream ends by returning the original byte stream beginning at the point of failure, or the empty bytestream with its return value. -} -type Codec = forall f m r . (Functor f , Monad m ) => - (Producer Text m (Producer ByteString m r) -> f (Producer Text m (Producer ByteString m r))) - -> Producer ByteString m r -> f (Producer ByteString m r ) +type Codec + = forall m r + . Monad m + => Lens' (Producer ByteString m r) + (Producer Text m (Producer ByteString m r)) decodeStream :: Monad m => (B.ByteString -> DecodeResult) -- cgit v1.2.3