stringz-0.0.1: src/Data/Stringz/Text.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FlexibleInstances #-}
module Data.Stringz.Text where
import Control.Lens
import qualified Data.ByteString.Char8 as ByteStringChar8
import qualified Data.ByteString.Lazy.Char8 as ByteStringLazyChar8
import qualified Data.Text as Text
import qualified Data.Text.Lazy as LazyText
class HasText a where
text ::
Lens' a Text.Text
instance HasText [Char] where
text =
iso
Text.pack
Text.unpack
instance HasText Text.Text where
text =
id
instance HasText LazyText.Text where
text =
iso
LazyText.toStrict
LazyText.fromStrict
instance HasText ByteStringChar8.ByteString where
text =
iso ByteStringChar8.unpack ByteStringChar8.pack . text
instance HasText ByteStringLazyChar8.ByteString where
text =
iso ByteStringLazyChar8.unpack ByteStringLazyChar8.pack . text
instance HasText a => HasText (Identity a) where
text =
iso runIdentity Identity . text
instance HasText a => HasText (Const a b) where
text =
iso getConst Const . text
class HasLazyText a where
lazyText ::
Lens' a LazyText.Text
instance HasLazyText [Char] where
lazyText =
iso
LazyText.pack
LazyText.unpack
instance HasLazyText Text.Text where
lazyText =
iso
LazyText.fromStrict
LazyText.toStrict
instance HasLazyText LazyText.Text where
lazyText =
id
instance HasLazyText ByteStringChar8.ByteString where
lazyText =
iso ByteStringChar8.unpack ByteStringChar8.pack . lazyText
instance HasLazyText ByteStringLazyChar8.ByteString where
lazyText =
iso ByteStringLazyChar8.unpack ByteStringLazyChar8.pack . lazyText
instance HasLazyText a => HasLazyText (Identity a) where
lazyText =
iso runIdentity Identity . lazyText
instance HasLazyText a => HasLazyText (Const a b) where
lazyText =
iso getConst Const . lazyText
class AsText a where
_Text ::
Prism' a Text.Text
instance AsText [Char] where
_Text =
iso
Text.pack
Text.unpack
instance AsText Text.Text where
_Text =
id
instance AsText LazyText.Text where
_Text =
iso
LazyText.toStrict
LazyText.fromStrict
instance AsText ByteStringChar8.ByteString where
_Text =
iso ByteStringChar8.unpack ByteStringChar8.pack . _Text
instance AsText ByteStringLazyChar8.ByteString where
_Text =
iso ByteStringLazyChar8.unpack ByteStringLazyChar8.pack . _Text
instance AsText a => AsText (Identity a) where
_Text =
iso runIdentity Identity . _Text
instance AsText a => AsText (Const a b) where
_Text =
iso getConst Const . _Text
class AsLazyText a where
_LazyText ::
Prism' a LazyText.Text
instance AsLazyText [Char] where
_LazyText =
iso
LazyText.pack
LazyText.unpack
instance AsLazyText Text.Text where
_LazyText =
iso
LazyText.fromStrict
LazyText.toStrict
instance AsLazyText LazyText.Text where
_LazyText =
id
instance AsLazyText ByteStringChar8.ByteString where
_LazyText =
iso ByteStringChar8.unpack ByteStringChar8.pack . _LazyText
instance AsLazyText ByteStringLazyChar8.ByteString where
_LazyText =
iso ByteStringLazyChar8.unpack ByteStringLazyChar8.pack . _LazyText
instance AsLazyText a => AsLazyText (Identity a) where
_LazyText =
iso runIdentity Identity . _LazyText
instance AsLazyText a => AsLazyText (Const a b) where
_LazyText =
iso getConst Const . _LazyText