Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher Order Types and Parameters #616

Closed
bvssvni opened this issue May 24, 2019 · 3 comments
Closed

Higher Order Types and Parameters #616

bvssvni opened this issue May 24, 2019 · 3 comments

Comments

@bvssvni
Copy link
Member

bvssvni commented May 24, 2019

Related to #610

A Higher Order Type is written \-> T and accepts any type T or a closure returning T:

fn foo(a: \-> f64, b: \-> f64) -> \-> f64 {
    return a + b
}

The \ type operator can be thought of as specifying an unknown type ("from something") defined at runtime when calling the function. The type checker reports an error if the "from something" type does not match each other for every argument.

Examples

A higher order line:

line(a: \-> vec4, b: \-> vec4, t : \-> f64) = a + (b - a) * t

A higher order quadratic bezier:

qbez(a : \-> vec4, b: \-> vec4, c: \-> vec4, t: \-> f64) =
    line(line(a, b, t), line(b, c, t), t)
@bvssvni
Copy link
Member Author

bvssvni commented Jul 27, 2019

An alternative is to write \T instead of \-> T.

@bvssvni
Copy link
Member Author

bvssvni commented Jul 27, 2019

Two other alternatives are \> T or -> T.

@bvssvni
Copy link
Member Author

bvssvni commented Aug 5, 2019

Closing, see #610 (comment)

@bvssvni bvssvni closed this as completed Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant