## null-or.pkg
# Compiled by:
#
src/lib/std/src/standard-core.sublib### "Men are born ignorant, not stupid.
### They are made stupid by education."
###
### -- Bertrand Russell
package null_or: (weak) Null_Or { # Null_Or is from
src/lib/std/src/null-or.api #
include package runtime; # for type Null_Or(X) # runtime is from
src/lib/core/init/built-in.pkg exception NULL_OR = NULL_OR;
fun the_else (THE x, y) => x;
the_else (NULL, y) => y;
end;
fun not_null (THE _) => TRUE;
not_null NULL => FALSE;
end;
fun the (THE x) => x;
the _ => raise exception NULL_OR;
end;
fun filter prior x
=
if (prior x) THE x;
else NULL;
fi;
fun join (THE opt) => opt;
join NULL => NULL;
end;
fun apply f (THE x) => f x;
apply f NULL => ();
end;
fun map f (THE x) => THE (f x);
map f NULL => NULL;
end;
fun map' f (THE x) => f x;
map' f NULL => NULL;
end;
fun compose (f, g) x
=
map f (g x);
fun compose_partial (f, g) x
=
map' f (g x);
};
## COPYRIGHT (c) 1997 AT&T Labs Research.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.