Reputation: 53
If I have the types:
type test = float * float
type helper =
| test1 of test
| test2 of test
| test3 of test
And right now I have a function with the type:
f: ('a * 'b) -> ('b -> 'a) -> 'a
What will the type of f(helper(1., 2.), true)
be? Will it be something like:
(helper * bool) -> (bool -> helper) -> helper
Or am I still confused with the polymorphic type in OCaml.
Upvotes: 0
Views: 41
Reputation: 36620
A value of type helper
would be constructed with test1
, test2
, or test3
, which must begin with a capital letter.
type test = float * float
type helper =
| Test1 of test
| Test2 of test
| Test3 of test
If we then test f (Test1 (1., 2.), true)
, we have partially applied f
and get a function which takes a function argument and returns helper
, or a type signature of:
(bool -> helper) -> helper
Upvotes: 2