示例#1
0
 // monadic
 Option <PhoneNumber> CreatePhoneNumberM
     (string typeStr, string countryStr, string numberStr)
 => optCountryCode(countryStr)
 .Bind(country => optNumberType(typeStr)
       .Bind(type => PhoneNumber.Number.Create(numberStr)
             .Bind <PhoneNumber.Number, PhoneNumber>(number
                                                     => PhoneNumber.Create(type, country, number))));
示例#2
0
 Validation <PhoneNumber> CreateValidPhoneNumberM
     (string typeStr, string countryStr, string numberStr)
 => from type in validNumberType(typeStr)
 from country in validCountryCode(countryStr)
 from number in validNumber(numberStr)
 select PhoneNumber.Create(type, country, number);
示例#3
0
 // monadic with LINQ
 Option <PhoneNumber> CreatePhoneNumber_LINQ
     (string typeStr, string countryStr, string numberStr)
 => from country in optCountryCode(countryStr)
 from type in optNumberType(typeStr)
 from number in PhoneNumber.Number.Create(numberStr)
 select PhoneNumber.Create(type, country, number);