Mercury-Language/mercury

use_module does not work for list.'[]'

Closed this issue · 2 comments

I decided to try out Mercury recently and started to follow a tutorial.
Usually as I go through a tutorial I try to see how things work, and in this case I was seeing how to control namespacing.

The tutorial uses :- import_module io., naturally main looks like so.

:- pred main(io::di, io::uo) is det.

I figure I would try :- use_module io., making it explicit.

:- pred main(io.io::di, io.io::uo) is det.

One would think this would work for everything, and so far it largely does.
there seems to be an exception for list.'[]'

I can't get this to compile

:- module print_univs.
:- interface.
:- use_module io.

:- pred main(io.io::di, io.io::uo) is det.


:- implementation.
:- use_module list.
:- use_module string.
:- use_module univ.


main(!IO) :-
  print_univ(univ.univ(1), !IO),
  print_univ(univ.univ("2"), !IO),
  print_univ(univ.univ(3.4), !IO),
  print_univ(univ.univ({5, 6, 7}), !IO).

:- pred print_univ(univ.univ::in, io.io::di, io.io::uo) is det.
print_univ(U, !IO) :-
  ( if      univ.univ_to_type(U, C) then io.format("a  char,   %c\n",     list.'[|]'(string.c(C), list.'[]'), !IO)
    else if univ.univ_to_type(U, S) then io.format("a  string, \"%s\"\n", list.'[|]'(string.s(S), list.'[]'), !IO)
    else if univ.univ_to_type(U, I) then io.format("an int,    %d\n",     list.'[|]'(string.i(I), list.'[]'), !IO)
    else if univ.univ_to_type(U, F) then io.format("a  float,  %f\n",     list.'[|]'(string.f(F), list.'[]'), !IO)
    else    io.format("no idea...\n", [], !IO)
  ).

note if i replace :- use_module list. with :- import_module list it will compile.

I'll continue to check out the language, but I'd like to know if this is a bug, or intentional.

That worked!
What an oversight on my part.

Thank you for your time, I'll be sure to look at all the errors next time, instead of the ones that catch my eye first.

I'll close the issue.