Subject: Re: constants and functions without arguments
From: Andreas Leitner <[email-masked]>
To: Tom Pledger <[email-masked]>
Date: Fri, 30 Mar 2001 12:22:38 +0200

Tom Pledger wrote:
> 
> Andreas Leitner writes:
>  :
>  | Given a lazy pure functional language do we need to differntiate
>  | (in syntax) between constants and functions without agruments? And
>  | if we don't need to, does Haskell make a difference?
> 
> Haskell always treats a declaration of the form
> 
>     foo = ...
> 
> as a pattern binding, not as a function binding.  Sections 4.4.3 and
> 4.5 of the Haskell 98 report give more details.
> 
> So, in that sense, every function in Haskell takes an argument.
> There's nothing to prevent you from adding a dummy parameter to turn a
> constant (i.e. a simple pattern binding) into a function.  The only
> reason I've heard for doing so, is to work around the monomorphism
> restriction.

Exactly thats' the reason for my question: Overcome ther monomorphism.
I come from an Eiffel background and there we have the uniform access
principle, which is a very important thing in that world. It means
that you access an attribute just like a function with no parameters.
This is actually a form of information hiding as you can change the
underlying implementation (an attribute to a function and vice versa). 

The classic examlple for this is class POINT, which has an interface
like that:
--
POINT
	-- group 1
	x: DOUBLE
	y: DOUBLE
	-- group 2
	rho: DOUBLE
	abs: DOUBLE
--
Now, you can choose to either implement group 1 as attributes, or
group 2 and calculate the other one. With the uniform access
principle, which says that accessing attributes and functions with no
arguments happen in the same syntactic way, you can change the
implementaion without notice. No user of this class needs to know.

I am to new to FP to say whether this is equaly important in
FP-languages, since the semantics are different (constants vs.
attributes and immutable values vs. objects), but for now I am just
currious wether it is possible theoretically.

I mean couldn't one say that there are no constants, just functions
with no arguments or the Void/Unit argument that return an expression.
Since we have lazy evaluation, there won't be a problem at runtime,
but would the type system allow such a thing?

tia,
Andreas