You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6904 Reporter:@zoggy Status: closed (set by @damiendoligez on 2016-04-15T16:46:02Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.1 Category: standard library
Bug description
Hello,
ifprintf and ikfprintf appears in Printf interface as:
val ifprintf : 'a -> ('b, 'a, unit) format -> 'b
val ikfprintf : (out_channel -> 'a) -> out_channel ->
('b, out_channel, unit, 'a) format4 -> 'b
But the types inferred from their implementation are more general:
cat > p.ml
open CamlinternalFormatBasics;;
open CamlinternalFormat;;
let ikfprintf k oc (Format (fmt, _)) =
make_printf (fun oc _ -> k oc) oc End_of_acc fmt
let ifprintf oc fmt = ikfprintf ignore oc fmt
^D
ocamlc -i p.ml
val ikfprintf :
('a -> 'b) ->
'a -> ('c, 'a, 'd, 'd, 'd, 'b) CamlinternalFormatBasics.format6 -> 'c
val ifprintf :
'a -> ('b, 'a, 'c, 'c, 'c, unit) CamlinternalFormatBasics.format6 -> 'b
Is there a reason to constraint these types ? ifprintf would be more useful with a more general type, for example in codes like the following:
let p fmt = Printf.ksprintf prerr_endline fmt ;;
let f b p fmt = if b then p fmt else ifprintf () fmt
let log fmt = f true p fmt
With the current types for i* functions, the code above has a type error on the third format argument.
The text was updated successfully, but these errors were encountered:
Original bug ID: 6904
Reporter: @zoggy
Status: closed (set by @damiendoligez on 2016-04-15T16:46:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.1
Category: standard library
Bug description
Hello,
ifprintf and ikfprintf appears in Printf interface as:
val ifprintf : 'a -> ('b, 'a, unit) format -> 'b
val ikfprintf : (out_channel -> 'a) -> out_channel ->
('b, out_channel, unit, 'a) format4 -> 'b
But the types inferred from their implementation are more general:
cat > p.ml
open CamlinternalFormatBasics;;
open CamlinternalFormat;;
let ikfprintf k oc (Format (fmt, _)) =
make_printf (fun oc _ -> k oc) oc End_of_acc fmt
let ifprintf oc fmt = ikfprintf ignore oc fmt
^D
ocamlc -i p.ml
val ikfprintf :
('a -> 'b) ->
'a -> ('c, 'a, 'd, 'd, 'd, 'b) CamlinternalFormatBasics.format6 -> 'c
val ifprintf :
'a -> ('b, 'a, 'c, 'c, 'c, unit) CamlinternalFormatBasics.format6 -> 'b
Is there a reason to constraint these types ? ifprintf would be more useful with a more general type, for example in codes like the following:
let p fmt = Printf.ksprintf prerr_endline fmt ;;
let f b p fmt = if b then p fmt else ifprintf () fmt
let log fmt = f true p fmt
With the current types for i* functions, the code above has a type error on the third format argument.
The text was updated successfully, but these errors were encountered: