Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Shouldn't we be allowed to assign anything to `unknown`?

$
0
0

I have have a BSON parser that can fail when an attempt is made to parse a leaf into an expected structure. let’s say the BSON parse expects an int at a leaf, but it sees something else (e.g., a string):

exception InvalidValue(unknown)

this is a case where i want to be able to just throw(InvalidValue(whateverValueThereWas)) without having to sprinkle Obj.magic. that lets the caller inspect the value, but we don’t know (or care) what it is when we throw beyond that it wasn’t what we wanted. unknown is enough for the caller to be able to carefully inspect/log whatever it was


Viewing all articles
Browse latest Browse all 2592

Trending Articles