Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Validation<'e,'v>
- | Failure of 'e
- | Success of 'v
- let IsSuccess<'e, 'v> (v: Validation<'e, 'v>) =
- match v with
- | Success _ -> true
- | Failure _ -> false
- let IsFailure<'e, 'v> (v: Validation<'e, 'v>) =
- match v with
- | Success _ -> false
- | Failure _ -> true
- let MapFailure<'e, 'v, 'b> (v: Validation<'e, 'v>) (f: 'e -> 'b) =
- match v with
- | Success _ -> v
- | Failure x -> Failure(f x)
- let MapSuccess<'e, 'v, 'b> (v: Validation<'e, 'v>) (f: 'v -> 'b) =
- match v with
- | Success x -> Success(f x)
- | Failure _ -> v
- let Fold<'e, 'v, 'a> (v: Validation<'e, 'v>) (e: 'e -> 'a) (s: 'v -> 'a)
- match v with
- | Success x -> s x
- | Failure x -> e x
Add Comment
Please, Sign In to add comment