[mercury-users] parsing a term of a dicriminated union type...

andrea bini andrea.bini at studenti.unimi.it
Wed Oct 3 02:55:38 AEST 2007

Hi all,
I need to parse a term of a discriminated union type that has an existentially quantified type typeclass constrained inside its unique constructor. I get an "Uncaught Mercury exception" executing this simple code:

:- module try_to_parse.

:- interface.
:- import_module io.

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

:- implementation.
:- import_module int, list, string.
:- import_module term, term_io, parser.

:- type t1 ---> some [T] c1(T) => class1(T).

:- typeclass class1(T) where [].
:- instance class1(int) where [].

:- pred p1(string::in, t1::out) is semidet.
p1(Str,T1) :- 
	RTerm = term(_, Term),
	term.try_term_to_type(Term, Result),
	Result = ok(T1).

main(!IO) :-
	Str = "c1(5).",
	(	if	p1(Str,T1)
		then io.print(T1,!IO)
		else io.write_string("No",!IO)

On executing I get this error:

Uncaught Mercury exception:
Software Error: ground_pseudo_type_desc_to_type_desc_det: not ground
Stack dump not available in this grade.

My fault or compiler/libraries fault?
I cannot understand what's wrong with my code...
How can I solve this?

I'm sorry if the topic was already discussed.


Andrea Bini
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list