[m-dev.] Mode syntax suggestion (possibly gross)

Ralph Becket rbeck at microsoft.com
Wed Sep 27 19:37:31 AEDT 2000


>From Tyson Dowd on 27/09/2000 01:43:29
> 
> This is not a terrible idea.
> 
> It's not actually too different to Fergus's sub-typing proposal from
> many months ago.

There seem to be two ideas here:
1. in/out modes are parameterised appropriately if the argument type
has an inst of the same name; and
2. subtypes automatically cause appropriate insts to be generated by 
default.

These are both handy things.

> [...]
> 
> It would be cleaner if you could just write
> 
> :- subtype ralphtype ---> foo ; bar ; baz.
> 
> and remove the need for a parent type.  This `:- subtype' is badly
> named, it's really just a mechanism for defining a type and a mode
> simultaneously.  It would be very nice if you could write
> 
> :- subtype mytype ---> foo(pred(int::in) is semidet) ; bar ; baz.
> 
> Or something similarly easy to write.

How about having the compiler automatically generate insts of the
same name for *all* non-simple types unless the program already
supplies one?  This may require including mode information in
type declarations as above.

Then I could write

:- type test_pred(T) == ( pred(T::in) is semidet ).
:- type filter_fn(T) == ( func(test_pred(T), list(T)) = list(T) ).

and the compiler would generate the following for me

:- inst test_pred == ( pred(in) is semidet ).
:- inst filter_fn == ( func(in(test_pred), in) = out is det ).

> So I'd like to reintroduce the subtyping proposal for discussion.

Agreed.

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list