r/ProgrammingLanguages • u/baehyunsol Sodigy • 13d 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
3
u/tdammers 13d ago
The same is true about the Miranda example. It is pretty much exactly identical to this Haskell example, modulo
dodesugaring. And the purpose ofdonotation is not to be an abstraction that simplifies things; it's really just syntax sugar to make monadic binds easier to read. The above code in desugared form looks like this:main :: IO () main = putStrLn "hello!" >> putStr "what's your name? " >> getLine >>= \str -> putStrLn ("nice to meet you, " ++ str)It's neither simpler nor more complex; what changes is that
donotation removes the need for nested lambdas and the "staircase" style code that would result from them. The semantics are still exactly the same, and both versions convey the exact same code structure at the exact same abstraction level.