next up previous index
Next: Tuples Up: Basic data types and Previous: Characters   Index

Options

In maybe.cecil:

abstract object maybe[`T];
extend type maybe[`T] subtypes maybe[`S >= T];
  signature if_some_none(maybe[`T], if_some:&(T):`T1, if_none:&():`T2):T1|T2;
  method if_some(m@:maybe[`T], if_some:&(T):void):void;
  method if_none(m@:maybe[`T], if_none:&():void):void;
  method is_some(m@:maybe[`T]):bool;
  method is_none(m@:maybe[`T]):bool;
  signature value(maybe[`T]):T;
  method value(m@:maybe[`T1], if_none:&():`T2):T1|T2;
template object some[`T] isa maybe[T];
extend type some[`T] subtypes some[`S >= T];
  field value(@:some[`T]):T;
  method if_some_none(s@:some[`T], if_some:&(T):`T1, if_none:&():`T2):T1|T2;
  method some(value:`T):some[T];
  method some[`T](value:T):some[T];
  method print_string(s@:some[`T]):string;
concrete object none[`T] isa maybe[T];
extend type none[`T] subtypes none[`S >= T];
  method if_some_none(@:none[`T], if_some:&(T):`T1, if_none:&():`T2):T1|T2;
  method value(@:none[`T]):T;
extend object maybe[`T <= comparable[T]] isa comparable[maybe[T]];
  method =(@:maybe[`T <= comparable[T]], @:maybe[`T]):bool;
  method =(s1@:some[`T <= comparable[T]], s2@:some[`T]):bool;
  method =(@:none[`T <= comparable[T]], @:none[`T]):bool;
extend object maybe[`T <= hashable[T]] isa hashable[maybe[T]];
  method hash(s@:some[`T <= hashable[T]], range:int):int;
  method hash(@:none[`T <= hashable[T]], range:int):int;
The maybe[T] parameterized type represents either a value of type T or no value, akin to ML's option datatype. maybes are useful where an explicit null pointer might be used in some other language, but the possibility for null is explicit when using maybes. In absent.cecil:

concrete object absnt;
type synonym mb[T] = T | absnt;
signature is_presnt(mb[`T]):bool;
signature is_absnt(mb[`T]):bool;
signature if_presnt(mb[`T], if_presnt:&(T):`R, if_absnt:&():`R):R;
signature if_presnt(mb[`T], if_presnt:&(T):void):void;
signature if_absnt (mb[`T], if_absnt:&():`R, if_presnt:&(T):`R):R;
signature if_absnt (mb[`T], if_absnt:&():void):void;
signature using_for_absnt   (mb[`T], val_for_absnt:T):T;
signature using_for_absnt_cl(mb[`T], if_absnt:&():T):T;
implementation if_absnt(x:`T, if_absnt:any, if_presnt:&(T):`R):R;
implementation if_absnt(x@:absnt, if_absnt:&():`R, if_presnt:any):R;
implementation if_absnt(x:mb[`T], if_absnt:&():void):void;
implementation if_presnt(x:mb[`T], if_presnt:&(T):void):void;
implementation if_presnt(x:mb[`T], if_presnt:&(T):`R, if_absnt:&():`R):R;
implementation is_absnt(x:mb[`T]):bool;
implementation is_presnt(x:mb[`T]):bool;
implementation using_for_absnt_cl(x:mb[`T], if_absnt:&():T):T;
implementation using_for_absnt(x:mb[`T], val_for_absnt:T):T;
signature =(mb[T], mb[T]):bool where `T <= comparable[T];
implementation =(@:absnt, @:absnt):bool;
implementation =(@:absnt, @:comparable[`T]):bool;
implementation =(@:comparable[`T], @:absnt):bool;
signature hash(mb[T], range:int):int where `T <= hashable[T];
implementation hash(@:absnt, range:int):int;


next up previous index
Next: Tuples Up: Basic data types and Previous: Characters   Index

Cecil/Vortex Project