Parametric polymorphic values in OCaml's type system can be thought of as "choose an assignment of the variables in this type, and you can use this value with that monomorphic type". But there's no monomorphic type that lets 'helper' do the right thing, so you actually need something more expressive than ordinary polymorphic types.

In Haskell there's higher-rank polymorphism, which in this case would look something like 'helper :: (forall a. T a -> b) -> Helper b', so that you could only pass sufficiently-polymorphic arguments to helper. However, as Jeremy said, there's a lot of added complexity involved.

On 7 January 2015 at 17:26, Jeremy Yallop <yallop@gmail.com> wrote:
On 7 January 2015 at 13:50, Goswin von Brederlow <goswin-v-b@web.de> wrote:
> Why are function arguments less general than their original function?

Polymorphic arguments complicate type checking and make type inference
impossible, so OCaml doesn't allow them.

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

I don't think that there's any way of passing polymorphic arguments
that works out simpler than using a record.

Of course, in your simple example code it's possible to eliminate the
GADT altogether, which would also eliminate the need for polymorphic
arguments.  Perhaps GADTs play a more essential role in your real
code, though.

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