
Hi all, I was wondering if someone knows how to do the following: Im looking to typecheck a string using the GHC Api, where I run into problems is that I need to construct a Target, but the TargetId only seem to reference physical files. Ofcourse I can write the string to a file and typecheck that file, but I would like to do it all in memory and avoid IO if possible. Does anyone know if this is possible? For the record Im trying to create the target as follows createTarget :: String -> IO Target createTarget content = do clock <- getClockTime buffer <- stringToStringBuffer content return $ Target { targetId = TargetModule (mkModuleName "string:internal") ß problem , targetAllowObjCode = True , targetContents = Just (buffer,clock) } typeCheckStringOnly :: String -> IO (ApiResults Bool) typeCheckStringOnly contents = handleSourceError processErrors $ runGhc (Just libdir) $ do dflags <- getSessionDynFlags setSessionDynFlags dflags target <- liftIO $ createTarget contents addTarget target load LoadAllTargets let modName = mkModuleName "string:internal" ß problem again, dont know how to create the dependency graph then. graph <- depanal [modName] True (\a->setSession $ a { hsc_mod_graph = graph }) =<< getSession value <- fmap typecheckedSource (typeCheck modName) return $ ApiOk True Cheers, Phyx