module Data.Number.Flint.Groups.Qfb.Instances where

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

import Data.Number.Flint.Groups.Qfb

instance Show Qfb where
  show :: Qfb -> String
show Qfb
x = IO String -> String
forall a. IO a -> a
unsafePerformIO (IO String -> String) -> IO String -> String
forall a b. (a -> b) -> a -> b
$ do
    (Qfb
_, CString
cs) <- Qfb -> (Ptr CQfb -> IO CString) -> IO (Qfb, CString)
forall {a}. Qfb -> (Ptr CQfb -> IO a) -> IO (Qfb, a)
withQfb Qfb
x Ptr CQfb -> IO CString
qfb_get_str
    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