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: 4158 Reporter: acone Assigned to:@mshinwell Status: resolved (set by @mshinwell on 2016-12-07T17:40:12Z) Resolution: fixed Priority: normal Severity: feature Category: ~DO NOT USE (was: OCaml general)
Bug description
If I do this in ocaml, I get a warning:
type t = Foo of int | Bar of string
let list_of_all_foos = [Foo 1; Foo 2; Foo 3]
let _ =
List.map
(fun (Foo x) -> x)
list_of_all_foos
The warning, of course, is that the pattern match is incomplete. But it happens all the time that I know which constructor some value has, and an exhaustive match would need to have a catch-all case like
| _ -> failwith "shouldn't get here"
So I have three options, none of them satisfying:
Write the concise version above, and accept that I'll get a crapload of warnings.
Write the concise version above, and disable incomplete-match warnings. This mutilates type safety, which sucks.
Do the more pedantic, complete match, which makes code suprisingly unreadable (and in reality, no safer).
So I want to keep the warnings on in general, but disable them for lines where I know what I'm doing. I should be able to do this in code, something like this:
I realize this is a weird thing to ask for, as it mixes a hackerish compiler directive into the language. But I can't think of any other way to do this.
The text was updated successfully, but these errors were encountered:
Original bug ID: 4158
Reporter: acone
Assigned to: @mshinwell
Status: resolved (set by @mshinwell on 2016-12-07T17:40:12Z)
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
If I do this in ocaml, I get a warning:
type t = Foo of int | Bar of string
let list_of_all_foos = [Foo 1; Foo 2; Foo 3]
let _ =
List.map
(fun (Foo x) -> x)
list_of_all_foos
The warning, of course, is that the pattern match is incomplete. But it happens all the time that I know which constructor some value has, and an exhaustive match would need to have a catch-all case like
| _ -> failwith "shouldn't get here"
So I have three options, none of them satisfying:
So I want to keep the warnings on in general, but disable them for lines where I know what I'm doing. I should be able to do this in code, something like this:
let _ =
List.map
(fun (Foo x) -> x) {\nowarn P}
list_of_all_foos
or maybe for a whole block of code:
DisableWarning p;;
let _ =
List.map
(fun (Foo x) -> x) {\nowarn P}
list_of_all_foos
EnableWarning p;;
I realize this is a weird thing to ask for, as it mixes a hackerish compiler directive into the language. But I can't think of any other way to do this.
The text was updated successfully, but these errors were encountered: