Skip to content

Instantly share code, notes, and snippets.

@CoditCompany
Last active July 16, 2019 09:08
Show Gist options
  • Save CoditCompany/ab992a252bb520ea89e1a9a45f93e0db to your computer and use it in GitHub Desktop.
Save CoditCompany/ab992a252bb520ea89e1a9a45f93e0db to your computer and use it in GitHub Desktop.
open FPrimitive
let unknown = 10
let untrusted = Untrust unknown
type NonZeroInt =
private NonZeroInt of int with
static member create x =
Spec.def<int>
|> Spec.notEqual 0 "should not be zero"
|> Spec.createModel NonZeroInt x
let (trusted : Result<NonZeroInt, string list>) =
Untrust.getWithResult NonZeroInt.create untrusted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment