🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fa.caml
Article #80

Re: Haskell $ like operator in OCaml

#80
From: utizoc
Date: Thu, 04 Oct 2012 00:57
37 lines
1958 bytes
On Friday, September 28, 2012 3:01:42 AM UTC-3, Evrim Ulu wrote:
> Hello,
> 
> 
> 
> Is there an equivalent operator to $ in Haskell?
> 
> 
> 
> let f1 a = a+1 in                                                                                                                         
> 
> let f2 a = a+2 in                                                                                                                         
> 
> f1 (f2 3);;
> 
> 
> 
> I would like to write f1 $ f2 3 instead of f1 (f2 3).
> 
> 
> 
> Thanks,
> 
> evrim.

Try this:

let ($) f x = f x;;

Repl:

# let ($) f x = f x;;
val ( $ ) : ('a -> 'b) -> 'a -> 'b = <fun>
# let f1 a = a+1 in
let f2 a = a+2 in
f1 $ f2 3;;     
- : int = 6
Technical Details
Message-ID: <6c2a6c83-a5fc-4e36-9a86-bb4e4036b1e9@googlegroups.com>
Path: arc1-ca.pugleaf.net!e10ni165558057qan.0!nntp.google.com!l8no24065794qao.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
References: <cb26f128-eca7-48d9-aca0-95e697c48673@googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: c0fe4b917e,edac671640b0ad55
X-Google-Attributes: gidc0fe4b917e,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: ENGLISH,ASCII-7-bit
Received: by 10.224.223.84 with SMTP id ij20mr4403717qab.5.1349312228699;
        Wed, 03 Oct 2012 17:57:08 -0700 (PDT)
Received: by 10.236.155.70 with SMTP id i46mr473695yhk.3.1349312228561; Wed,
 03 Oct 2012 17:57:08 -0700 (PDT)
Path: arc1-ca.pugleaf.net!e10ni165558057qan.0!nntp.google.com!l8no24065794qao.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: fa.caml
Date: Wed, 3 Oct 2012 17:57:08 -0700 (PDT)
In-Reply-To: <cb26f128-eca7-48d9-aca0-95e697c48673@googlegroups.com>
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=190.135.59.1; posting-account=q708iQoAAABGfHUnErI39EY6T8V1g4EL
NNTP-Posting-Host: 190.135.59.1
References: <cb26f128-eca7-48d9-aca0-95e697c48673@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6c2a6c83-a5fc-4e36-9a86-bb4e4036b1e9@googlegroups.com>
Subject: Re: Haskell $ like operator in OCaml
From: utizoc@gmail.com
Injection-Date: Thu, 04 Oct 2012 00:57:08 +0000
Content-Type: text/plain; charset=ISO-8859-1