[Haskell] Running haskell from within Haskell

Donald Bruce Stewart dons at cse.unsw.edu.au
Tue Jan 18 21:51:24 EST 2005


vivian.mcphail:
> 
>    Dear All,
>    I have a parser which has entries for each word, such as:
> 
>    ate  = s \ np / np  : ^x y.did(eat y x);
> 
>    so each word has a type (s \ np / np) and a semantics (the
>    lambda term ^x y.did(eat y x)).
> 
>    Currently I parse the semantics into lambda terms and use my
>    own lambda-interpreter to do evaluation.
> 
>    "I ate a python programmer" would be evaluated as:
> 
>    did(eat I (a python programmer))
> 
>    What I would like to be able to do is actually use haskell
>    functions in the semantic slot for each word.  This requires
>    parsing a fragment of a file into haskell and then making it
>    available as code within my program.
> 
>    Is this possible?
> 
>    for example:
> 
>    kicked = s \ np / np : \x y -> case x of
> 
>                                        (the bucket) = did(die
>    y)
> 
>                                        _                = did(k
>    ick y x);
> 
>    Thanks in advance.

You may be able to use the eval functions provided by hs-plugins
    http://www.cse.unsw.edu.au/~dons/hs-plugins/

A number of mini-edsl-interpreters for Haskell have been written this
way. Where:
    eval :: Typeable a => String -> [Import] -> IO (Maybe a)

An example of an interpreter for Haskell, using this mechanism, is at:
    http://www.cse.unsw.edu.au/~dons/hs-plugins/hs-plugins-Z-H-14.html#node_chap_B

-- Don


More information about the Haskell mailing list