From: Pierrick Couderc <pierrickcouderc@gmail.com>
To: Yotam Barnoy <yotambarnoy@gmail.com>
Cc: Ocaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Problem extending the Standard library
Date: Wed, 27 Aug 2014 17:04:14 +0200 [thread overview]
Message-ID: <CA+gYG2tZ3QAd7psR9_ypoK_zWp=g9gAYipRrSSSewYiE9Y4d0Q@mail.gmail.com> (raw)
In-Reply-To: <CAN6ygO=CjGzH3TuWbH9LE2=yYeVErGwDLYZ0xe4Tr0z32ao6Yg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]
Actually, the type of "+'a t" is not exported in Map.S, therefore it cannot
be used directly, even when including the module (or I am mistaking the
include semantics).
Le 27 août 2014 16:54, "Yotam Barnoy" <yotambarnoy@gmail.com> a écrit :
> I've recently tried to extend the Map in the standard library with extra
> functionality. This is what I've tried doing:
>
> In a file my_map.ml:
>
> module type S =
> sig
> include Map.S
> val find_lt: key -> 'a t -> 'a
> val find_gt: key -> 'a t -> 'a
> end
>
> module Make(Ord: Map.OrderedType) = struct
> include Map.Make(Ord)
>
> let find_almost move_f x n =
> let rec loop lastval n =
> match n, lastval with
> | Empty, None -> raise Not_found
> | Empty, Some i -> i
> | Node(l, v, d, r, _) ->
> let c = Ord.compare x v in
> let lastval', next = move_f c lastval l d r in
> loop lastval' next
> in loop None n
>
> let move_lt c lastval l d r =
> if c <= 0 then lastval, l else Some d, r
>
> let move_gt c lastval l d r =
> if c < 0 then Some d, l else lastval, r
>
> let find_gt x n = find_almost move_gt x n
> let find_lt x n = find_almost move_lt x n
> end
>
> Can anyone tell me why the compiler complained about Empty being an
> unbound constructor when it's declared in Map.Make, which I include?
>
> Thanks
> Yotam
>
[-- Attachment #2: Type: text/html, Size: 2210 bytes --]
prev parent reply other threads:[~2014-08-27 15:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 14:52 Yotam Barnoy
2014-08-27 14:59 ` Leo White
2014-08-27 15:01 ` Yotam Barnoy
2014-08-27 15:04 ` Pierrick Couderc [this message]
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='CA+gYG2tZ3QAd7psR9_ypoK_zWp=g9gAYipRrSSSewYiE9Y4d0Q@mail.gmail.com' \
--to=pierrickcouderc@gmail.com \
--cc=caml-list@inria.fr \
--cc=yotambarnoy@gmail.com \
/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