    {-# LANGUAGE CPP #-}
    {-# OPTIONS_GHC -Wno-orphans #-}

    module TextBuilderDev.Domains.StrictTextBuilder where

    #if MIN_VERSION_text(2,1,2)

    import Data.Text.Internal.StrictBuilder
    import qualified TextBuilderCore as Core
    import TextBuilderDev.Isomorphic
    import TextBuilderDev.Prelude

    instance Isomorphic StrictTextBuilder where
      {-# INLINE from #-}
      from :: StrictTextBuilder -> TextBuilder
    from (StrictTextBuilder Int
    size forall s. MArray s -> Int -> ST s ()
    write) =
        Int -> (forall s. MArray s -> Int -> ST s Int) -> TextBuilder
    Core.TextBuilder
          Int
    size
          ( \MArray s
    array Int
    offset ->
              MArray s -> Int -> ST s ()
    forall s. MArray s -> Int -> ST s ()
    write MArray s
    array Int
    offset ST s () -> Int -> ST s Int
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> Int
    offset Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    size
          )
      {-# INLINE to #-}
      to :: TextBuilder -> StrictTextBuilder
    to (Core.TextBuilder Int
    size forall s. MArray s -> Int -> ST s Int
    write) =
        Int -> (forall s. MArray s -> Int -> ST s ()) -> StrictTextBuilder
    StrictTextBuilder
          Int
    size
          ( \MArray s
    array Int
    offset ->
              MArray s -> Int -> ST s Int
    forall s. MArray s -> Int -> ST s Int
    write MArray s
    array Int
    offset ST s Int -> () -> ST s ()
    forall (f :: * -> *) a b. Functor f => f a -> b -> f b
    $> ()
          )

    #endif