# Infix expressions

**Ken Shan
**
ken@digitas.harvard.edu

*Mon, 29 Jul 2002 15:32:04 -0400*

--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hello,
In Haskell, backquotes can be used to convert individual identifiers
into infix operators, but not complex expressions. For example,
[1,2,3] `zip` [4,5,6]
is OK, but not
[1,2,3] `zipWith (+)` [4,5,6]
Is there any reason other than potential confusion when one of the two
backquotes is accidentally omitted?
In any case, perhaps some people on this mailing list would appreciate
the following implementation of "infix expressions" that Dylan Thurston
and I came up with -- as algebraic and perverse as we could manage:
infixr 0 -:, :-
data Infix f y =3D f :- y
x -:f:- y =3D x `f` y
main =3D print $ [1,2,3] -: zipWith (+) :- [4,5,6]
--=20
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
The trick is that there is no trick.
--a8Wt8u1KmwUX3Y2C
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9RZgzzjAc4f+uuBURAjl6AKCQmYb0HJvk2VicBlRD6zRX9VfRRgCg9F2B
YPXu07Uqrz8pj2iUt+HVM3U=
=WjJq
-----END PGP SIGNATURE-----
--a8Wt8u1KmwUX3Y2C--