[Haskell] Re: Typing in haskell and mathematics

Chung-chieh Shan ccshan at post.harvard.edu
Mon Jan 31 13:05:31 EST 2005


Jeremy Gibbons <Jeremy.Gibbons at comlab.ox.ac.uk> wrote in article <Pine.GSO.4.51.0501310314250.3639 at abacus.comlab> in gmane.comp.lang.haskell.general:
> But in FP, of course, functions are first class citizens. So one may get
> ambiguities on account of it being reasonable to treat a particular
> function either as "program" or as "data" - with conflicting outcomes...

> Suppose one wants to streamline notation, so
> that instead of having to write
>   (f . g) $ x
> one can write
>   f @ g @ x
> Here, "@" means either composition or application according to context. It
> is supposed to be associative, so it isn't the same as normal Haskell $;
> in particular,
>   f @ g
> is valid and represents the composition of f and g.

Indeed, I've been thinking about such a notation, but one that
explicitly specifies whether to treat a function as "program" or "data".
Variables like "f" always denote data to start with; such data can be
thought of as a program that maps unit to a function.  Data can be
turned into a program by unquoting it with "," (usually I write "@" for
unquotation but you use it for composition already).  (Conversely, a
program can be turned into data by enclosing it in a pair of quotation
brackets "[]", a la Joy; unquotation cancels quotation by the reduction
step ,[X] => X.)  Now

    (f . g) $ x

in Haskell notation is written

    ,f @ ,g @ x

We also distinguish between

    ,thrice @ thrice

and

    ,thrice @ ,thrice

An advantage of this notation is that it exposes the symmetry between
call-by-value and call-by-name evaluation: right-to-left evaluation here
corresponds to call-by-value, argument-first evaluation; left-to-right
evaluation here corresponds to call-by-name evaluation.  I could go on
and on about this.

-- 
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
War crimes will be prosecuted. War criminals will be punished. And it
will be no defense to say, "I was just following orders."'
                    George W. Bush, address to the nation, 2003-03-17
      http://www.whitehouse.gov/news/releases/2003/03/20030317-7.html



More information about the Haskell mailing list