[mercury-users] More on higher order functions

Ralph Becket rbeck at microsoft.com
Fri Feb 4 03:00:40 AEDT 2000

I'm experimenting with programming in the monadic
style in Mercury and I've discovered a mildly painful
hole in the default func mode assumption.

If I have

:- type stateT(S, A) ---> stateT(func(S) = pair(A, S)).

:- func stateT(S, A) `thenST` (func(A) = stateT(S, B)) = stateT(S, B).

and write

stateT(ST) `thenST` F =
		func(S0) = FX(S) :-
			(X-S) = ST(S0),
			stateT(FX) = F(X)

then I get all sorts of whinges from the compiler about
modes, the problem being that the default func mode
assumption doesn't extend to `wrapped up' functions.
My question is, would it be possible to extend the mode
assumption to ``wherever I know there's a function, and
no mode declarations have been made to the contrary, I
will assume that function has mode
`(in, ...) = out is det' ''?

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