[mercury-users] term_io__read_term fills detstack
Ralph Becket
rafe at cs.mu.OZ.AU
Sat Jan 28 10:46:16 AEDT 2006
Peter Ross, Saturday, 28 January 2006:
> On Fri, Jan 27, 2006 at 11:48:27AM +1100, Ralph Becket wrote:
> > Hi Ondrej,
> >
> > at the moment I don't have time to look into this one, but I have
> > experienced the same problem in the past. A short-term solution
> > may be to break up your data into a collection of smaller units. For
> > instance, if your top-level structure is a large list, io.write each
> > member separately.
> >
> We have the same problem here, and that is what I do.
>
> For example I write a map as
> element(K, V).
> element(KA, VA).
> end_map.
Which you can best do using map.foldl:
:- pred write_map(map(T1, T2)::in, io::di, io::uo) is det.
write_map(Map, !IO) :-
map.foldl(write_element, Map, !IO),
io.write_string("end_map.\n", !IO)
:- pred write_element(T1::in, T2::in, io::di, io::uo) is det.
write_element(K, V, !IO) :-
io.format("element(%s, %s).\n", [s(string(K)), s(string(V))], !IO).
-- 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