caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jeremy Yallop <yallop@gmail.com>
To: Peter Frey <pjfrey@sympatico.ca>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Packing/Unpacking modules
Date: Sat, 21 Sep 2013 01:17:44 +0100	[thread overview]
Message-ID: <CAAxsn=EQR8og6Hr1TXj4CV=NnxCHA0a_o_EYf20stjHVpFv68Q@mail.gmail.com> (raw)
In-Reply-To: <BLU0-SMTP27EBB1458E2D6322877AD4A3220@phx.gbl>

On 21 September 2013 00:22, Peter Frey <pjfrey@sympatico.ca> wrote:
> I am showing my code (which does not work) first; the rest follows:
>
> let q = let module M = (val s2:Stream with type a = char) in
>                   (module  struct
>                    include (val s2: Stream  with type a = char)
>                    let stream = (M.tail (M.stream))
>                    end : Stream with type a = char )

The root problem here is that there are two types in the Stream
signature, of which one (a) is exposed and one (t) is opaque.  Each
unpacking of s2 gives you a new instance of t which is incompatible
with the instances that come from other unpackings.

The solution is to unpack s2 only once:

 let q = let module M = (val s2:Stream with type a = char) in
                   (module  struct
                    include M
                    let stream = (M.tail (M.stream))
                    end : Stream with type a = char )

  reply	other threads:[~2013-09-21  0:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20 23:22 Peter Frey
2013-09-21  0:17 ` Jeremy Yallop [this message]
2013-10-14 23:11 Peter Frey
2013-10-15 16:54 ` Drup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAxsn=EQR8og6Hr1TXj4CV=NnxCHA0a_o_EYf20stjHVpFv68Q@mail.gmail.com' \
    --to=yallop@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=pjfrey@sympatico.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).