Exemplo n.º 1
0
        public SubUnit GMapT <A>(MkT <A> lf)
        {
            Func <Dept, SubUnit>     fd = d => new SubUnit(lf.Apply(d));
            Func <Employee, SubUnit> fe = e => new SubUnit(lf.Apply(e));

            return(Match(fd, fe));
        }
Exemplo n.º 2
0
        private static void V2Example()
        {
            var grandchild = new Grandchild("Mario");

            var child  = new Child(grandchild);
            var parent = new Parent(child);

            var lf = new MkT <Grandchild>(p => new Grandchild(p.Name + " Rossi"));

            var result = Everywhere(lf, parent);
        }
Exemplo n.º 3
0
        private static void ParadiseExample()
        {
            // Build example company
            var company = Functions.BuildCompany();

            // Lift function, mkT in the original paper
            var liftedIncrease = new MkT <Salary>(p => Functions.Increase(0.1m, p));

            // Apply the lifted function everywhere
            var result = Everywhere(liftedIncrease, company);

            // Salary is increased, check only one to verify it
            var original = company.Departments
                           .FirstOrDefault(p => p.Name.Value == "Strategy")
                           .Manager.Salary.Value;

            var final = result.Departments
                        .FirstOrDefault(p => p.Name.Value == "Strategy")
                        .Manager.Salary.Value;

            Console.WriteLine($"Starting salary is {original}, final salary is {final}");
        }
Exemplo n.º 4
0
 public Dept GMapT <A>(MkT <A> lf)
 {
     return(new Dept(lf.Apply(Name), lf.Apply(Manager), Units.Select(u => lf.Apply(u)).ToArray()));
 }
Exemplo n.º 5
0
 public Grandchild GMapT <A>(MkT <A> lf)
 {
     return(new Grandchild(Name));
 }
Exemplo n.º 6
0
 public Parent GMapT <A>(MkT <A> lf)
 {
     return(new Parent(lf.Apply(_child)));
 }
Exemplo n.º 7
0
 public Company GMapT <A>(MkT <A> lf)
 {
     return(new Company(Departments.Select(d => lf.Apply(d)).ToArray()));
 }
Exemplo n.º 8
0
 public Salary GMapT <A>(MkT <A> lf)
 {
     return(this);
 }
Exemplo n.º 9
0
 public new Manager GMapT <A>(MkT <A> lf)
 {
     return(new Manager(lf.Apply(Salary), lf.Apply(Person)));
 }
Exemplo n.º 10
0
 public Employee GMapT <A>(MkT <A> lf)
 {
     return(new Employee(lf.Apply(Salary), lf.Apply(Person)));
 }
Exemplo n.º 11
0
 public Person GMapT <A>(MkT <A> lf)
 {
     return(new Person(lf.Apply(Address), lf.Apply(Name)));
 }
Exemplo n.º 12
0
 public Child GMapT <A>(MkT <A> lf)
 {
     return(new Child(lf.Apply(_grandchild)));
 }
Exemplo n.º 13
0
 public Address GMapT <A>(MkT <A> lf)
 {
     return(this);
 }
Exemplo n.º 14
0
 public Name GMapT <A>(MkT <A> lf)
 {
     return(this);
 }