1

What I would like to achieve:

./myHaskellProgram aLambdaFunc aFilePath

This aLambdaFunc is a string that the user provides and will run on the aFilePath.

I suppose I need Template Haskell and parse the aLambdaFunc string? Is there an easier way to do this?

daydaynatation
  • 550
  • 2
  • 8

3 Answers3

0

You could just load your program into ghci and let the user type Haskell expressions. And you can do a bit better using a custom quasi quoter.

David Fox
  • 654
  • 4
  • 10
0

You could either use a system call to invoke GHCI (very unsafe) or you could write an entire parser.

You have an example on the ihaskell project, which uses a parser to create an interactive kernel compatible with Jupyter Notebook.

David Davó
  • 417
  • 1
  • 4
  • 18
0

The mueval package attempts to sandbox and execute Haskell code at runtime. It seems to be what you're looking for. It is(was) used in production by Chris Done's Try Haskell and some parts of lambdabot.

Ari Fordsham
  • 2,437
  • 7
  • 28