Hi Leila
You can use pretty much any language you like once it's installed on the Jobe server. See the documentation on
Supporting or implementing new languages.
So in your case you'd need to get your sysadmin to install ghc on the Jobe server (command: sudo apt install ghc
).
You should then be able to follow through the step-by-step guide in the above-linked documentation section, replacing 'C' with 'Haskell' throughout and using the following template code in lieu of that given for C.
""" The template for a simple write-a-program Haskell question type."""
import subprocess
# Write the student code to a file
student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
with open("Main.hs", "w") as src:
print(student_answer, file=src)
# Run it.
subprocess.run(["runhaskell", "Main.hs"], text=True)
When that's done, you should find you have a new question type haskell_via_python (or whatever else you chose to call it). I attach an export of the prototype, though I recommend you work through the construction of it yourself if you can. I also attach a trivial demo which behaves as follows:
Import caveats:
- I'm not a Haskell programmer so there may be all sorts of restrictions/limitations/error situations that I'm unaware of.
- This is just a write-a-program question type. More complex question types, such as write-a-function, are of course possible but require a bit more understanding of CodeRunner and prototypes.
- Since both Python and Haskell run within the same allocated virtual memory, you will likely run out of memory with larger programs. It depends on what sort of questions you're setting. You may wish to set a high MemLimit value within the prototype (hidden under Advanced Customisation).
- You do need to be understand question prototypes and manage them carefully. There are quite a few gotchas. See the documentation.
If this prototype proves useful, please post back and I'll include it in the unsupported question types folder in the repo. If it doesn't prove useful, or your have issues with it, please let us know, too.