Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Lost Polymorphism. Can we force the compiler not to?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-12-24 (15:59)
From: Loup Vaillant <loup.vaillant@g...>
Subject: Lost Polymorphism. Can we force the compiler not to?

I am currently writing a FRP-like system, stealing the ides previously
exposed in this list (I have chosen the CPS style). The issue is a
loss of polymorphism when I write a signal function in terms of
other's. Namely:

(* type ('a, 'b) sf = SF of ('a -> 'a * ('a, 'b) sf) *)
(* integral : ('a, float) sf ('a float) sf *)
(* lift : ('a -> 'b) -> ('a, 'b) sf *)

let time = integral (lift (fun x -> 1.0))
(* time : ('_a float) sf *)

I think it this loss is due to a partial application. Usually, transforming

let foo arg = bar baz


let foo arg x = bar baz x

works around this problem. However, I can't do this in the case of
signal functions, unless I accept to break the abstractness of my

Is there a neater workaround, or a compiler option to tweak the type inference?


Loup Vaillant