[m-users.] Inst problem
Volker Wysk
post at volker-wysk.de
Sun Nov 2 04:54:09 AEDT 2025
Hi
Thinking again, I wonder why the final instantiatedness of Res in this line:
Res = iosupp.error(Err)
... is unique(error(ground) ; ok(bound(path(ground, ground)))) and not just
unique(error(ground)).
Volker
Am Samstag, dem 01.11.2025 um 11:45 +0100 schrieb Volker Wysk:
> Hi!
>
> I have this:
>
> ------------
> :- type iosupp.res(T)
> ---> ok(T)
> ; error(iosupp.error).
>
> :- inst iosupp.res(I)
> ---> ok(I)
> ; error(ground).
>
> :- type path ---> path(
> abs :: bool,
> comps :: list(string)
> ).
>
> :- inst abs_path == bound(path(bound(yes), ground)).
>
> :- pred absolute_path_p(path, iosupp.res(path), io, io).
> :- mode absolute_path_p(in, out(res(abs_path)), di, uo) is det.
>
> :- pred current_directory_p(
> iosupp.res(path)::out(iosupp.res(abs_path)),
> io::di, io::uo
> ) is det.
>
> absolute_path_p(Path, Res, !IO) :-
> (
> if Path ^ abs = yes
> then Res = iosupp.ok(Path)
> else dirsupp.current_directory_p(Res1, !IO),
> (
> Res1 = ok(Cwd),
> Res = ok(path(yes, Cwd ^ comps ++ Path ^ comps))
> ;
> Res1 = iosupp.error(Err),
> Res = iosupp.error(Err)
> )
> ).
> ------------
>
> And I get this error message from the compiler:
>
> iosupp.m:1065: In clause for `absolute_path_p(in,
> out(iosupp.res(iosupp.abs_path)), di, uo)':
> iosupp.m:1065: mode error: argument 2 had the wrong instantiatedness.
> iosupp.m:1065: Final instantiatedness of `Res' was
> iosupp.m:1065: unique(
> iosupp.m:1065: error(ground)
> iosupp.m:1065: ;
> iosupp.m:1065: ok(
> iosupp.m:1065: bound(
> iosupp.m:1065: path(ground, ground)
> iosupp.m:1065: )
> iosupp.m:1065: )
> iosupp.m:1065: ),
> iosupp.m:1065: expected final instantiatedness was
> iosupp.m:1065: named inst res(abs_path)
> iosupp.m:1065: which expands to
> iosupp.m:1065: bound(
> iosupp.m:1065: error(ground)
> iosupp.m:1065: ;
> iosupp.m:1065: ok(
> iosupp.m:1065: named inst abs_path
> iosupp.m:1065: which expands to
> iosupp.m:1065: bound(
> iosupp.m:1065: path(
> iosupp.m:1065: bound(
> iosupp.m:1065: yes
> iosupp.m:1065: ),
> iosupp.m:1065: ground
> iosupp.m:1065: )
> iosupp.m:1065: )
> iosupp.m:1065: )
> iosupp.m:1065: ).
>
>
> I think I understand the final instantiatedness of `Res', and that it
> doesn't match the mode line for absolute_path_p. But how *should* it be
> done?
>
> TIA,
> Volker
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
More information about the users
mailing list