コード例 #1
0
 public IfDotted() : base("if_then_else_dotted", true,
                          new[]
 {
     Curry.ConstructFrom(a,
                         new Curry(b, Typs.Bool),
                         new Curry(b, a),
                         b),
     Curry.ConstructFrom(a,
                         new Curry(b, Typs.String),
                         new Curry(b, a),
                         b),
     Curry.ConstructFrom(a,
                         new Curry(b, Typs.Bool),
                         new Curry(b, a),
                         new Curry(b, a),
                         b),
     Curry.ConstructFrom(a,
                         new Curry(b, Typs.String),
                         new Curry(b, a),
                         new Curry(b, a),
                         b)
 }
                          )
 {
     Funcs.AddBuiltin(this, "ifdotted");
     Funcs.AddBuiltin(this, "ifDotted");
 }
コード例 #2
0
 public Default() : base("default", true,
                         new[]
 {
     Curry.ConstructFrom(a, a, new Curry(b, a), b)
 })
 {
 }
コード例 #3
0
ファイル: Concat.cs プロジェクト: pietervdvn/AspectedRouting
 public Concat() : base("concat", true,
                        new[]
 {
     Curry.ConstructFrom(Typs.String, Typs.String, Typs.String)
 })
 {
 }
コード例 #4
0
 public Eq() : base("eq", true,
                    new[]
   {
       Curry.ConstructFrom(Typs.Bool, new Var("a"), new Var("a")),
       Curry.ConstructFrom(Typs.String, new Var("a"), new Var("a"))
   })
 {
 }
コード例 #5
0
 public ConstRight() : base("constRight", true,
                            new[]
   {
       Curry.ConstructFrom(new Var("b"), new Var("a"), new Var("b"))
   }
                            )
 {
 }
コード例 #6
0
ファイル: Const.cs プロジェクト: pietervdvn/AspectedRouting
 public Const() : base("firstArg", true,
                       new[]
 {
     Curry.ConstructFrom(new Var("a"), new Var("a"), new Var("b"))
 }
                       )
 {
     Funcs.AddBuiltin(this, "const");
 }
コード例 #7
0
 public void Fresh_SomeType_NewVarName()
 {
     Assert.Equal("$d", Var.Fresh(
                      Curry.ConstructFrom(new Var("a"),
                                          new Var("b"),
                                          new Var("b"),
                                          new Var("c"),
                                          new Var("aa"))).Name);
 }
コード例 #8
0
 public AtLeast() : base("atleast", true,
                         new[]
 {
     Curry.ConstructFrom(a,
                         Typs.Double,
                         new Curry(b, Typs.Double),
                         a, a, b),
 })
 {
 }
コード例 #9
0
ファイル: NotEq.cs プロジェクト: pietervdvn/AspectedRouting
 public NotEq() : base("notEq", true,
                       new[]
 {
     Curry.ConstructFrom(Typs.Bool, new Var("a"), new Var("a")),
     Curry.ConstructFrom(Typs.String, new Var("a"), new Var("a")),
     new Curry(Typs.Bool, Typs.Bool),
 })
 {
     Funcs.AddBuiltin(this, "not");
 }
コード例 #10
0
 public Dot() : base("dot", true, new[]
 {
     // (.) : (b -> c) -> (a -> b) -> a -> c
     Curry.ConstructFrom(C,
                         new Curry(B, C),
                         new Curry(A, B),
                         A
                         )
 })
 {
 }
コード例 #11
0
ファイル: If.cs プロジェクト: pietervdvn/AspectedRouting
 public If() : base("if_then_else", true,
                    new[]
 {
     Curry.ConstructFrom(a, Typs.Bool, a, a),
     Curry.ConstructFrom(a, Typs.Bool, a),
     Curry.ConstructFrom(a, Typs.String, a, a),
     Curry.ConstructFrom(a, Typs.String, a)
 }
                    )
 {
     Funcs.AddBuiltin(this, "if");
 }
