[m-dev.] maybe_error type

Paul Bone paul at bone.id.au
Sun Apr 21 12:38:25 AEST 2013


On Sun, Apr 21, 2013 at 11:13:26AM +1000, Michael Day wrote:
> Hi Paul,
>
>> :- type maybe_error(E)
>>      --->     ok
>>      ;       error(E).
>
> This type is isomorphic to maybe(E), eg. maybe(error), which is shorter  
> and just as obvious, I think :)
>

I see what you mean, however I prefer a situation where the names of the
function symbols are meaningful.  Otherwise we might as well have the stupid
names of the Either monad from Haskell:

:- type either(L, R)
    --->    left(L)
    ;       right(R).

Which one represents an error (for my intended use?)  (Answer: it's the
'right' one but you don't know this unless you look inside the typeclass
instance for Monad Either l.  (Mercury syntax would be (monad(either(L))).

Good symbol/variable names are important.


-- 
Paul Bone
http://www.bone.id.au



More information about the developers mailing list