Yhc/API/Interpreter

From HaskellWiki
< Yhc‎ | API
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Part of Yhc

(Download)

Yhc - Yhi Api

Some people want an Api for Yhi. It's needed for a good version of Yhe.

In particular its needed to embed Haskell into Linda.

Load a module

//Load a module from an array of bytes
Module loadModule(const char* Data, int Length);
//Load a module from a file
Module loadModuleFromFile(const char* FileName);

Running Main

data Console = Console {
    stdout :: Char -> IO (),
    stderr :: Char -> IO (),
    stdin  :: IO Char
  }
runMain :: Module -> Console -> IO ()
runMainThread :: Module -> Console -> IO () -> IO (IO ())
-- result is an action that when applied aborts the computation.
-- There is also an IO that is evaluated when the program terminates cleanly.

Apparently GtkHs does this, uses FunPtr, grep for "foreign .*wrapper" - see FfiCookbook