Not directly with the type system.
It's a bit tricky conceptually because of the multiple dispatch. Suppose
you only wanted your Function to take functions of the type Real to Real.
You pass in sqrt which satisfies this, but what if someone else has a
method for sqrt which maps matrices to matrices?
You could make your own choices of how to do this and implement some kind
of type checking within the inner constructor; julias introspection tools
make this feasible. But probably that's not a good idea.
Zenna
On Tuesday, March 3, 2015 at 9:07:55 PM UTC-5, Phil Tomson wrote:
>
> Let's say I want to define a type that contains a Function type:
>
> type IterFunc
> iter_trigger::Int64
> func::Function
> end
>
> Is there any way to say that the func member in that type should be a
> function that takes arguments of a certain type?
>
> Something like (not valid syntax, I tried):
>
> type IterFunc
> iter_trigger::Int64
> func::Function{i::Int64, something::SomeType}
> end
>
>
> ?
>