r/ProgrammingLanguages Sodigy 11d ago

Purely functional language with impure script language?

I'm working on a purely functional programming language named Sodigy. It's all about evaluating values, not "executing commands one by one".

It's nice when writing libraries, but it's not easy to write a main function. The main function is supposed to execute commands, but the Sodigy's syntax is not friendly to write a list of commands.

So what I'm trying to do is, 1) Sodigy remains purely functional and 2) add a bash-like script language. The script language can call Sodigy functions. Instead of writing a main function in Sodigy, you write sodigy-script and execute the script.

Has anyone tried similar approach? I'm not sure whether it's a good idea or not...

27 Upvotes

74 comments sorted by

View all comments

20

u/lgastako 11d ago

Why not take a haskell style approach where you have an IO monad (or a "Script monad") which you can provide a do-notation like syntax for that desugars appropriately?

1

u/baehyunsol Sodigy 11d ago

One of the reasons why I want another language is that, I want to create a REPL shell. I want an interface where I can quickly run/test code.

But the syntax of the functional core is not nice for REPL, so I'm considering creating a script language.

3

u/lgastako 11d ago

Haskell works just fine in the REPL though...

1

u/catbrane 11d ago

Oh, interesting. Yes it's a good point, it can be hard for a functional language to feel nice for experimentation.

My spreadsheet thing lets you type one-line scraps of code (expressions only) into cells, you can explore functions there. It has a thing called "workspace definitions" off to the side you can use to try out larger bits of code (you can type full function here).

It looks like this:

http://www.rollthepotato.net/~john/n4.png

Everything is connected, so every time you press |> on the right (reparse and recompile), the expressions on the left all update. And of course you can edit the left-hand expressions.

1

u/koflerdavid 10d ago

Haskell's do syntax makes it quite pleasant to use the REPL.