caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Problem with universal functions in a module
@ 2015-01-07 13:50 Goswin von Brederlow
  2015-01-07 15:30 ` Goswin von Brederlow
  2015-01-07 17:26 ` Jeremy Yallop
  0 siblings, 2 replies; 11+ messages in thread
From: Goswin von Brederlow @ 2015-01-07 13:50 UTC (permalink / raw)
  To: caml users

Hi,

I have a functor that boxes a GADT type into an universal container.
But then the problem is how to get the type back out again.
Specifically I want to pass the data to a polymorphic function that
doesn't care what type it gets since it will pattern match the GADT to
determine the right type.

But, because the argument is a GADT, ocaml complains after unboxing
the type would escape its scope (see call_unboxed below). One can only
call an universal function with the unboxed data and only records (and
objects) can have universal functions.

Problem is that I would like to keep the implementation of the helper
record abstract and only provide a constructor (helper function
below). But the constructor needs an universal function and function
argument are only polymorphic (less general).

A) why is a polymorphic function less general here?

The print function is good enough for List.iter below or for
constructing a helper but not indirectly via "M.helper fn".

Why are function arguments less general than their original function?

B) is there some way around this I'm not seeing?

MfG
	Goswin

--


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

end of thread, other threads:[~2015-01-12 14:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-07 13:50 [Caml-list] Problem with universal functions in a module Goswin von Brederlow
2015-01-07 15:30 ` Goswin von Brederlow
2015-01-07 17:26 ` Jeremy Yallop
2015-01-08  9:45   ` Ben Millwood
2015-01-08 15:21     ` Goswin von Brederlow
2015-01-08 16:25       ` Leo White
2015-01-09  1:02         ` Jacques Garrigue
2015-01-10 18:02           ` Goswin von Brederlow
2015-01-10 17:52         ` Goswin von Brederlow
2015-01-10 18:49           ` Leo White
2015-01-12 14:28             ` Goswin von Brederlow

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