caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: caml-list@inria.fr
Subject: [Caml-list] Error: In this definition, a type variable cannot be deduced from the type parameters.
Date: Sun, 6 Mar 2016 02:33:32 +0100	[thread overview]
Message-ID: <20160306013332.GA27650@frosties> (raw)

Hi,

if I use the type aliases in the commented out lines then I get:

    Error: In this definition, a type variable cannot be deduced
    from the type parameters.

To me the types sure do look alike and nothing is private or hidden my
a signature. So what am I missing?

MfG
	Goswin
-------------------------------------------------------------------------
module Proxy = struct
  type +'a t
end

module QObject = struct
  type +'a qObject'
  type +'a t = 'a qObject' Proxy.t

  class ['a] qObject proxy = object
    constraint 'a = 'b qObject' as 'a
    method proxy : 'a Proxy.t = proxy
  end
end

module QWidget = struct
  type +'a qWidget'
  type +'a t = 'a qWidget' QObject.t

  external add : 'a qWidget' QObject.qObject' Proxy.t -> 'b qWidget' QObject.qObject' Proxy.t -> unit = "add"
  (*
    external add : 'a t -> 'b qWidget' QObject.t -> unit = "add"
  *)
  class ['a] qWidget proxy = object
    constraint 'a = 'b qWidget' QObject.qObject' as 'a
    inherit ['a] QObject.qObject proxy
    method add : 'c 'd . ('d qWidget' QObject.qObject' #QObject.qObject as 'c) -> unit = fun w -> add proxy w#proxy
  end
end

module QButton = struct
  type +'a qButton'
  type +'a t = 'a qButton' QWidget.t

  external set : 'a qButton' QWidget.qWidget' QObject.qObject' Proxy.t -> 'b QWidget.qWidget' QObject.qObject' Proxy.t -> unit = "set"
  (*
    external set : 'a t -> 'b QWidget.t -> unit = "set"
  *)
  class ['a] qButton proxy = object
    constraint 'a = 'b qButton' QWidget.qWidget' QObject.qObject' as 'a
    inherit ['a] QWidget.qWidget proxy
    method set : 'c 'd . ('c QWidget.qWidget' QObject.qObject' #QWidget.qWidget as 'd) -> unit = fun w -> set proxy w#proxy
    method text = "button"
  end
end

let qObject_proxy : unit QObject.t = Obj.magic 0
let qWidget_proxy : unit QWidget.t = Obj.magic 0
let qButton_proxy : unit QButton.t = Obj.magic 0
let qObject = new QObject.qObject qObject_proxy
let qWidget = new QWidget.qWidget qWidget_proxy
let qButton = new QButton.qButton qButton_proxy
let () = qWidget#add qWidget
let () = qWidget#add qButton
let () = qButton#set qWidget
let () = qButton#set qButton
let () = qButton#add qWidget
let () = qButton#add qButton

             reply	other threads:[~2016-03-06  1:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-06  1:33 Goswin von Brederlow [this message]
2016-03-06 15:30 ` Jacques Garrigue
  -- strict thread matches above, loose matches on Subject: below --
2014-02-22 17:54 Goswin von Brederlow
2014-02-23  9:18 ` Jacques Garrigue

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=20160306013332.GA27650@frosties \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    /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).