[erlang-questions] -protocol declartion idea, worth an EEP?

Richard A. O'Keefe ok@REDACTED
Tue Jun 6 00:42:49 CEST 2017

> On 6/06/2017, at 5:35 AM, Michael Truog <mjtruog@REDACTED> wrote:
> I believe it is more important to be able to mark functions impure or pure 

Actually that was something I was working on with SERC just before
funs were introduced into Erlang and completely derailed my ideas.

One issue is that 'pure' or 'impure' is far too coarse a classification.
For example, we might want to distinguish
 - termination
   - terminates in bounded time
   - terminates in finite time
   - not known to terminate
 - process dictionary
   - no dependency on process dictionary
   - reads specified parts of process dictionary
   - writes (and maybe reads) specified parts of process dictionary
 - input/output
   - does no I/O
   - reads
   - writes
   - opens and closes
 - inter-process communication
   - does it create processes or not
   - does it send messages or not
   - does it receive messages (which?) or not
And that isn't meant to be a complete list.

Another issue is higher-order functions.

map(F, [X|Xs]) -> [F(X) | map(F, Xs)];
map(_, [])     -> [].

is itself pure, but if F has any effects, map(F, ...) may
(but need not) have those effects too.  So we need a type
map/2 :: (A -> B effect E, list(A)) -> list(B) effect E+finite.

Since then, Erlang has gone through at least three different
type systems (the Wadler one, the Armstrong one, and the one
it now has), and I never did get around to trying to adapt a
proper "effect" system to the Dialyzer approach.

More information about the erlang-questions mailing list