cashew-s-engine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[CASHeW-s-engine] Shinyness (Dynamic Haskell)


From: Simon Foster
Subject: [CASHeW-s-engine] Shinyness (Dynamic Haskell)
Date: 29 Nov 2004 13:59:59 +0000

I think I may have found (well I say found, I knew about it already,
just hadn't discovered this part of it yet) the answers to a number of
problems. We were talking about the loading of and execution of Haskell
code for our OWL-S extensions. Well quite simply, Don's hs-plugin
library can _already_do_this_ and it's type-safe. How? Simple, he
provides a function called eval;

eval :: Typeable a => String -> [Import] -> IO (Maybe a)

Where the String is Haskell code you want to evaluate and the list is
any imports required. This lovely function apparently allows the
evaluation of arbitrary Haskell code (providing it's valid of course)
and will return either a value or Nothing depending on 

- Whether it's valid Haskell code
- Whether it type-checks.

Any it also throws a number of exceptions to aid in error checking.

It also works (also a bonus);

Prelude Eval.Haskell> i <- eval "1 + 6 :: Int" [] :: IO (Maybe Int)
Prelude Eval.Haskell> i
Just 7
Prelude Eval.Haskell>

Website at:

http://www.cse.unsw.edu.au/~dons/hs-plugins/hs-plugins.html

I've installed the appropriate packages, and it seems to work. If it
does do what we want, it should allow us to do quite a number of things
we couldn't do before, but completely safely (unlike Lisp).

-Si.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]