Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Evaluation Order
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-06-13 (09:56)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] Evaluation Order
Dave Mason wrote:

> I think the answer is that the ``effect''ness isn't simply captured in
> the type.  So the current type-inference engine would not be able to
> do it.  It would require a bit of ad-hocery in the compiler.  That
> doesn't mean that it's unsound, just that the existing compiler
> mechanisms couldn't do it.

	I think you probably _have_ to capture it in the type.
Consider a new type

	'a => 'b

where '=>' means 'function with side effects'. Now consider
the following two term constructors:


The type-checking rules are then clear:

	fn1: 'a->'b, arg1:'a, Apply(fn1,arg1):'b
	fn2: 'a=>'b, arg2:'a, name: 'b


	'a->'b is a subtype of 'a=>'b'

In Felix it would be easy to verify correct usage,
but I'm not sure it is possible to verify correct
specification. In Ocaml, it may be harder, since
one can use a function before declaration in a 'let rec',
and it may be too late when spotting the type annotation
to report a wrong usage.

[OTOH, if the Ocaml compiler scanned 'let recs' for type
annotations before examining bodies, it might improve
error reporting in other circumstances??]

John (Max) Skaller,
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper
download Interscript
Bug reports:  FAQ:
To unsubscribe, mail  Archives: