Guest User

Untitled

a guest
Jul 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. module std;
  2.  
  3. export Maybe;
  4. export Nothing;
  5. export Just;
  6.  
  7. export force;
  8. export isNothing;
  9.  
  10. Maybe<a> = variant Nothing, Just(a)
  11.  
  12. force<a> :: Maybe<a> -> a;
  13.  
  14. force(Just(x)) := x;
  15. force(Nothing) := error "forced a Nothing";
  16.  
  17. isNothing :: Maybe<a> -> Bool;
  18.  
  19. isNothing(Just(_)) := false;
  20. isNothing(Nothing) := true;
Add Comment
Please, Sign In to add comment