2019-04-21 04:25 AEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000323mercuryBugpublic2014-04-03 01:21
Reporterbwitkowski 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformLinuxOSDebianOS Versionwheezy (7.0)
Product Version 
Target VersionFixed in Version 
Summary0000323: Matching on adts makes and instantiation state subtyping is impossible.
DescriptionMatching on a subtype doesn't carry the information about the inst of the subtype which makes using pattern matching and instantiation state subtyping impossible to use. See the attached file for details.
Steps To Reproduce$ mmc --version
Mercury Compiler, version 13.05.2, configured for x86_64-unknown-linux-gnu
Copyright (C) 1993-2013 The University of Melbourne

$ mmc -E subtyping.m
subtyping.m:019: In clause for `use_everything(in, out)':
subtyping.m:019: mode error in conjunction. The next 2 error messages
subtyping.m:019: indicate possible causes of this error.
subtyping.m:019: In clause for `use_everything(in, out)':
subtyping.m:019: in argument 1 of call to predicate `subtyping.use_bar'/2:
subtyping.m:019: mode error: variable `Bar' has instantiatedness `ground',
subtyping.m:019: expected instantiatedness was
subtyping.m:019: `bound(subtyping.bar(ground))'.
subtyping.m:019: In clause for `use_everything(in, out)':
subtyping.m:019: in argument 2 of clause head:
subtyping.m:019: mode error in unification of `HeadVar__2' and `String'.
subtyping.m:019: Variable `HeadVar__2' has instantiatedness `free',
subtyping.m:019: variable `String' has instantiatedness `free'.
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0000656

juliensf (administrator)

You can work around the above problem by rewriting the predicate use_everything/2 to use a single clause, for example:

   use_everything(Foo, String) :-
       (
           Foo = bar(_),
           use_bar(Foo, String)
       ;
           Foo = baz(_),
           String = "baz"
       ).

~0000657

bwitkowski (reporter)

Last edited: 2014-04-03 01:21

View 2 revisions

Interesting, thank you very much! Paul Bone on #mercury irc also suggested deconstructing and reconstructing bar like:

use_everything(bar(X), String) :- use_bar(bar(X), String).

which works too. Still I think that, ideally, this should also work in pattern matching in multiple clauses(?).

+Notes

-Issue History
Date Modified Username Field Change
2014-04-02 22:53 bwitkowski New Issue
2014-04-02 22:53 bwitkowski File Added: subtyping.m
2014-04-03 01:09 juliensf Note Added: 0000656
2014-04-03 01:17 bwitkowski Note Added: 0000657
2014-04-03 01:21 bwitkowski Note Edited: 0000657 View Revisions
+Issue History