[mercury-users] Bit-fields in Mercury
Michael Day
mikeday at bigpond.net.au
Tue Jul 11 08:56:20 AEST 2006
> This is more usable, but you are still left with the problem that it
> does not allow the use of (often sensible) defaults.
You could add defaults like this:
:- func opts = opt. % returns default options
f(..., (opts ^ network := disable) ^ parallax := reverse)
Of course, then you run into the clunky nested parentheses required by the
syntax for multiple field assignments.
Something that would be quite handy but perhaps beyond the scope of
Mercury is an assoc_list with an association between the value of the key
and the type of the associated value.
Currently the only way to get this kind of thing is like this:
:- type opt
---> opt1(int)
; opt2(string).
:- type opts == list(opt).
When sometimes you would like to separate option names and values:
:- type opt
---> opt1
; opt2.
:- func opt_type(opt) = type. % eek, functions returning types!
opt_type(opt1) = int.
opt_type(opt2) = string.
:- type opts == list(pair(Key : opt, opt_type(Key))).
Any chance Mercury will have dependent types in the distant future? :)
Michael
--
Print XML with Prince!
http://www.princexml.com
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at csse.unimelb.edu.au
administrative address: owner-mercury-users at csse.unimelb.edu.au
unsubscribe: Address: mercury-users-request at csse.unimelb.edu.au Message: unsubscribe
subscribe: Address: mercury-users-request at csse.unimelb.edu.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list