myProgram : '{IO, Exception} ()
myProgram = '(printLine "Hello World")
myProgramWithArgs : '{IO, Exception} ()
myProgramWithArgs = 'let
printLine ("Hello " ++ Optional.getOrElse "World" (List.head !getArgs) ++ "!")
scratch/main> run myProgram
scratch/main> run myProgramWithArgs Rebecca
The run
command is used to evaluate terms that require the IO ability within ucm. A program that performs IO cannot be evaluated in a watch expression but can be executed with run
.
Run takes a delayed computation and performs !myProgram
, where myProgram
is searched for in the most recent typechecked file, or in the codebase. The function provided to the run command can return any type, and may perform the IO and Exception
abilities.
Any arguments following the run
command will be passed as program arguments.