unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.78k stars 270 forks source link

ucm run : Numeric arguments are changed to find results #2805

Open hagl opened 2 years ago

hagl commented 2 years ago

When running a main function in ucm a numeric argument is replaced by the potential last result of a find command:

main _ = printLine ("Hello " ++ Optional.getOrElse "" (head !getArgs) ++ "!")
.> run main 1
Hello 1!
.> find isAscii

  1. base.Char.ascii.isAscii : Char -> Boolean
  2. base.Char.ascii.isAscii.doc : Doc.Deprecated

.> run main 1  
Hello base.Char.ascii.isAscii#o1nnl7n4cpa2ddq66u50cda6ns8d6uo2j3gngcm70071rub2gq9n10kfemhvij3dk6rohigvn7os91gh5j9pbg6nk84noq39pm9luio!

See this discussion on Slack: https://unisonlanguage.slack.com/archives/CLUNF0J5S/p1642108647023800

iacore commented 2 years ago

same problem here

main : '{IO, Exception} ()
main _ = let
  use Text ++
  printLine "Hello world"
  args = !getArgs
  List.foldLeft
    (i arg -> let
      printLine (toText i ++ ": " ++ arg)
      i + 1) 0 args
  ()

$ ucm
.> find
# exit find
.> run main 0 1
Hello world
0: 0
1: add_mul#bl5qhvd4r9qdnm01vhksm6ekve2l1ibbp36p5qjeq8bsh0cokkepl22otlhp5f982a410u08714j7jse5lkontk97c9q9il53ct7nh8
aryairani commented 1 month ago

Can we change it from a pre-step to a per-argument thing, have it be part of the argumentType? IIRC we want substitution for everything except args 2+ when running.

aryairani commented 1 month ago

Even a workaround like clearing the numbered args would be better than nothing.