2 people like it.
Like the snippet!
F# lambda as C# expression
Expression<Func<'a, 'b>> as expr builder
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
|
open System.Linq.Expressions
open System.Linq
open System
type ExprBuilder() =
member private __.ReturnFrom(f: Expression<Func<_,_>>) = f
member __.Return(f) = __.ReturnFrom(fun x -> f(x))
let expr = ExprBuilder()
let predicate = expr { return (>=) 5 }
let selector = expr { return (+) 1 >> (*) 2 }
let a = [|1; 2; 3|].AsQueryable().Select(selector).Where(predicate)
|
namespace System
namespace System.Linq
namespace System.Linq.Expressions
Multiple items
type ExprBuilder =
new : unit -> ExprBuilder
member Return : f:('a -> 'b) -> Expression<Func<'a,'b>>
member private ReturnFrom : f:Expression<Func<'c,'d>> -> Expression<Func<'c,'d>>
Full name: Script.ExprBuilder
--------------------
new : unit -> ExprBuilder
member private ExprBuilder.ReturnFrom : f:Expression<Func<'c,'d>> -> Expression<Func<'c,'d>>
Full name: Script.ExprBuilder.ReturnFrom
val f : Expression<Func<'c,'d>>
Multiple items
type Expression =
member CanReduce : bool
member NodeType : ExpressionType
member Reduce : unit -> Expression
member ReduceAndCheck : unit -> Expression
member ReduceExtensions : unit -> Expression
member ToString : unit -> string
member Type : Type
static member Add : left:Expression * right:Expression -> BinaryExpression + 1 overload
static member AddAssign : left:Expression * right:Expression -> BinaryExpression + 2 overloads
static member AddAssignChecked : left:Expression * right:Expression -> BinaryExpression + 2 overloads
...
Full name: System.Linq.Expressions.Expression
--------------------
type Expression<'TDelegate> =
inherit LambdaExpression
member Compile : unit -> 'TDelegate + 1 overload
member Update : body:Expression * parameters:IEnumerable<ParameterExpression> -> Expression<'TDelegate>
Full name: System.Linq.Expressions.Expression<_>
Multiple items
type Func<'TResult> =
delegate of unit -> 'TResult
Full name: System.Func<_>
--------------------
type Func<'T,'TResult> =
delegate of 'T -> 'TResult
Full name: System.Func<_,_>
--------------------
type Func<'T1,'T2,'TResult> =
delegate of 'T1 * 'T2 -> 'TResult
Full name: System.Func<_,_,_>
--------------------
type Func<'T1,'T2,'T3,'TResult> =
delegate of 'T1 * 'T2 * 'T3 -> 'TResult
Full name: System.Func<_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 -> 'TResult
Full name: System.Func<_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 -> 'TResult
Full name: System.Func<_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
--------------------
type Func<'T1,'T2,'T3,'T4,'T5,'T6,'T7,'T8,'T9,'T10,'T11,'T12,'T13,'T14,'T15,'T16,'TResult> =
delegate of 'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8 * 'T9 * 'T10 * 'T11 * 'T12 * 'T13 * 'T14 * 'T15 * 'T16 -> 'TResult
Full name: System.Func<_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_>
val __ : ExprBuilder
member ExprBuilder.Return : f:('a -> 'b) -> Expression<Func<'a,'b>>
Full name: Script.ExprBuilder.Return
val f : ('a -> 'b)
member private ExprBuilder.ReturnFrom : f:Expression<Func<'c,'d>> -> Expression<Func<'c,'d>>
val x : 'a
val expr : ExprBuilder
Full name: Script.expr
val predicate : Expression<Func<int,bool>>
Full name: Script.predicate
val selector : Expression<Func<int,int>>
Full name: Script.selector
val a : IQueryable<int>
Full name: Script.a
More information