{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FlexibleInstances #-}

module Text.Pandoc.Z.Text where

import Control.Lens
import Data.Text
import qualified Data.Text.Lazy as Lazy
import qualified Text.Pandoc.Definition as D

class HasText a where
  text ::
    Lens' a Text

instance HasText Text where
  text :: Lens' Text Text
text =
    (Text -> f Text) -> Text -> f Text
forall a. a -> a
id

instance HasText Lazy.Text where
  text :: Lens' Text Text
text =
    (Text -> Text) -> (Text -> Text) -> Iso Text Text Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      Text -> Text
Lazy.toStrict
      Text -> Text
Lazy.fromStrict

instance HasText D.Format where
  text :: Lens' Format Text
text =
    (Format -> Text) -> (Text -> Format) -> Iso Format Format Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      (\(D.Format Text
x) -> Text
x)
      Text -> Format
D.Format

instance HasText [Char] where
  text :: Lens' [Char] Text
text =
    ([Char] -> Text) -> (Text -> [Char]) -> Iso [Char] [Char] Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      [Char] -> Text
pack
      Text -> [Char]
unpack

class HasLazyText a where
  lazyText ::
    Lens' a Lazy.Text

instance HasLazyText Lazy.Text where
  lazyText :: Lens' Text Text
lazyText =
    (Text -> f Text) -> Text -> f Text
forall a. a -> a
id

instance HasLazyText Text where
  lazyText :: Lens' Text Text
lazyText =
    (Text -> Text) -> (Text -> Text) -> Iso Text Text Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      Text -> Text
Lazy.fromStrict
      Text -> Text
Lazy.toStrict

instance HasLazyText D.Format where
  lazyText :: Lens' Format Text
lazyText =
    (Text -> f Text) -> Format -> f Format
forall a. HasText a => Lens' a Text
Lens' Format Text
text ((Text -> f Text) -> Format -> f Format)
-> ((Text -> f Text) -> Text -> f Text)
-> (Text -> f Text)
-> Format
-> f Format
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> f Text) -> Text -> f Text
forall a. HasLazyText a => Lens' a Text
Lens' Text Text
lazyText

instance HasLazyText [Char] where
  lazyText :: Lens' [Char] Text
lazyText =
    ([Char] -> Text) -> (Text -> [Char]) -> Iso [Char] [Char] Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      [Char] -> Text
Lazy.pack
      Text -> [Char]
Lazy.unpack

class AsText a where
  _Text ::
    Prism' a Text

instance AsText Text where
  _Text :: Prism' Text Text
_Text =
    p Text (f Text) -> p Text (f Text)
forall a. a -> a
id

instance AsText Lazy.Text where
  _Text :: Prism' Text Text
_Text =
    (Text -> Text) -> (Text -> Text) -> Iso Text Text Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      Text -> Text
Lazy.toStrict
      Text -> Text
Lazy.fromStrict

instance AsText D.Format where
  _Text :: Prism' Format Text
_Text =
    (Format -> Text) -> (Text -> Format) -> Iso Format Format Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      (\(D.Format Text
x) -> Text
x)
      Text -> Format
D.Format

instance AsText [Char] where
  _Text :: Prism' [Char] Text
_Text =
    ([Char] -> Text) -> (Text -> [Char]) -> Iso [Char] [Char] Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      [Char] -> Text
pack
      Text -> [Char]
unpack

class AsLazyText a where
  _LazyText ::
    Prism' a Lazy.Text

instance AsLazyText Lazy.Text where
  _LazyText :: Prism' Text Text
_LazyText =
    p Text (f Text) -> p Text (f Text)
forall a. a -> a
id

instance AsLazyText Text where
  _LazyText :: Prism' Text Text
_LazyText =
    (Text -> Text) -> (Text -> Text) -> Iso Text Text Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      Text -> Text
Lazy.fromStrict
      Text -> Text
Lazy.toStrict

instance AsLazyText D.Format where
  _LazyText :: Prism' Format Text
_LazyText =
    p Text (f Text) -> p Format (f Format)
forall a. AsText a => Prism' a Text
Prism' Format Text
_Text (p Text (f Text) -> p Format (f Format))
-> (p Text (f Text) -> p Text (f Text))
-> p Text (f Text)
-> p Format (f Format)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p Text (f Text) -> p Text (f Text)
forall a. AsLazyText a => Prism' a Text
Prism' Text Text
_LazyText

instance AsLazyText [Char] where
  _LazyText :: Prism' [Char] Text
_LazyText =
    ([Char] -> Text) -> (Text -> [Char]) -> Iso [Char] [Char] Text Text
forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso
      [Char] -> Text
Lazy.pack
      Text -> [Char]
Lazy.unpack