Skip to content

Instantly share code, notes, and snippets.

@prophile
Created December 5, 2010 13:57
Show Gist options
  • Save prophile/729098 to your computer and use it in GitHub Desktop.
Save prophile/729098 to your computer and use it in GitHub Desktop.
module std;
export Maybe;
export Nothing;
export Just;
export force;
export isNothing;
Maybe<a> = variant Nothing, Just(a)
force<a> :: Maybe<a> -> a;
force(Just(x)) := x;
force(Nothing) := error "forced a Nothing";
isNothing :: Maybe<a> -> Bool;
isNothing(Just(_)) := false;
isNothing(Nothing) := true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment