{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}

module Torch.Internal.Managed.Type.StdString where


import Foreign.C.String
import Foreign.C.Types
import Foreign
import Torch.Internal.Type
import Torch.Internal.Class
import Torch.Internal.Cast
import Torch.Internal.Objects
import qualified Torch.Internal.Unmanaged.Type.StdString as Unmanaged



newStdString
  :: IO (ForeignPtr StdString)
newStdString :: IO (ForeignPtr StdString)
newStdString = forall a ca. Castable a ca => IO ca -> IO a
_cast0 IO (Ptr StdString)
Unmanaged.newStdString

newStdString_s
  :: String
  -> IO (ForeignPtr StdString)
newStdString_s :: String -> IO (ForeignPtr StdString)
newStdString_s String
str = forall a ca y cy.
(Castable a ca, Castable y cy) =>
(ca -> IO cy) -> a -> IO y
_cast1 String -> IO (Ptr StdString)
Unmanaged.newStdString_s String
str

string_c_str
  :: ForeignPtr StdString
  -> IO String
string_c_str :: ForeignPtr StdString -> IO String
string_c_str ForeignPtr StdString
str = forall a ca y cy.
(Castable a ca, Castable y cy) =>
(ca -> IO cy) -> a -> IO y
_cast1 Ptr StdString -> IO String
Unmanaged.string_c_str ForeignPtr StdString
str

instance Castable String (ForeignPtr StdString) where
  cast :: forall r. String -> (ForeignPtr StdString -> IO r) -> IO r
cast String
str ForeignPtr StdString -> IO r
f = String -> IO (ForeignPtr StdString)
newStdString_s String
str forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ForeignPtr StdString -> IO r
f
  uncast :: forall r. ForeignPtr StdString -> (String -> IO r) -> IO r
uncast ForeignPtr StdString
xs String -> IO r
f = ForeignPtr StdString -> IO String
string_c_str ForeignPtr StdString
xs forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= String -> IO r
f