Infix expressions
Yoann Padioleau
Yoann.Padioleau@irisa.fr
30 Jul 2002 11:53:42 +0200
Ken Shan <ken@digitas.harvard.edu> writes:
> --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]
This is a funny tricks.
Does some people know other kind of tricks (possibly in other functionnal langage) ?
>
> --=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--
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
--
Yoann Padioleau, INSA de Rennes, France,
Opinions expressed here are only mine. Je n'écris qu'à titre personnel.
**____ Get Free. Be Smart. Simply use Linux and Free Software. ____**