[mercury-users] Restricted types with inst declarations? ELL type/inst usage?

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Wed Feb 22 09:32:04 AEDT 2006


Dear Ian, thank you for the inst question solution!  You also wrote:

>But why don't you just do:
>
>:- type bit
>	--->	one
>	;		zero.
>
>I think that would make your life simpler.

You are absolutely right on all counts.  So thank you for humouring me on this inst issue.  It's also a question of (*sigh*) semantics and conciseness.  1 and 0 are fairly strongly embedded into the mode of discourse, so reading something in the code like:

Rule0 = [111 - 0, 110 - 0, 101 - 0, 100 - 1, 011 - 1, 010 - 1, 001 - 1, 000 - 0]

is much easier for one to grasp* than

Rule1 = [[one, one, one] - zero, [zero, one, one] - zero, [one, zero, one] - zero, [zero, zero, one] - one,
            [one, one, zero] - one, [zero, one, zero] - one, [one, zero, zero] - one, [zero, zero, zero] - zero] +


and, having Rule0 be proved type-correct at compile-time is the benefit I'm looking for.

Sincerely,
Doug Auclair

* E.g. the Peano series has many advantages over int for counting (e.g. iterating a fixed number of times), but reading the digits '12' is much easier for most people than reading its equivalent Peano representation (I've used Peano numbers much larger than 12 for iteration, BTW; it makes reading the call in the debugger not-too-much-fun).

+ Note that the LSB is at the head of the triple, of course.

--------------------------------------------------------------------------
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