# Pastebin GCB7AnJv main = do -- Let's read a number from input... putStrLn "Enter a nonnegative integer: " n <- read <$> getLine -- use this number with the C function a couple times traverse f =<< createStuff n traverse f =<< createStuff (n * 2) -- note that f does not deallocate its argument -- that is done automatically by the GC later -- withForeignPtr is used to "downgrade" ForeignPtr to a Ptr where f fPtr = withForeignPtr fPtr (\p -> do -- convert a C char* to a -- Haskell String xs <- peekCString p putStrLn xs)