Questions tagged [ghc-api]

39 questions
3
votes
1 answer

Determine ModuleName of loaded target

I was wondering how do you determine the ModuleName of the file you've just loaded in ghc using the API. If you look at the Documentation of the API they always assume you know the module name before you load the file in. I have tried top sorting…
Phyx
  • 2,697
  • 1
  • 20
  • 35
2
votes
2 answers

Why cannot top level module be set to main in Hint

Why cannot top level module be set to "Main" in Hint (Language.Haskell.Interpreter)? Allow me to demonstrate: module Main where import Language.Haskell.Interpreter import Control.Monad main = do res <- runInterpreter (test "test") case res…
Daniel O
  • 4,607
  • 6
  • 44
  • 52
2
votes
1 answer

Using GHC API from GHC compiled from source

I'd like to, within a client program, use the GHC API from a modified version of GHC. Its easy enough to get the GHC sources and build and install the modified GHC, but installing the modified GHC causes all older (Cabal) dependencies to break.…
Ranjit Jhala
  • 1,242
  • 8
  • 18
2
votes
0 answers

Parsing a Type using a GHC-Plugin

I'm working on a compiler plugin that should abort compilation if a declaration doesn't have a type that given as a plugin argument. I think the function Unify.tcMatchTy :: Type -> Type -> Maybe TCvSubstS would do the trick. I can find one of the…
aleator
  • 4,436
  • 20
  • 31
2
votes
0 answers

Running Q Exp in a GhcMonad

I'm looking for something with a type similar to this: runQExpDynamically :: (GhcMonad m) => Q Exp -> m Dynamic Docs: GhcMonad, Q Exp, Dynamic, I'm looking for ways to combine two of my code examples; one for dynamically evaluating haskell code…
worldsayshi
  • 1,788
  • 15
  • 31
2
votes
1 answer

ghc-mtl fails to build with ghc-7.8

I'm trying to build ghc-mtl-1.2.1.0 with ghc-7.8.3 and I'm getting these error messages: Control/Monad/Ghc.hs:42:15: No instance for (GHC.MonadIO Ghc) arising from the 'deriving' clause of a data type declaration Possible fix: …
n. m. could be an AI
  • 112,515
  • 14
  • 128
  • 243
1
vote
1 answer

get the renamed (with fully qualified import) haskell AST using ghc api

I can get the following ghc compiler working using ghc api to compile a single file.I would like to get the renamed AST of haskell source (AST with all function calls fully qualified) ghcmake = defaultErrorHandler defaultFatalMessager…
doofin
  • 508
  • 2
  • 13
1
vote
1 answer

Language.Haskell.Interpreter - how to properly call IO actions?

Following the example file, I try to dynamically call an IO action. testHint :: Interpreter () testHint = do setImportsQ [("Prelude", Nothing)] let somecode = "putStrLn \"some string\"" interpret…
user1546806
  • 137
  • 6
0
votes
2 answers

Haskell: Can a function be compiled?

Consider a simple Haskell Brainf*ck interpreter. Just look at the interpret function. import Prelude hiding (Either(..)) import Control.Monad import Data.Char (ord, chr) -- function in question interpret :: String -> IO () interpret strprog = let…
firefrorefiddle
  • 3,795
  • 20
  • 31
1 2
3