{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Safe #-}
module Lens.Micro.Platform.Internal
(
IsText(..),
)
where
import Lens.Micro
import qualified Data.Text as T
import qualified Data.Text.Lazy as TL
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative
#endif
class IsText t where
packed :: Lens' String t
unpacked :: Lens' t String
instance IsText String where
packed = id
{-# INLINE packed #-}
unpacked = id
{-# INLINE unpacked #-}
instance IsText T.Text where
packed f s = T.unpack <$> f (T.pack s)
{-# INLINE packed #-}
unpacked f s = T.pack <$> f (T.unpack s)
{-# INLINE unpacked #-}
instance IsText TL.Text where
packed f s = TL.unpack <$> f (TL.pack s)
{-# INLINE packed #-}
unpacked f s = TL.pack <$> f (TL.unpack s)
{-# INLINE unpacked #-}