[Haskell-cafe] Type checking the content of a string

Corentin Dupont corentin.dupont at gmail.com
Sat Feb 23 00:03:45 CET 2013


I'm trying to load my interpreter in the Q monad:

cr :: QuasiQuoter
cr = QuasiQuoter { quoteExp = quoteRuleFunc}

quoteRuleFunc :: String -> Q TH.Exp
quoteRuleFunc s = do
   res <- runIO $ runInterpreter $ do
      setImports ["Prelude", "Language.Nomyx.Rule",
"Language.Nomyx.Expression", "Language.Nomyx.Test",
               "Language.Nomyx.Examples", "GHC.Base", "Data.Maybe"]
      interpret s (as :: RuleFunc)
   case res of
      Right _ -> [| s |]
      Left e -> fail $ show e


 However, I always obtain an error durring compilation:

...
Loading package XXX ... linking ... done.


GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   __stginit_ghczm7zi4zi1_DsMeta
whilst processing object file
   /usr/lib/ghc/ghc-7.4.1/libHSghc-7.4.1.a
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
     loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.


I vaguely understand that the interpreted modules are conflicting with the
compiled ones...


On Fri, Feb 22, 2013 at 11:51 PM, Corentin Dupont <corentin.dupont at gmail.com
> wrote:

> Great! That seems very powerful. So you can do what you want during
> compilation, readin files, send data over the network?
> Other question, in my example how can I halt the compilation if a test
> program is wrong?
>
>
> On Fri, Feb 22, 2013 at 8:30 PM, Francesco Mazzoli <f at mazzo.li> wrote:
>
>> At Fri, 22 Feb 2013 19:43:51 +0100,
>> Corentin Dupont wrote:
>> > Hi Adam,
>> > that looks interresting. I'm totally new to TH and QuasiQuotes, though.
>> > Can I run IO in a QuasiQuoter? I can run my own interpreter.
>>
>> Yes, you can:
>> <
>> http://hackage.haskell.org/packages/archive/template-haskell/2.8.0.0/doc/html/Language-Haskell-TH.html#v:runIO
>> >.
>>
>> Francesco
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130223/3bdfd870/attachment.htm>


More information about the Haskell-Cafe mailing list