Re:Why do our programs need to read input and write output?
by Gabriel439 on Sunday October 08, 2017 @01:44PM
(#15429125)
Your program can be a pure function which somebody else can invoke, so it's not necessarily a constant
However, Dhall does have the ability to normalize under lambda when possible so it will actually do this for you if it can! For example, if you try to interpret this program, which is a function:
let replicate = https://ipfs.io/ipfs/QmQ8w5PLcsNz56dMvRtq54vbuPe9cNnCCUXAQp6xLc6Ccx/Prelude/List/replicate
in let exclaim = λ(t : Text) → t ++ "!"
in λ(x : Text) → replicate +3 Text (exclaim x)
The interpreter will simplify that down to: λ(x : Text) → [x ++ "!", x ++ "!", x ++ "!"] : List Text
... although it can't do anything else until somebody else comes along later and calls the function on a specific input
If you compile your inputs into your program, what you're left with is a fancy constant. You might as well let the compiler take the final step of running the program for you and printing the output.
If you think Dhall is great and more people should use it as their I/O library, that's awesome, maybe show some of the cool things it does. Motivating it's usage by trying to make I/O a functional vs imperative issue just seems really contrived, and mostly wrong and prone to argument. I/O isn't a functional issue, and it is one of the main reasons to write a program: to do some work parameterized over different inputs.