caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Implicit question about searching for implicit module definition in the functor argument.
@ 2016-08-02 23:17 Kakadu
  2016-08-03  5:18 ` Gawlitza, Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Kakadu @ 2016-08-02 23:17 UTC (permalink / raw)
  To: Caml List

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Implicit question about searching for implicit module definition in the functor argument.
  2016-08-02 23:17 [Caml-list] Implicit question about searching for implicit module definition in the functor argument Kakadu
@ 2016-08-03  5:18 ` Gawlitza, Thomas
  2016-08-03 20:53   ` Kakadu
  0 siblings, 1 reply; 3+ messages in thread
From: Gawlitza, Thomas @ 2016-08-03  5:18 UTC (permalink / raw)
  To: Kakadu, Caml List

[-- Attachment #1: Type: text/plain, Size: 2293 bytes --]

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


[-- Attachment #2: Type: text/html, Size: 12094 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Implicit question about searching for implicit module definition in the functor argument.
  2016-08-03  5:18 ` Gawlitza, Thomas
@ 2016-08-03 20:53   ` Kakadu
  0 siblings, 0 replies; 3+ messages in thread
From: Kakadu @ 2016-08-03 20:53 UTC (permalink / raw)
  To: Gawlitza, Thomas; +Cc: Caml List

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
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-03 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-02 23:17 [Caml-list] Implicit question about searching for implicit module definition in the functor argument Kakadu
2016-08-03  5:18 ` Gawlitza, Thomas
2016-08-03 20:53   ` Kakadu

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).