caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Kakadu <kakadu.hafanana@gmail.com>
To: "Gawlitza, Thomas" <thomas.gawlitza@sap.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Implicit question about searching for implicit module definition in the functor argument.
Date: Wed, 3 Aug 2016 23:53:29 +0300	[thread overview]
Message-ID: <CAGmVoG3MvvgR5U3uUQNzVcRtUAZpZOnR8sWZf56U7DF_fuWsLQ@mail.gmail.com> (raw)
In-Reply-To: <032632D8-A18E-4F9D-846B-F18860440120@sap.com>

Oh, thanks. I did know that it is something obvious. Maybe we will
need a warnings for this......

On Wed, Aug 3, 2016 at 8:18 AM, Gawlitza, Thomas
<thomas.gawlitza@sap.com> wrote:
> Hi!
>
>
>
> Your question inspired me to have a look at the modular implicits. I really
> like them. It seems that the argument of the implicit functor Show_logic
> also needs to be implicit, i.e., in curly braces. At least this worked for
> me.
>
>
>
> Thomas
>
>
>
> module type SHOW = sig
>
>     type t
>
>     val show : t -> string
>
> end
>
>
>
> let show {S : SHOW} x = S.show x;;
>
>
>
> implicit module Show_int : (SHOW with type t = int) = struct
>
>     type t = int
>
>     let show = string_of_int
>
> end
>
>
>
> module type CORE = sig
>
>   type 'a logic
>
>
>
>   implicit module Show_logic {X: SHOW} : (SHOW with type t = X.t logic)
>
> end
>
>
>
> module Make(MK: CORE) = struct
>
>   open MK
>
>   (* open implicit MK (* doesn't help *) *)
>
>
>
>   let foo (x: int logic) =
>
>     let s = show x in (* Error: No instance found for implicit S. *)
>
>     s
>
> end
>
>
>
>
>
> ---
>
>
>
> Dr. rer. nat. Thomas Martin Gawlitza, Diplom-Informatiker
>
> Development Architect
>
> Technology Office
>
> office location: Potsdam (DE), POT04, A2.01, SAP Innovation Center,
> Konrad-Zuse-Ring 10, 14469 Potsdam
>
> email: Thomas.Gawlitza@sap.com
>
> phone: +49 331 9799 5408
>
> mobile: +49 151 168 10 726
>
>
>
> From: <caml-list-request@inria.fr> on behalf of Kakadu
> <kakadu.hafanana@gmail.com>
> Reply-To: Kakadu <kakadu.hafanana@gmail.com>
> Date: Wednesday 3 August 2016 at 01:17
> To: Caml List <caml-list@inria.fr>
> Subject: [Caml-list] Implicit question about searching for implicit module
> definition in the functor argument.
>
>
>
> Hey, hackers.
>
>
>
> I'm missing something obvious. Any fresh eyes around?
>
>
>
> module type SHOW = sig
>
>     type t
>
>     val show : t -> string
>
> end
>
>
>
> let show {S : SHOW} x = S.show x;;
>
>
>
> implicit module Show_int : (SHOW with type t = int) = struct
>
>     type t = int
>
>     let show = string_of_int
>
> end
>
>
>
> module type CORE = sig
>
>   type 'a logic
>
>
>
>   implicit module Show_logic(X: SHOW) : (SHOW with type t = X.t logic)
>
> end
>
>
>
> module Make(MK: CORE) = struct
>
>   open MK
>
>   open implicit MK (* doesn't help *)
>
>
>
>   let foo (x: int logic) =
>
>     let s = show x in (* Error: No instance found for implicit S. *)
>
>     s
>
> end
>
>
>
>
>
> Kind regards,
>
> Kakadu
>
>
>
> --
>
> Caml-list mailing list.  Subscription management and archives:
>
> https://sympa.inria.fr/sympa/arc/caml-list
>
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

      reply	other threads:[~2016-08-03 20:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 23:17 Kakadu
2016-08-03  5:18 ` Gawlitza, Thomas
2016-08-03 20:53   ` Kakadu [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=CAGmVoG3MvvgR5U3uUQNzVcRtUAZpZOnR8sWZf56U7DF_fuWsLQ@mail.gmail.com \
    --to=kakadu.hafanana@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=thomas.gawlitza@sap.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;
as well as URLs for NNTP newsgroup(s).