LightAndLight / ipso

A functional scripting language.
https://ipso.dev
17 stars 1 forks source link

Overloaded interpolation in command literals #132

Closed LightAndLight closed 2 years ago

LightAndLight commented 2 years ago

Depends on #134.

Command literals should support interpolation for strings and arrays.

Examples

1.

let words = ["hello", "world"] in `echo $words`

is equivalent to

`echo hello world`

When interpolating an array, each item of the array is an argument to the command.

2.

let words = ["hello", "new world"] in `echo $words`

is equivalent to

`echo hello "new world"`

When an array item contains spaces, that item is still treated as a single argument rather than multiple arguments.

3.

(\name -> `echo "hello $name"`) : String -> Cmd

When an expression is interpolated into a quoted argument, that expression is treated as a string.

4.

(\args -> `echo $args`) : ToArgs a => a -> Cmd

When an expression is interpolated and unquoted, that expression is treated as an argument list.

Implementation

Notes