Re: constants and functions without arguments

2001-03-30 Thread Tom Pledger

Andreas Leitner writes:
 :
 | 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.

That uniformity of access can certainly be achieved in Haskell.
Here's the Point example.  I've done it with two constructors so as to
get fewer floating point imprecisions, but some other possible
representations (e.g. one with only the Polar constructor) would look
identical outside the module.

module Point(Point, cartesian, polar, x, y, r, theta) where

-- data type with hidden constructors
data Point = Cartesian Double Double-- corresponds to group 1
   | Polar Double Double-- corresponds to group 2

-- proxy constructor functions
cartesian x y = Cartesian x y
polar r theta = Polar r theta

-- attribute extraction functions
x (Cartesian x y) = x
x (Polar r theta) = r * cos theta
y (Cartesian x y) = y
y (Polar r theta) = r * sin theta
r (Cartesian x y) = sqrt (x*x + y*y)
r (Polar r theta) = r
theta (Cartesian x y) = atan2 y x
theta (Polar r theta) = theta

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Instances of Read and Show

2001-03-30 Thread Dean Herington


Ingo Sander wrote:
I have a question concerning the Read and Show classes.
I have read the Haskell 98 report (section 6.3.3 The Read and Show
Classes), but I still do not figure out how to make instances.
I have a simple data type:
data TVal a =  Abst

| Prst a
I managed to define the function show, so that I can use it with the
data
type TVal
instance (Show a) => Show (TVal a) where
 show Abst
= "_"
 show (Prst x) = show
x
Signals> [Prst 1, Abst, Prst 2]
[1,_,2] :: [TVal Integer]
which is what I want to have.
But how do I make a Read instance?
I still do not understand the meaning of 'readsPrec' and
'readList' (and not of 'showPrec' and 'showList') either.
Can somebody explain to me or give me a good reference so that I can
make
TVal an instance of the classes Read and Show.
Thanks in advance for your help!
Ingo Sander
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

I might do it this way:
> data TVal a = Abst | Prst a
 
> instance (Show a) => Show (TVal a) where
> showsPrec p Abst = ('_' :)
> showsPrec p (Prst x) = showsPrec p x
> instance (Read a) => Read (TVal a) where
> readsPrec p s = case s' of ('_':t) ->
(Abst,t) : readsA
>   
_ -> readsA
>   where s' = dropWhile isSpace
s
>
readsA = map (\(a,t)-> (Prst a,t)) (readsPrec p s')
See section D.4 of the Haskell report for information on 'readsPrec',
'readList', 'showPrec', and 'showList'.
Dean Herington


RE: "Lambda Dance", Haskell polemic, etc. on O'Reilly site

2001-03-30 Thread Simon Marlow


> There are, perhaps good reasons for all these failures, but please
> recognize them for what they are: failures to meet the needs of the
> working programmer who just wants to get something done 
> (whether he/she
> lives in YU, FR, JP, or US)
> 
> I would love to be using Haskell for day to day programming work but I
> can't at this time.  Unless the community recognizes what is 
> required and
> gets it done, I never will.

There is one good reason that Haskell fails in these areas, and that's
shortage of effort.

We in the GHC team are actively trying to encourage our users to
contribute: with an open CVS source tree, open development mailing
lists, etc.  We've had some good results (thanks to our developers!),
but we need more.  GHC is a large and complex system, and with trying to
be all things to all people - a research vehicle / experimentation
platform / production compiler, our developer resources are stretched a
bit thin.  I'm sure this goes for the other Haskell systems too.

I see libraries as the biggest missing piece in the Haskell language.
Let's face it, Joe Programmer isn't going to pass Haskell by just
because it doesn't support a particular flavour of overlapping instance
declarations.  But he might if it doesn't have a networking library, or
unicode support, or an XML parser.  Please, join [EMAIL PROTECTED]


Cheers,
Simon

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: "Lambda Dance", Haskell polemic, etc. on O'Reilly site

2001-03-30 Thread S. Alexander Jacobson

Jerszy,

Although I think Haskell is a beautiful language, Jelovic is right on his
core points, Haskell implementations don't meet the needs of the working
programmer.

A user can download Python or Perl to his windows or linux computer,
install, and very quickly be up and running writing code that calls system
libraries, talks to mysql databases, retrieves XML content from the web and parses
it, etc.

Moreover, if the default libraries don't meet his/her needs, it is easy
to find additional libraries on the web, and when found, there is a high
likelyhood that they will work as advertised with the installed system.

Contrast the above with Haskell, which doesn't immediately, easily and
reliably install on all platforms (perhaps aside from Hugs), is still
figuring out core language features,and does not even have a consistent
set of libraries for simple stuff like filesystem access!

There are, perhaps good reasons for all these failures, but please
recognize them for what they are: failures to meet the needs of the
working programmer who just wants to get something done (whether he/she
lives in YU, FR, JP, or US)

I would love to be using Haskell for day to day programming work but I
can't at this time.  Unless the community recognizes what is required and
gets it done, I never will.

-Alex-

___
S. Alexander Jacobson   Shop.Com
1-646-638-2300 voiceThe Easiest Way To Shop (sm)



On Fri, 30 Mar 2001, Jerzy Karczmarczuk wrote:

> Fritz K Ruehr wrote:
>
> ...
>
> > The second link is a little polemic entitled "Why People Aren't Using
> > Haskell", which I presume would be of interest to readers of this
> > list (the author is Dejan Jelovic, whom I don't recognize as a regular
> > contributor here):
> >
> > 
>
> If you didn't verify this site, forget it. There is NOTHING serious
> there.
>
> Over and over again the same silly song, by a person who - visibly -
> had never anything to do with functional languages, who thinks now
> about hiring some C and java programmers living in Belgrade, but who
> writes such silly, incompetent things as:
>
> > And there is an air of staleness: where new versions of these other
> > languages appear frequently, the Haskell community is offering you
> > Hugs98.
>
>
> Delovic points out that some languages became "immensely" popular,
> as e.g. Ruby, and that Haskell is marginal.  Hm. this extremely
> orthodox Japanese essence of O-O programming may have some practical
> merits, especially those which come from shameless borrowing from
> Eiffel, Sather, Clu and Common Lisp, but calling Haskell "marginal"
> or "obscure" informs us not what is Haskell, but who is Jelovic.
> He accuses the Haskell community of not providing libraries...
>
> ==
>
> Perhaps there is *one* point worth mentioning: the necessity to
> publish papers about Haskell far from such journals as JFP or HOSC,
> but to try to reach DrDobbs etc. I would add: Software: Practice
> and experience, and journals on numerical software where one could
> show some non-trivial implementations of practical, numerical
> algorithms.
>
> Jerzy Karczmarczuk
> Caen, France
>
>
> PS. What is "hamster dance", anyway?
>
> ___
> Haskell-Cafe mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: "Lambda Dance", Haskell polemic, etc. on O'Reilly site

2001-03-30 Thread Jerzy Karczmarczuk

Fritz K Ruehr wrote:

...

> The second link is a little polemic entitled "Why People Aren't Using
> Haskell", which I presume would be of interest to readers of this
> list (the author is Dejan Jelovic, whom I don't recognize as a regular
> contributor here):
> 
> 

If you didn't verify this site, forget it. There is NOTHING serious
there.

Over and over again the same silly song, by a person who - visibly -
had never anything to do with functional languages, who thinks now
about hiring some C and java programmers living in Belgrade, but who
writes such silly, incompetent things as:

> And there is an air of staleness: where new versions of these other
> languages appear frequently, the Haskell community is offering you 
> Hugs98. 


Delovic points out that some languages became "immensely" popular,
as e.g. Ruby, and that Haskell is marginal.  Hm. this extremely
orthodox Japanese essence of O-O programming may have some practical
merits, especially those which come from shameless borrowing from
Eiffel, Sather, Clu and Common Lisp, but calling Haskell "marginal"
or "obscure" informs us not what is Haskell, but who is Jelovic.
He accuses the Haskell community of not providing libraries...

==

Perhaps there is *one* point worth mentioning: the necessity to
publish papers about Haskell far from such journals as JFP or HOSC,
but to try to reach DrDobbs etc. I would add: Software: Practice
and experience, and journals on numerical software where one could
show some non-trivial implementations of practical, numerical
algorithms.

Jerzy Karczmarczuk
Caen, France


PS. What is "hamster dance", anyway?

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe