<div dir="ltr">Hi Michael,<div><br></div><div>I believe that happens because the module List binds a function to the show variable:</div><div><br></div><div><div>val show = fn [a] (_ : show a) =></div><div>              let</div><div>                  fun show' (ls : list a) =</div><div>                      case ls of</div><div>                          [] => "[]"</div><div>                        | x :: ls => show x ^ " :: " ^ show' ls</div><div>              in</div><div>                  mkShow show'</div><div>              end</div></div><div><br></div><div>Therefore, opening the List module shadows the show function defined in the Basis module.</div><div><br></div><div>val show : t ::: Type -> show t -> t -> string<br></div><div><br></div><div>Regards,</div><div>Saulo</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 9, 2016 at 6:55 AM, Michael Rohs <span dir="ltr"><<a href="mailto:michael.rohs@hci.uni-hannover.de" target="_blank">michael.rohs@hci.uni-hannover.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Saulo,<br>
<br>
Thanks for your help. Thanks for the suggestion to add type annotations. It indeed works, but only if I don't open the List module.<br>
<br>
The problem appears if I add module List (even without using any of its functions).<br>
<br>
test.urp:<br>
$/list<br>
test<br>
<br>
test.ur:<br>
open List<br>
<br>
if I remove "open List" from test.ur it works.<br>
<br>
I don't understand why...<br>
<br>
Here is the full test.ur:<br>
------------------------------<wbr>----------------<br>
(*open List*)  <-- error if uncommenting this line<br>
<span class=""><br>
fun int2string (i : int) : string = show i<br>
</span>val s = int2string 123<br>
<br>
fun main () =<br>
    let<br>
        val stuff = "apple" :: "key" :: "goat" :: []<br>
        fun predicate (s : string) : bool = s <> "apple"<br>
        (* val stuff2 = List.filter predicate stuff*)<br>
    in<br>
        return <xml><body><br>
        {[s]}<br/><br>
          <br/><br>
        </body></xml><br>
    end<br>
------------------------------<wbr>----------------<br>
<br>
Best,<br>
Michael<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
> On 09 Oct 2016, at 10:04, Saulo Araujo <<a href="mailto:saulo2@gmail.com">saulo2@gmail.com</a>> wrote:<br>
><br>
> Hi Michael,<br>
><br>
> Your definition of int2string is fine. For example, the code<br>
><br>
> fun int2string (i : int) : string = show i<br>
><br>
> val s = int2string 10<br>
><br>
> compiles without errors. I suspect the problem is in another part of your code. The error message suggests that you have an expression that produces a list where something else is expected. In my experience learning languages of the ML family, in situations like this, it helps to type-annotate arguments and results of functions. Eventually, it also helps to type-annotate expressions. For example<br>
><br>
> val h = 10<br>
> val t = []<br>
> val s = (h :: t) : int<br>
><br>
> Thanks to the type annotation ": int", the compiler will produce an error saying that there is a list int where an int is required:<br>
><br>
> Expression:  Basis.Cons [int] {1 = h, 2 = t}<br>
>   Have con:  list int<br>
>   Need con:  int<br>
> Incompatible constructors<br>
> Have:  list int<br>
> Need:  int<br>
><br>
> Regards,<br>
> Saulo<br>
><br>
> On Sun, Oct 9, 2016 at 4:07 AM, Michael Rohs <<a href="mailto:michael.rohs@hci.uni-hannover.de">michael.rohs@hci.uni-<wbr>hannover.de</a>> wrote:<br>
> Hi all,<br>
><br>
> I have a question to a very simple problem. How to convert an integer to a string?<br>
><br>
> This does not work:<br>
><br>
> fun int2string (i : int) : string = show i<br>
><br>
> Error message:<br>
><br>
> /.../test.ur:19:36: (to 19:40) Unification failure<br>
> Expression:  show [<UNIF:H::Type>] _<br>
>   Have con:  show (list <UNIF:H::Type>)<br>
>   Need con:  <UNIF:I::Type> -> <UNIF:J::Type><br>
> Incompatible constructors<br>
> Have:  show (list <UNIF:H::Type>)<br>
> Need:  <UNIF:I::Type> -> <UNIF:J::Type><br>
><br>
> I couldn't find anything else like Int.toString or so.<br>
><br>
> Thank you very much in advance!<br>
><br>
> Best,<br>
> Michael<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Ur mailing list<br>
> <a href="mailto:Ur@impredicative.com">Ur@impredicative.com</a><br>
> <a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer" target="_blank">http://www.impredicative.com/<wbr>cgi-bin/mailman/listinfo/ur</a><br>
><br>
> ______________________________<wbr>_________________<br>
> Ur mailing list<br>
> <a href="mailto:Ur@impredicative.com">Ur@impredicative.com</a><br>
> <a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer" target="_blank">http://www.impredicative.com/<wbr>cgi-bin/mailman/listinfo/ur</a><br>
<br>
<br>
______________________________<wbr>_________________<br>
Ur mailing list<br>
<a href="mailto:Ur@impredicative.com">Ur@impredicative.com</a><br>
<a href="http://www.impredicative.com/cgi-bin/mailman/listinfo/ur" rel="noreferrer" target="_blank">http://www.impredicative.com/<wbr>cgi-bin/mailman/listinfo/ur</a><br>
</div></div></blockquote></div><br></div>