Guest User

Untitled

a guest
Nov 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. type Validation<'e,'v>
  2. | Failure of 'e
  3. | Success of 'v
  4.  
  5. let IsSuccess<'e, 'v> (v: Validation<'e, 'v>) =
  6. match v with
  7. | Success _ -> true
  8. | Failure _ -> false
  9.  
  10. let IsFailure<'e, 'v> (v: Validation<'e, 'v>) =
  11. match v with
  12. | Success _ -> false
  13. | Failure _ -> true
  14.  
  15. let MapFailure<'e, 'v, 'b> (v: Validation<'e, 'v>) (f: 'e -> 'b) =
  16. match v with
  17. | Success _ -> v
  18. | Failure x -> Failure(f x)
  19.  
  20. let MapSuccess<'e, 'v, 'b> (v: Validation<'e, 'v>) (f: 'v -> 'b) =
  21. match v with
  22. | Success x -> Success(f x)
  23. | Failure _ -> v
  24.  
  25. let Fold<'e, 'v, 'a> (v: Validation<'e, 'v>) (e: 'e -> 'a) (s: 'v -> 'a)
  26. match v with
  27. | Success x -> s x
  28. | Failure x -> e x
Add Comment
Please, Sign In to add comment