Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Loup Vaillant <loup.vaillant@g...>
Subject: Lost Polymorphism. Can we force the compiler not to?
Hello,

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

into

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

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

Thanks,

Loup Vaillant