コード例 #12
0
 public MustMatch() : base("must_match", true,
                           new[] {
     // [String] -> (Tags -> [string]) -> Tags -> bool
     Curry.ConstructFrom(Typs.Bool,                                       // Result type on top!
                         new ListType(Typs.String),                       // List of keys to check for
                         new Curry(Typs.Tags, new ListType(Typs.String)), // The function to execute on every key
                         Typs.Tags                                        // The tags to apply this on
                         )
 })
 {
     Funcs.AddBuiltin(this, "mustMatch");
 }
コード例 #13
0
 public FirstMatchOf() : base("first_match_of", true,
                              new[]
 {
     // [String] -> (Tags -> [a]) -> Tags -> a
     Curry.ConstructFrom(new Var("a"),     // Result type on top!
                         new ListType(Typs.String),
                         new Curry(Typs.Tags, new ListType(new Var("a"))),
                         Typs.Tags
                         )
 })
 {
     Funcs.AddBuiltin(this, "firstMatchOf");
 }
コード例 #14
0
        public void TypeInference_EitherIdConstConst_CorrectType()
        {
            /*
             * id : a -> a
             * dot: (b -> c) -> (a -> b) -> a -> c
             * const - throw away b: a -> b -> a
             * eitherFunc: (a -> b) -> (c -> d) -> (a -> b)
             * eitherFunc: (a -> b) -> (c -> d) -> (c -> d)
             *
             *
             * All with free vars:
             * id: a -> a
             * dot: (b -> c) -> (x -> b) -> x -> c
             * const: y -> z -> y
             * eitherfunc: (d -> e) -> (f -> g) -> (d -> e)
             *             (d -> e) -> (f -> g) -> (f -> g)
             */

            /*
             * (((eitherfunc id) dot) const)
             *
             *  (eitherfunc id)
             *  [(d -> e) -> (f -> g) -> (d -> e)] (a -> a)
             *  [(d -> e) -> (f -> g) -> (f -> g)] (a -> a)
             *
             * Gives:
             *   d ~ a
             *   e ~ a
             * thus:
             * (f -> g) -> (a -> a)
             * (f -> g) -> (f -> g)
             *
             * ((eitherfunc id) dot)
             * [(f -> g) -> (a -> a)] ((b -> c) -> (x -> b) -> x -> c)
             * [(f -> g) -> (f -> g)] (b -> c) -> (x -> b) -> (x -> c)
             *
             * Thus: (f -> g) ~ (b -> c) -> ((x -> b) -> x -> c)
             * thus: f ~ (b -> c)
             *       g ~ ((x -> b) -> (x -> c))
             * thus:
             * (a -> a)
             * (b -> c) -> ((x -> b) -> (x -> c))
             *
             *
             *
             * (((eitherfunc id) dot) const):
             * [(a -> a)] (y -> (z -> y))
             * [(b -> c) -> ((x -> b) -> (x -> c))] (y -> (z -> y))
             *
             * Thus: case 1:
             *     a ~ (y -> (z -> y)
             *     Type is: (y -> z -> y) === typeof(const)
             * case2:
             *     (b -> c) ~  (y -> (z -> y))
             *     thus: b ~ y
             *           c ~ (z -> y)
             *     ((x -> y) -> (x -> (z -> y))))
             *     = ((x -> y) -> x -> z -> y === mix of dot and const
             *
             */

            var a = new Var("a");
            var c = new Var("c");
            var d = new Var("d");


            var e     = Funcs.Either(Funcs.Id, Funcs.Dot, Funcs.Const);
            var types = e.Types.ToList();

            Assert.Equal(Curry.ConstructFrom(c, c, d), types[0]);
            Assert.Equal(Curry.ConstructFrom(
                             c, // RESULT TYPE
                             new Curry(a, c),
                             a, d
                             ), types[1]);
        }