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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] class and printf
From: Anastasia Gornostaeva <ermine@ermine.pp.ru>

> What I need to drink to compile it?
> 
> class foo ch =
> object
>  method myprintf = Printf.fprintf ch
> end
> 
> The compiler says 
> The method myprintf has type ('a, out_channel, unit) format -> 'a where 'a
> is unbound

Since I assume that you want to be able to use differently typed
formats with the same object,

class foo ch = object
  method myprintf : 'a. ('a, out_channel, unit) format -> 'a =
    Printf.fprintf ch
end

Jacques Garrigue