module Data.Number.Flint.Acb.Mat.Instances where

import System.IO.Unsafe
import Foreign.C.String
import Foreign.Marshal.Alloc ( free )

import Data.Number.Flint.Arb.Types
import Data.Number.Flint.Acb.Mat

instance Show AcbMat where
  show :: AcbMat -> String
show AcbMat
x = IO String -> String
forall a. IO a -> a
unsafePerformIO (IO String -> String) -> IO String -> String
forall a b. (a -> b) -> a -> b
$ do
    (AcbMat
_, CString
cs) <- AcbMat -> (Ptr CAcbMat -> IO CString) -> IO (AcbMat, CString)
forall {a}. AcbMat -> (Ptr CAcbMat -> IO a) -> IO (AcbMat, a)
withAcbMat AcbMat
x ((Ptr CAcbMat -> IO CString) -> IO (AcbMat, CString))
-> (Ptr CAcbMat -> IO CString) -> IO (AcbMat, CString)
forall a b. (a -> b) -> a -> b
$ \Ptr CAcbMat
x -> do Ptr CAcbMat -> CLong -> ArbStrOption -> IO CString
acb_mat_get_strn Ptr CAcbMat
x CLong
16 ArbStrOption
arb_str_no_radius
    String
s <- CString -> IO String
peekCString CString
cs
    CString -> IO ()
forall a. Ptr a -> IO ()
free CString
cs
    String -> IO String
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return String
s