I could:
import Foreign.C.String
import Foreign.Marshal.Alloc
-- Your declarations and foreign bindings here
getTime :: IO String
getTime = do
p <- malloc
c_time p
tmPtr <- c_localtime p
str <- peekCString $ c_asctime tmPtr
free p
return str
main :: IO ()
main = do
currentTime <- getTime
putStrLn currentTime
malloc free, , c_time , c_localtime CTmStruct, c_asctime, CString, Haskell String peekCString , , , .
, , alloca:
getTime :: IO String
getTime = alloca $ \p -> do
c_time p
tm <- c_localtime p
peekCString $ c_astime tm
, . alloca , , , .