Friends

Short summary: can someone familiar with using the GHC API offer advice on 
getting the Wolfram Language connected to Haskell?

Many of you will know of the Wolfram 
Language<https://www.wolfram.com/language/>, which is IMHO pretty cool and not 
well enough known.    There are lots of interesting things about it, but a huge 
thing is that it's deeply connected to the vast pile of carefully curated data 
that Wolfram Research has gathered and organised over several decades.

Anyway, they'd like to be able to invoke Haskell code from the Wolfram Language 
interpreter.   But as you'll see below, they are understandably stumbling on 
the engineering aspects of doing so.

Rather than spam Stephen Wolfram himself, I'm cc'ing Todd Gayley who is the 
team lead.  (Hi Todd.)   I'd really appreciate it if some of you could help 
advise him.  It would be terrific to have a direct connection between Wolfram 
and Haskell!


Many thanks

Simon

From: Stephen Wolfram
Sent: 01 April 2020 01:49
To: Simon Peyton Jones <simo...@microsoft.com>
Subject: Haskell question, etc.



Simon ---

[...snip...]

What brings me to email is a Haskell question:

It's probably best that I just forward what my team wants to ask:

=========

A powerful feature of the Wolfram Language is that it allows users to evaluate 
code in other programing languages, returning the results to a Wolfram notebook 
(https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Freference.wolfram.com%2Flanguage%2Fguide%2FExternalInterpretedLanguageInterfaces.html&amp;data=02%7C01%7Csimonpj%40microsoft.com%7Cb8abce5772944182a1de08d7d5d68940%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637212989714565411&amp;sdata=po6qg70bq8f4jbEvTRv6eoQfhLSZ3Fvdj3DBJFpWB%2FY%3D&amp;reserved=0).
 We have implemented this feature for a number of languages, including Python, 
NodeJS, Julia, and Ruby. We would very much like to include Haskell in this 
set, but we have little Haskell expertise, and have hit a stumbling block. We 
would appreciate it if some Haskell experts could help us out with this feature.

We have the following basic line of code for evaluating a string of Haskell 
code:

    r <- liftIO $ runInterpreter $ do { setImports ["Prelude"]; eval 
strToEvaluate}

The problem is that this is a one-shot evaluation, and we want a long-lived 
interactive Haskell session, to which a series of inputs can be directed. We 
have been told that we have to use GHCi for that, but we don't know how to do 
it.

The basic flow of our functionality is as follows:

1) User calls StartExternalSession["LanguageName"] to launch an interpreter for 
the language. This process remains running and can be used for multiple calls.

2) User calls ExternalEvaluate[session, "some code"] to execute the given code 
in the external language and return a result converted into native Wolfram 
Language types (strings, numbers, lists, associations, etc.)

ZeroMQ is used as the transport between Wolfram Language and the external 
language interpreter, and JSON is the data format we use to return results. 
Beyond the basics of hooking up GHCi for this type of session use, we also 
would like assistance in introspection of Haskell results so that they can be 
sent back to WL in the most useful form. This is the general structure of what 
we do for other languages:

     if result is an object
         return object data
     else if result is a function
         return function data
     else
        return JSON form of the expression

We have attached a simple file of Haskell code that one of our engineers has 
successfully used to get a basic evaluation of Haskell code from the Wolfram 
Language, but it uses the single-shot evaluation code that was given above, and 
so is not suitable. We would appreciate any help that you can give us, or 
developers or resources you can point us at, to assist in integrating Haskell 
into our ExternalEvaluate system.


========



Any help greatly appreciated!  (Not least because I'd personally like to play 
with this... :) )

--- Stephen

Attachment: start_Haskell.hs
Description: start_Haskell.hs

_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to