Typed abstract syntax tree with function application
I am trying to write a typed abstract syntax tree datatype that can represent function application. So far I have type Expr<'a> = | Constant of 'a | Application of Expr<'b -> 'a> * Expr<'b> // error: The type parameter 'b' is not defined I don't think there is a way in F# to write something like 'for all b' on that last line - am I approaching this problem wrongly? In general, the F# type system is not expressive enough to (directly) define a typed abstract syntax tree as the one in your example. This can be done using generalized algebraic data types (GADTs) which are not supported in F#