Standard Effects
The built-in effect operations that ship with Loon.
IO
println : Str -> ()
Print a string followed by a newline to stdout.
print : Str -> ()
Print a string to stdout without a trailing newline.
read-line : () -> Str
Read a line of input from stdin.
read-file : Str -> Str
Read the entire contents of a file as a string.
write-file : Str -> Str -> ()
Write a string to a file, creating or overwriting it.
Fail
fail : Str -> a
Raise an error with a message. Aborts unless handled.
try : (() -> a) -> Result a Str
Run a computation, catching any fail effect as Err.
[let result [try [fn [] [fail "oops"]]]]
[match result
[Ok val] [println val]
[Err msg] [println [str "error: " msg]]]Async
spawn : (() -> a) -> Task a
Spawn a concurrent task that runs in the background.
await : Task a -> a
Block until a task completes and return its result.
[let t [spawn [fn [] [+ 1 2]]]]
[println [await t]] ; 3Process
exec : Str -> #[Str] -> Result Str Str
Run an external command with arguments. Returns stdout on success.
env : Str -> Option Str
Read an environment variable. Returns None if unset.
args : () -> #[Str]
Return the command-line arguments as a vector of strings.
Net
fetch : Str -> Map -> Result Str Str
Make an HTTP request. The map contains method, headers, and body.
listen : Int -> (Conn -> ()) -> ()
Listen for TCP connections on a port and handle each one.
serve : Int -> (Request -> Response) -> ()
Start an HTTP server on a port with a request handler.
Physics
gravity : () -> Acceleration
Return gravitational acceleration for the current environment.
yield-strength : () -> Pressure
Return the yield strength of the current material.
elastic-modulus : () -> Pressure
Return the elastic (Young's) modulus of the current material.
density : () -> Density
Return the density of the current material.
temperature : () -> Temperature
Return the ambient temperature.
thermal-conductivity : () -> ThermalConductivity
Return the thermal conductivity of the current material.
[handle [analyze beam 10.0kN]
[Physics.gravity] [resume [unit 9.81 :m]]
[Physics.yield-strength] [resume 250.0MPa]
[Physics.density] [resume [unit 7850.0 :kg]]]Sim
stress : geometry -> material -> load -> Pressure
Compute stress for a given geometry, material, and load.
deflection : geometry -> material -> load -> Length
Compute deflection under load.
natural-freq : geometry -> material -> Frequency
Compute the natural frequency of a structure.
thermal-field : geometry -> material -> sources -> Temperature
Compute the temperature field for given heat sources.