I have seen somewhere (sorry, I can't find the a reference) this operator composition:
(>>)(>>)
where (>>): (('a -> 'b) -> ('b -> 'c) -> 'a -> 'c)
- (>>)
is the function composition operator.
I find simpler examples are easy to understand. For example (>>)f
, where f: i -> i
.
(>>)(i -> i)
becomes (i -> 't) -> i -> 't
. This is because ('a -> 'b)
is curried away, 'b
is inferred to be i
and 't
remains a generic type.
I do not fully understand (>>)(>>)
:
The use
What would (>>)(>>)
and (<<)(<<)
used for?
Why it is necessary to make the argument explicit?
> (>>)(>>);;
(>>)(>>);;
-^^^^^^
C:\Users\...\Temp\stdin(3,2): error FS0030: Value restriction. The value 'it' has been inferred to have generic type
val it : (((('_a -> '_b) -> '_c -> '_b) -> '_d) -> ('_c -> '_a) -> '_d)
Either make the arguments to 'it' explicit or, if you do not intend for it to be generic, add a type annotation.
As suggested by the error message:
> let strangeFun arg = (>>)(>>) arg;;
val strangeFun : arg:((('a -> 'b) -> 'c -> 'b) -> 'd) -> (('c -> 'a) -> 'd)