unisonweb / unison

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

Error message mentions Maybe instead of Optional #4357

Open chtenb opened 11 months ago

chtenb commented 11 months ago
> List.at (Some 1) [1,2,3]

UCM:

  The 1st argument to `List.at`

            has type:  Maybe Nat
      but I expected:  Nat

     97 | > List.at (Some 1) [1,2,3]
> view Some

  structural type lib.base.Optional a = Some a | None
ceedubs commented 10 months ago

@chtenb if you do names Optional what do you see? I suspect that another library is introducing the name Maybe such that Optional and Maybe are both names for the same type. The pretty-printer arbitrarily chooses Maybe (probably because it's shorter and/or comes first alphabetically).

While this is confusing, it's arguably working as intended. It certainly is confusing behavior for the code author, though.

I think that the lowest hanging fruit is to get that Maybe alias outside of common libraries. I think that the lowest-hanging fruit is to get this alias outside of common libraries. I think that it might already be removed from the newer versions of some of the libraries that it used to appear in. Let me know what your names output says, as it might be another place that we should remove it.

A more complicated solution might involve convincing error messages to use the names that are used in the offending code in the scratch file. But I don't know quite what that would look like. Here your code doesn't even mention Optional. It mentions Some, which isn't really directly tied to the name Optional for the type.

chtenb commented 10 months ago

Ah, that is understandable.

@chtenb/aoc2020/main> names Optional

  Type
  Hash:  #nirp5os0q6
  Names: lib.advent_of_code_client.lib.base.Optional
         lib.advent_of_code_client.lib.httpclient.lib.base.Optional
         lib.advent_of_code_client.lib.httpclient.lib.codec.lib.names.Maybe
         lib.advent_of_code_client.lib.httpclient.lib.codec.lib.names.Option
         lib.advent_of_code_client.lib.logging.lib.base.Optional
         lib.base.Optional
         lib.uniparsec.lib.base.Optional
ceedubs commented 10 months ago

@rlmark when you turned the AOC client into a project, is there any chance that you upgraded libraries and this Maybe no longer exists in there? If not we might want to do that before December.

rlmark commented 9 months ago

I did indeed upgrade the libraries, and was just notified that a similar issue was occurring for another community member. Is the solution to add Maybe back? Or remove Maybe from the Codec library in the next version and upgrade again?

ceedubs commented 9 months ago

@rlmark oh sorry that message came across differently than I meant. I was hoping that you did update some libraries and that meant that the references to Maybe would be gone in the future. But I'm not sure what (if anything) might be hanging around in the codec library.