caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Lost Polymorphism. Can we force the compiler not to?
@ 2007-12-24 15:59 Loup Vaillant
  2007-12-24 17:33 ` [Caml-list] " Pierre-Evariste Dagand
  0 siblings, 1 reply; 2+ messages in thread
From: Loup Vaillant @ 2007-12-24 15:59 UTC (permalink / raw)
  To: Caml mailing list

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


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

* Re: [Caml-list] Lost Polymorphism. Can we force the compiler not to?
  2007-12-24 15:59 Lost Polymorphism. Can we force the compiler not to? Loup Vaillant
@ 2007-12-24 17:33 ` Pierre-Evariste Dagand
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre-Evariste Dagand @ 2007-12-24 17:33 UTC (permalink / raw)
  To: Loup Vaillant, caml-list

Hi,

You might find this thread interesting :

[http://camltest.inria.fr/pub/ml-archives/caml-list/2003/10/b524697dd6429ef4b3d37491d400e8ff.fr.html]

In a nutshell, it is a FAQ :

"A function obtained through partial application is not polymorphic enough"

at [http://caml.inria.fr/resources/doc/faq/core.en.html].

The proposed solution is eta-expanding. It's what I do when I use my
Arrow combinators.

But I'm not either a type-checker or OCaml guru so their might be a
better solution. That I would be pleased to learn.

HTH,

-- 
Pierre-Evariste Dagand


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

end of thread, other threads:[~2007-12-24 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-24 15:59 Lost Polymorphism. Can we force the compiler not to? Loup Vaillant
2007-12-24 17:33 ` [Caml-list] " Pierre-Evariste Dagand

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