on master help sign in
Merge pull request #126 from DanBurton/master
75726f0Bryan O'Sullivan
Data/Text.hs+6−2
@@ -221,7 +221,7 @@ import Data.Semigroup (Semigroup(..))
221import Data.String (IsString(..))
221import Data.String (IsString(..))
222import qualified Data.Text.Internal.Fusion as S
222import qualified Data.Text.Internal.Fusion as S
223import qualified Data.Text.Internal.Fusion.Common as S
223import qualified Data.Text.Internal.Fusion.Common as S
224−import Data.Text.Encoding (decodeUtf8, encodeUtf8)
224+import Data.Text.Encoding (decodeUtf8', encodeUtf8)
225import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
225import Data.Text.Internal.Fusion (stream, reverseStream, unstream)
226import Data.Text.Internal.Private (span_)
226import Data.Text.Internal.Private (span_)
227import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
227import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
@@ -365,7 +365,11 @@ instance NFData Text where rnf !_ = ()
365
365
366instance Binary Text where
366instance Binary Text where
367 put t = put (encodeUtf8 t)
367 put t = put (encodeUtf8 t)
368+ get = do
369+ bs <- get
368− get = P.fmap decodeUtf8 get
370+ case decodeUtf8' bs of
371+ P.Left exn -> P.fail (P.show exn)
372+ P.Right a -> P.return a
369
373
370-- | This instance preserves data abstraction at the cost of inefficiency.
374-- | This instance preserves data abstraction at the cost of inefficiency.
371-- We omit reflection services for the sake of data abstraction.
375-- We omit reflection services for the sake of data abstraction.
Data/Text/Lazy.hs+6−2
@@ -229,7 +229,7 @@ import Data.Text.Internal.Lazy.Fusion (stream, unstream)
229import Data.Text.Internal.Lazy (Text(..), chunk, empty, foldlChunks,
229import Data.Text.Internal.Lazy (Text(..), chunk, empty, foldlChunks,
230 foldrChunks, smallChunkSize)
230 foldrChunks, smallChunkSize)
231import Data.Text.Internal (firstf, safe, text)
231import Data.Text.Internal (firstf, safe, text)
232−import Data.Text.Lazy.Encoding (decodeUtf8, encodeUtf8)
232+import Data.Text.Lazy.Encoding (decodeUtf8', encodeUtf8)
233import qualified Data.Text.Internal.Functions as F
233import qualified Data.Text.Internal.Functions as F
234import Data.Text.Internal.Lazy.Search (indices)
234import Data.Text.Internal.Lazy.Search (indices)
235#if __GLASGOW_HASKELL__ >= 702
235#if __GLASGOW_HASKELL__ >= 702
@@ -376,7 +376,11 @@ instance NFData Text where
376
376
377instance Binary Text where
377instance Binary Text where
378 put t = put (encodeUtf8 t)
378 put t = put (encodeUtf8 t)
379+ get = do
380+ bs <- get
379− get = P.fmap decodeUtf8 get
381+ case decodeUtf8' bs of
382+ P.Left exn -> P.fail (P.show exn)
383+ P.Right a -> P.return a
380
384
381-- | This instance preserves data abstraction at the cost of inefficiency.
385-- | This instance preserves data abstraction at the cost of inefficiency.
382-- We omit reflection services for the sake of data abstraction.
386-- We omit reflection services for the sake of data abstraction.