[m-dev.] generic result types
Peter Ross
pdross at gmail.com
Wed Feb 18 14:44:36 AEDT 2009
On Wed, Feb 18, 2009 at 2:39 PM, Julien Fischer
<juliensf at csse.unimelb.edu.au> wrote:
>
> On Wed, 18 Feb 2009, Peter Ross wrote:
>
>> On Wed, Feb 18, 2009 at 2:12 PM, Julien Fischer
>> <juliensf at csse.unimelb.edu.au> wrote:
>>>
>>> On Wed, 18 Feb 2009, Peter Ross wrote:
>>>
>>>> On Wed, Feb 18, 2009 at 1:47 PM, Julien Fischer
>>>> <juliensf at csse.unimelb.edu.au> wrote:
>>>>>
>>>>> On Wed, 18 Feb 2009, Peter Ross wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Do people think it would be useful to add the following generic types
>>>>>> to the standard library?
>>>>>>
>>>>>> :- type result(T, E)
>>>>>> ---> ok(T)
>>>>>> ; error(E)
>>>>>> .
>>>>>>
>>>>>> :- type partial_result(T, E) == partial_result(T, T, E).
>>>>>>
>>>>>> :- type partial_result(T, P, E)
>>>>>> ---> ok(T)
>>>>>> ; error(P, E)
>>>>>>
>>>>>> :- type result(E)
>>>>>> ---> ok
>>>>>> ; error(E)
>>>>>> .
>>>>>>
>>>>>> Then the various io and stream types could be redefined in terms of
>>>>>> these
>>>>>> types.
>>>>>>
>>>>>> I ask because we have written a lot of code at MC which should use
>>>>>> these
>>>>>> generic
>>>>>> result types, so I was going to add this to our library but ian
>>>>>> suggested we should
>>>>>> see first if it goes better in the mercury standard library.
>>>>>
>>>>> In which module would they be defined?
>>>>>
>>>> I was thinking result.m, just like maybe.m and cohorts.
>>>
>>> Are you proposing that there be generic result types for all the types
>>> duplicated in the io and stream modules? The above doesn't cover the
>>> case where they have an eof functor.
>>>
>> No only the types with two functors, ok and error.
>
> In which case the names you have chosen above clash with the 3-functor
> versions in the io and stream modules.
>
I'm more interested in whether or not this is a sufficently useful
module for standard library inclusion.
We can argue about functor and type names later.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions: mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the developers
mailing list