packages feed

convertible 1.1.0.0 → 1.1.1.0

raw patch · 2 files changed

+193/−42 lines, 2 filesdep ~basedep ~bytestringdep ~text

Dependency ranges changed: base, bytestring, text

Files

Data/Convertible/Instances/Text.hs view
@@ -30,55 +30,206 @@  import Data.Convertible.Base import qualified Data.Text as TS+import qualified Data.Text.Encoding as TE import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.Builder as TLB+import qualified Data.Text.Lazy.Encoding as TLE import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BL+import qualified Data.ByteString.Builder as BB import Data.Word (Word8)+import Data.Foldable --- Text -instance Convertible [Char] TS.Text where-    safeConvert = Right . TS.pack  instance Convertible TS.Text [Char] where+    {-# INLINE safeConvert #-}     safeConvert = Right . TS.unpack -instance Convertible [Char] TL.Text where-    safeConvert = Right . TL.pack+instance Convertible TS.Text TL.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TL.fromStrict +instance Convertible TS.Text TLB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TLB.fromText++instance Convertible TS.Text BS.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TE.encodeUtf8++instance Convertible TS.Text BL.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BL.fromStrict . TE.encodeUtf8++instance Convertible TS.Text BB.Builder where+    {-# INLINE safeConvert #-}+#if MIN_VERSION_text(1,2,0)+    safeConvert = Right . TE.encodeUtf8Builder+#else+    safeConvert = safeConvert . TE.encodeUtf8+#endif+++ instance Convertible TL.Text [Char] where+    {-# INLINE safeConvert #-}     safeConvert = Right . TL.unpack -#if MIN_VERSION_text(0,8,1)-instance Convertible TS.Text TL.Text where-    safeConvert = Right . TL.fromStrict- instance Convertible TL.Text TS.Text where+    {-# INLINE safeConvert #-}     safeConvert = Right . TL.toStrict-#else-instance Convertible TS.Text TL.Text where-    safeConvert = Right . TL.fromChunks . (:[]) -instance Convertible TL.Text TS.Text where-    safeConvert = Right . TS.concat . TL.toChunks+instance Convertible TL.Text TLB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TLB.fromLazyText++instance Convertible TL.Text BS.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = safeConvert . TLE.encodeUtf8++instance Convertible TL.Text BL.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TLE.encodeUtf8++instance Convertible TL.Text BB.Builder where+    {-# INLINE safeConvert #-}+#if MIN_VERSION_text(1,2,0)+    safeConvert = Right . TLE.encodeUtf8Builder+#else+    safeConvert = safeConvert . TLE.encodeUtf8 #endif --- ByteString -instance Convertible [Word8] BS.ByteString where-    safeConvert = Right . BS.pack +instance Convertible TLB.Builder [Char] where+    {-# INLINE safeConvert #-}+    safeConvert = safeConvert . TLB.toLazyText++instance Convertible TLB.Builder TS.Text where+    {-# INLINE safeConvert #-}+    safeConvert = safeConvert . TLB.toLazyText++instance Convertible TLB.Builder TL.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TLB.toLazyText++instance Convertible TLB.Builder BS.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = safeConvert . TLB.toLazyText++instance Convertible TLB.Builder BL.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = safeConvert . TLB.toLazyText++instance Convertible TLB.Builder BB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = safeConvert . TLB.toLazyText+++ instance Convertible BS.ByteString [Word8] where+    {-# INLINE safeConvert #-}     safeConvert = Right . BS.unpack -instance Convertible [Word8] BL.ByteString where-    safeConvert = Right . BL.pack+instance Convertible BS.ByteString TS.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TE.decodeUtf8 +instance Convertible BS.ByteString TL.Text where+    {-# INLINE safeConvert #-}+    safeConvert = fmap TL.fromStrict . safeConvert++instance Convertible BS.ByteString TLB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = fmap TLB.fromText . safeConvert++instance Convertible BS.ByteString BL.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BL.fromStrict++instance Convertible BS.ByteString BB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BB.byteString+++ instance Convertible BL.ByteString [Word8] where+    {-# INLINE safeConvert #-}     safeConvert = Right . BL.unpack -instance Convertible BS.ByteString BL.ByteString where-    safeConvert = Right . BL.fromChunks . (:[])+instance Convertible BL.ByteString TS.Text where+    {-# INLINE safeConvert #-}+    safeConvert = fmap TL.toStrict . safeConvert +instance Convertible BL.ByteString TL.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TLE.decodeUtf8++instance Convertible BL.ByteString TLB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = fmap TLB.fromLazyText . safeConvert+ instance Convertible BL.ByteString BS.ByteString where-    safeConvert = Right . BS.concat . BL.toChunks+    {-# INLINE safeConvert #-}+    safeConvert = Right . BL.toStrict++instance Convertible BL.ByteString BB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BB.lazyByteString++++instance Convertible [Char] TS.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TS.pack++instance Convertible [Char] TL.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TL.pack++instance Convertible [Char] TLB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TLB.fromString++++instance Convertible [Word8] BS.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BS.pack++instance Convertible [Word8] BL.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BL.pack++instance Convertible [Word8] BB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . foldMap BB.word8++++instance Convertible Char TS.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TS.singleton++instance Convertible Char TL.Text where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TL.singleton++instance Convertible Char TLB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . TLB.singleton++++instance Convertible Word8 BS.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BS.singleton++instance Convertible Word8 BL.ByteString where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BL.singleton++instance Convertible Word8 BB.Builder where+    {-# INLINE safeConvert #-}+    safeConvert = Right . BB.word8
convertible.cabal view
@@ -1,8 +1,8 @@ Name: convertible-Version: 1.1.0.0+Version: 1.1.1.0 License: BSD3-Maintainer: Nicolas Wu <nicolas.wu@gmail.com>-Author: John Goerzen, Nicolas Wu+Maintainer: Erik Hesselink <hesselink@gmail.com>+Author: John Goerzen Copyright: Copyright (c) 2009-2011 John Goerzen license-file: LICENSE extra-source-files: LICENSE, utils/genCinstances.hs,@@ -11,7 +11,10 @@                     testsrc/TestMap.hs,                     testsrc/TestNum.hs,                     testsrc/TestTime.hs-homepage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/convertible+homepage: http://hackage.haskell.org/package/convertible+bug-reports:  https://github.com/hdbc/convertible/issues++ Category: Data synopsis: Typeclasses and instances for converting between types Description: convertible provides a typeclass with a single function@@ -37,25 +40,25 @@ Stability: Stable Build-Type: Simple -Cabal-Version: >=1.2+Cabal-Version: >=1.6 -flag splitBase-  description: Choose the new smaller, split-up base package. flag buildtests   description: Build the executable to run unit tests   default: False +source-repository head+  type: git+  location: git://github.com/hdbc/convertible.git+ library-  if flag(splitBase)-    Build-Depends: base>=3 && <5,-                   old-time,-                   time>=1.1.3,-                   bytestring,-                   containers,-                   old-locale-  else-    Build-Depends: base<3-  Build-Depends: mtl, text >= 0.7+  Build-Depends: base>=3 && <5,+                 old-time,+                 time>=1.1.3,+                 bytestring >= 0.10.2,+                 containers,+                 old-locale,+                 mtl, +                 text >= 0.8    GHC-Options: -O2 -Wall -fno-warn-orphans @@ -69,9 +72,6 @@                    Data.Convertible.Instances.Text,                    Data.Convertible.Instances.Time -  --Other-Modules: Database.HDBC.Utils-  --Extensions: ExistentialQuantification, AllowOverlappingInstances,-  --    AllowUndecidableInstances   Extensions: ExistentialQuantification, MultiParamTypeClasses,               UndecidableInstances, FlexibleInstances,               FlexibleContexts, TypeSynonymInstances, CPP