1 # shake/args: the process's arguments, each word reusable, internal (main.bend 2 # exports it). `IO.args` answers a `&1` list that starts with the program as 3 # invoked (bend 2.0.32 and later); the rest of a program reads the line more 4 # than once, so `words` drops that head and copies the rest. 5 import Base 6 7 # a &1 list copied to &2 8 def copy(xs: List<&1, String>) -> List<&2, String>: 9 match xs: 10 case Nil{}: 11 Nil{} 12 case Con{+h, t}: 13 h <> copy(t) 14 15 # the arguments of an IO.args line: every word after the program name, copied 16 def words(xs: List<&1, String>) -> List<&2, String>: 17 match xs: 18 case Nil{}: 19 Nil{} 20 case Con{_h, t}: 21 copy(t) 22 23 # the process's arguments, without the program name 24 def argv() -> IO(List<&2, String>): # noqa: L001 IO: reads argv (SHAKE-TRUST-4) 25 IO.bind(List<&1, String>, List<&2, String>, IO.args(), 26 xs => IO.pure(List<&2, String>, words(xs)))