Closed GoogleCodeExporter closed 8 years ago
Original comment by fiddloso...@gmail.com
on 6 Nov 2008 at 10:23
Unfortunately, dons says that the plugins library is no longer maintained.
Original comment by fiddloso...@gmail.com
on 11 Nov 2008 at 3:04
The hint library might be an alternative to plugins. Check to see if it is
actively
maintained.
Original comment by fiddloso...@gmail.com
on 12 Nov 2008 at 12:57
Or mueval, for more safety.
Original comment by fiddloso...@gmail.com
on 12 Nov 2008 at 1:06
Example of use of hint, in ghci:
> :m + Language.Haskell.Interpreter.GHC
> :m + Text.Pandoc
> inp <- readFile "README"
> let y = withSession ses (setImports ["Text.Pandoc","Prelude"] >> (interpret
("writeLaTeX defaultWriterOptions $ readMarkdown defaultParserState $ " ++ show
inp)
(as :: Pandoc)))
> y
Original comment by fiddloso...@gmail.com
on 13 Nov 2008 at 7:04
Note: the example above is missing
ses <- newSession
also try this:
> :m + Control.Monad.Errors
> e <- withSession ses (setImports ["Prelude"] >> (catchError (interpret "(+)"
(as ::
Int -> Int)) (\e -> return id)))
> e 2
4
> e <- withSession sess (setImports ["Prelude","Text.Pandoc"] >> (interpret
"processPandoc (const Space)" (as :: Pandoc -> Pandoc)))
> e $ Pandoc (Meta [] [] []) [Para [Str "Hi",Space,Emph [Str "there"]]]
Pandoc (Meta [] [] "") [Para [Space,Space,Space]]
Original comment by fiddloso...@gmail.com
on 14 Nov 2008 at 7:30
This is fun:
-- MyMod.hs
module MyMod (doit) where
import Text.Pandoc
doit :: Inline -> Inline
doit (Str x) = Str (x ++ "!")
doit x = x
-- GHCI:
GHCI> e <- withSession sess (loadModules ["MyMod"] >> setImports
["Prelude","Text.Pandoc","MyMod"] >> (catchError (interpret "processPandoc
doit" (as
:: Pandoc -> Pandoc)) (\e -> throwError e >> return id)))
GHCI> e $ Pandoc (Meta [] [] []) [Para [Str "Hi",Space,Emph [Str "there"]]]
Pandoc (Meta [] [] "") [Para [Str "Hi!",Space,Emph [Str "there!"]]]
Original comment by fiddloso...@gmail.com
on 14 Nov 2008 at 7:44
The newest release of hint supports GHC 6.10.
Time to get going on this!
Original comment by fiddloso...@gmail.com
on 1 Jan 2009 at 5:02
> Or mueval, for more safety.
Mueval might work as a library, with some modification to the internal API. But
given
that the code is either A) supplied by the developers and presumably vetted and
checked; or B) written by the user who has incentive to not write evil code,
mueval
may be the wrong solution.
It is also relatively inefficient compared to running Hint directly, due to the
resource-limiting, process-level and thread-level watchdogs, checks to sanitize
the
code, etc. That's fine for running potentially-evil code since the alternative
to
running slowly & safely is not running at all.
I would suggest Hint instead of Mueval. It is pleasant to use & Daniel Gorin has
always responded quickly to my needs (for mueval development), and I don't
foresee it
being abandoned anytime soon. (It certainly is currently a better solution than
hs-plugins inasmuch as the latter does not even work on 6.10.)
Original comment by gwe...@gmail.com
on 23 Jan 2009 at 9:47
Actually, I've already got all the plugin stuff written, using hint.
I've just been waiting for Daniel to upload the latest version (which
he did today), since the old version didn't cabal install under ghc 6.8.
So you should see the plugin stuff, including some worked-out examples,
in the repository before too long!
Original comment by fiddloso...@gmail.com
on 24 Jan 2009 at 2:29
Added as of r1526.
Original comment by fiddloso...@gmail.com
on 24 Jan 2009 at 8:01
Original issue reported on code.google.com by
fiddloso...@gmail.com
on 6 Nov 2008 at 10:22