Beispiel #1
0
 private static Maybe <MovieReview> LiftedReview(AssociationList alist)
 {
     return(Maybe.LiftM3(
                MovieReview.MakeMovieReview,
                Lookup1("title", alist),
                Lookup1("user", alist),
                Lookup1("review", alist)));
 }
Beispiel #2
0
        public Settings()
        {
            InitializeComponent();
            var dataSource = AssociationList <Association> .CreateGroups(App.ViewModel.Associtions,
                                                                         new CultureInfo("nl-BE"), s => s.Dn, true);

            associations.ItemsSource = dataSource;
            DataContext = App.ViewModel.UserPreference;
        }
Beispiel #3
0
        private static Either <string, string> Lookup1(string key, AssociationList alist)
        {
            var keyWithEmptyValue = EitherError.Left <string>(string.Format("Found key \"{0}\" but its value is empty", key));
            var keyWithNoValue    = EitherError.Left <string>(string.Format("Found key \"{0}\" but it has no value", key));
            var keyNotFound       = EitherError.Left <string>(string.Format("Failed to find a value for key \"{0}\"", key));

            return(alist.GetValue(key).Match(
                       v => v.Match(
                           s => string.IsNullOrEmpty(s) ? keyWithEmptyValue : EitherError.Right(s),
                           () => keyWithNoValue),
                       () => keyNotFound));
        }
Beispiel #4
0
 private static Maybe <MovieReview> ApReview(AssociationList alist)
 {
     return(Maybe.LiftM(Fn.Curry(MovieReview.MakeMovieReviewFunc), Lookup1("title", alist))
            .Ap(Lookup1("user", alist))
            .Ap(Lookup1("review", alist)));
 }
Beispiel #5
0
 private static Maybe <string> Lookup1(string key, AssociationList alist)
 {
     return(alist
            .GetValue(key)
            .Bind(v => v.MFilter(s => !string.IsNullOrEmpty(s))));
 }
Beispiel #6
0
 private static Either <string, MovieReview> LiftedReview(AssociationList alist)
 {
     return(Either.LiftM(Fn.Curry(MovieReview.MakeMovieReviewFunc), Lookup1("title", alist))
            .Ap(Lookup1("user", alist))
            .Ap(Lookup1("review", alist)));
 }