[mercury-users] More on higher order functions

Tyson Dowd trd at cs.mu.OZ.AU
Mon Feb 7 18:33:26 AEDT 2000

On 03-Feb-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> 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 =
> 	stateT((
> 		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' ''?

I think the general premise is OK, but I'm not entirely sure where
this idea applies in the code above.  Do you mean that the compiler
doesn't assume the default func mode when you pass a data term which
contains a field which is a higher order func?

I think this is a bug, I suspect it can be fixed.

       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
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