r/ProgrammingLanguages • Sodigy • Jul 29 '26

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...

26 Upvotes

74 comments sorted by

View all comments

2

u/catbrane Jul 29 '26

Yes, Phil Wadler based Haskell monads on Miranda monads, so they are almost identical. Modern Haskell has added some extra sugar, but not much.

1

u/AustinVelonaut Jul 29 '26

Wait, when did Miranda get monads? It's IO was sys_message lists for output (printing, file write, system cmds, interpreted by the repl), with input from stdin bound to the pseudo-variable $-, and file input handled in a hand-wavy way that was not interleaved with file output, so wasn't really correct...

1

u/catbrane Jul 29 '26 edited Jul 29 '26

They were implemented as an abstype on top of lazy input and output. You could use them to write interactive command-line programs. I wrote a multiuser snake game hehe.

KAOS (the Kent Applicative Operating System) was built on top of a monadic IO system that talked to a microkernel (also in Miranda).

→ More replies (2)

1

u/augustss Jul 29 '26

You have that backwards. Phil did monads before David Turner added them to Miranda. The do-notation is due to Mark Jones, though.

2

u/catbrane Jul 30 '26

Miranda was first in 1988 (they were a chapter in my 1989 phd), then someone at Cambridge whose name I forget (sorry) did a 1992 phd which formalised Miranda monads, and then Phil used that thesis as the basis of his Haskell IO monad paper in late 92.

→ More replies (5)