[mercury-users] Typeclass problem (bug, misunderstanding, oth er?)
Ralph Becket
rbeck at microsoft.com
Thu Aug 3 22:34:27 AEST 2000
> From: Fergus Henderson [mailto:fjh at cs.mu.OZ.AU]
>
> > :- func solve(CSP, Node) = CSP <= csp(CSP, Node).
> > :- mode solve(in, unused) = out is det.
> >
> > ...
> > main -->
> > { node_type(DummyNode) },
> > { Sol = solve(CSP, DummyNode) },
> > ...
> >
> > % this predicate just constrains the type of its
> > % argument to be `my_node'
> > :- pred node_type(my_node::unused) is det.
>
> > node_type(_).
> >
> > While this will work, it does seem to be something of a hack. I
> > wonder if there's some small addition we could make to the language
> > that would handle this more gracefully?
>
> One thing that would certainly help is syntax for explicit type
> qualification. Then you could write it as
>
> main -->
> { Sol = solve(CSP, _::my_node) },
> ...
Sure. Can we ditch : as a module separator sometime soon and use
: as a type qualifier instead? :: is just going to confuse the issue.
> without needing to define the `node_type' predicate.
> This one has been on the list for a while, and will
> probably actually happen sometime soon.
>
> > E.g.
> >
> > :- func solve(CSP) = CSP <= (some [Node] csp(CSP, Node)).
> >
> > solve(CSP0) = CSP :-
> > some [PoppedNodes, TopNode] (
> > ... code in which it would otherwise be
> > ... impossible to work out a type for
> > ... PoppedNodes and TopNode, but which
> > ... doesn't need to know
> > ).
>
> That won't work in general, since the choice of the node type
> could affect the semantics.
I know I'm being a bit slow, but could you give an example?
Cheers,
Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list