module Text.Isomorphic
( module Data.Types.Injective
, module Data.Types.Isomorphic
, as, as2, as3, as4 ) where
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC
import qualified Data.ByteString.Lazy as BL
import qualified Data.ByteString.Lazy.Char8 as BLC
import qualified Data.Char as C
import qualified Data.String as S
import qualified Data.Text as TS
import qualified Data.Text.Encoding as TSE
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Encoding as TLE
import Data.Types.Injective
import Data.Types.Isomorphic
instance S.IsString s => Injective String s where to = S.fromString
instance Injective BS.ByteString String where
to = BSC.unpack
instance Injective String BS.ByteString where
to = BSC.pack
instance Iso String BS.ByteString
instance Iso BS.ByteString String
instance Injective BL.ByteString String where
to = BLC.unpack
instance Injective String BL.ByteString where
to = BLC.pack
instance Iso String BL.ByteString
instance Iso BL.ByteString String
instance Injective TS.Text BS.ByteString where
to = TSE.encodeUtf8
instance Injective BS.ByteString TS.Text where
to = TSE.decodeUtf8
instance Iso TS.Text BS.ByteString
instance Iso BS.ByteString TS.Text
instance Injective TS.Text BL.ByteString where
to = BL.fromStrict . to
instance Injective BL.ByteString TS.Text where
to = to . BL.toStrict
instance Iso TS.Text BL.ByteString
instance Iso BL.ByteString TS.Text
instance Injective TL.Text BS.ByteString where
to = BL.toStrict . to
instance Injective BS.ByteString TL.Text where
to = to . BL.fromStrict
instance Iso TL.Text BS.ByteString
instance Iso BS.ByteString TL.Text
instance Injective TL.Text BL.ByteString where
to = TLE.encodeUtf8
instance Injective BL.ByteString TL.Text where
to = TLE.decodeUtf8
instance Iso TL.Text BL.ByteString
instance Iso BL.ByteString TL.Text
instance Injective BS.ByteString BL.ByteString where
to = BL.fromStrict
instance Injective BL.ByteString BS.ByteString where
to = BL.toStrict
instance Iso BS.ByteString BL.ByteString
instance Iso BL.ByteString BS.ByteString
as :: forall a b. (Iso a b, Iso b a) => (a -> a) -> b -> b
as f = from . f . to
as2 :: forall a b. (Iso a b, Iso b a) => (a -> a -> a) -> b -> b -> b
as2 f x y = from $ f (to x) (to y)
as3 :: forall a b. (Iso a b, Iso b a) => (a -> a -> a -> a) -> b -> b -> b -> b
as3 f x y z = from $ f (to x) (to y) (to z)
as4 :: forall a b. (Iso a b, Iso b a) => (a -> a -> a -> a -> a) -> b -> b -> b -> b -> b
as4 f w x y z = from $ f (to w) (to x) (to y) (to z)