News for hackers. Stuff that matters.
Re:Verified Programming in F*: A Tutorial by globuous on Monday January 04, 2021 @03:08PM (#25637150)
Ocaml beginner here, didn't know you could restrict an Ocaml type to a string of a given length !! How would you go about that ?? Cheers :)
Re:Verified Programming in F*: A Tutorial by octachron on Tuesday January 05, 2021 @09:09AM (#25645629)
The easiest way is probably to define a private subtype of string (type small_string = private string) with smart constructors that enforces the restriction at runtime. This often means that creating such values may fail, but if you have a value of this type you are assured that the constraint on the size holds.