[m-users.] is there a easy way to wrap Erlang's improper_list/2 and something similar?
Xiaofeng Yang
n.akr.akiiya at gmail.com
Fri Dec 27 00:31:13 AEDT 2013
hi, all
I'm new to Mercury and trying to use it as a language on Erlang VM with
strict and obligatory static checker. I've tried to wrap the basic list
types in Erlang but failed. The following is what I've done. I know the
definitions are wrong. But I don't know how to wrap the improper lists in
an easy, expressive, efficient way so that I can use them like how I use
them in Erlang. Please help me or point me how to solve this problem.
Thanks.
In Mercury:
%% nonempty_improper_list()
:- type erlang_nonempty_improper_list(Contents, Termination) --->
[Contents | Termination]
; [Contents | erlang_nonempty_improper_list(Contents, Termination)].
%% wrap improper_list()
:- type erlang_improper_list(Contents, Termination) --->
erlang_improper_list( Termination ) % can't use
Termination directly
; erlang_improper_list( erlang_nonempty_improper_list(Contents,
Termination) ).
But I can write this in Erlang:
-type erlang_nonempty_improper_list(Contents, Termination) ::
[Contents | Termination]
| [Contents | erlang_nonempty_improper_list(Contents, Termination)].
%% improper_list() wrapping
-type erlang_improper_list(Contents, Termination) ::
Termination
| erlang_nonempty_improper_list(Contents, Termination).
Best regards,
Xiaofeng Yang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20131226/69feef35/attachment.html>
More information about the users
mailing list