Version française
Home     About     Download     Resources     Contact us    
Browse thread
Option functions (or lack thereof) + operator for composition
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Serge Le Huitouze <serge.lehuitouze@g...>
Subject: Re: [Caml-list] Option functions (or lack thereof) + operator for composition
>> To get rid of many warnings, I wrapped some calls (the "connect" calls of
>> my widgets) into "ignore (f x y)" statements.
>
> You can, but unfortunately $ does not have the right associativity.
>
> # let ($) f x = f x;;
> val ( $ ) : ('a -> 'b) -> 'a -> 'b = <fun>
> # ignore $ 1+1;;
> - : unit = ()
> # succ $ succ 3;;
> - : int = 5
> # succ $ succ $ succ 3;;
>
> If you want the compositionality, you can use something starting with @:
>
> # let (@@) f x = f x;;
> val ( @@ ) : ('a -> 'b) -> 'a -> 'b = <fun>
> # succ @@ succ @@ succ 3;;
> - : int = 6
>

Wow, tricky!
Not as tricky as Perl naming scheme for variables, but still tricky! ;-)
So I have to learn the precedence and associaticity table in section 6.7 of
OCaml's reference manual!!!


> Note however that there is a simpler way to circumvent the problem:
> use the "-w s" option on the command line, disabling the statement warning.
> All my lablgtk code uses this flag :-)

Warnings should be gotten rid of, so I don't like the idea of making
them silent.
But restricting silence to the statement warning is probably OK.
And I'll take your words for it, since, obviously, you have more experience
with lablgtk than myself! ;-)

But, on the other hand, maybe you can harmlessly use "-w s", whereas it may
bite me, given my poor understanding of this stuff...


Thanks.

--Serge