Version française
Home     About     Download     Resources     Contact us    
Browse thread
function specialization
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Vsevolod Fedorov <sevaAtWork@m...>
Subject: function specialization
Hello!

I have code like following:
----

type 'a wrap = ('a -> unit) -> 'a -> unit

let wrap fn arg =
  fn arg

let fn1 (v: int)    = ()
let fn2 (v: string) = ()

let use (wrap: 'a wrap) =
  wrap fn1 1;
  wrap fn2 ""
  (*   ^^^ This expression has type string -> unit but is here used with
type int -> unit *)

------
and get this error from compiler.
Is there any way to use 'wrap' function for both cases: fn1 and fn2?
Or is there some 'standard' workarounds/solutions for this problem exists?

Thanks
Seva