[zeromq-dev] Introducing Caravan: Simple, Faithful ZMQ-Bindings for Objective Caml

Pedro Borges pdhb.lists at gmail.com
Mon Apr 4 03:37:59 CEST 2011


On Mon, Apr 4, 2011 at 2:09 AM, Guillaume Yziquel
<guillaume.yziquel at citycable.ch> wrote:
> It's nice to have phantom types to have usage of sockets type checked.
> But if it prevents them from being bundled in an array for zmq_poll(),
> there has to be a workaround.
>
> One would be to have them carrying their types around at runtime. Not so
> lean. Another would be to have a declaration like
>
>        type 'a typed_socket = private untyped_socket
>
> allowing you to subtype a typed socket into an untyped_socket, but not
> the other way round as that would not be safe.

Currently ocaml-zmq declares the socket type parameter covariant and
every type parameter private of "generic" so you can cast any socket
like this:

    let a : pub Socket.t = ...
    let b = ( a :> generic Socket.t)


> --
>     Guillaume Yziquel
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>



More information about the zeromq-dev mailing list