Re: [Haskell-cafe] Re: 0/0 1 == False

2008-01-12 Thread Cristian Baboi
On Sat, 12 Jan 2008 13:23:41 +0200, Kalman Noel  
[EMAIL PROTECTED] wrote:



Achim Schneider wrote:

Actually, lim( 0 ) * lim( inf ) isn't anything but equals one, and
the anything is defined to one (or, rather, is _one_ anything) to be
able to use the abstraction. It's a bit like the difference between
eight pens and a box of pens. If someone knows how to properly
formalise n = 1, please speak up.


Sorry if I still don't follow at all.  Here is how I understand (i. e.
have learnt) lim notation, with n ∈ N, a_n ∈ R.  (Excuse my poor
terminology, I have to translate this in my mind from German maths
language ;-).  My point of posting this is that I don't see how to
accommodate the lim notation as I know it with your term. The limit of
infinity?  What is the limit of infinity, and why should I multiplicate
it with 0?  Why should I get 1?

(1) lim a_n  = a(where a ∈ R)
(2) lim a_n  = ∞
(3) lim a_n  = − ∞
(4) lim { x → x0 } f(x) = y (where f is a function into R)

(1) means that the sequence of reals a_n converges towards a.

(2) means that the sequence does not converge, because you can
always find a value that is /larger/ than what you hoped might
be the limit.
   (3) means that the sequence does not converge, because you can
always find a value that is /smaller/ than what you hoped might
be the limit.

(4) means that for any sequence of reals (x_n ∈ dom f) converging
towards x0, we have lim f(x_n) = y.  For this equation again, we
have the three cases above.


Suppose lim a_n = a , lim b_n = b, c_2n = a_n, c_2n+1 = b_n.

What is lim c_n ?


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: 0/0 1 == False

2008-01-12 Thread Cristian Baboi
On Sat, 12 Jan 2008 13:55:19 +0200, Kalman Noel  
[EMAIL PROTECTED] wrote:



Cristian Baboi:

Suppose lim a_n = a , lim b_n = b, c_2n = a_n, c_2n+1 = b_n.

What is lim c_n ?


If my intuition was of any importance here, it would claim that c_n
diverges, because if I roughly approximate c_n by the sequence c' =
⟨a,b,a,b,...⟩, then I note that c' oscillates, so c_n »roughly
oscillates«.

Kalman


You mean something like this x=a:b:x  ?


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Cristian Baboi
On Thu, 10 Jan 2008 19:38:07 +0200, Tillmann Rendel  
[EMAIL PROTECTED] wrote:



[EMAIL PROTECTED] wrote:
Although it could be argued that laziness is the cause of some very  
obscure bugs... g Niko

 Example, PLEASE.


Prelude sum [1..100]
*** Exception: stack overflow


Not true in Hugs.


Prelude Data.List.foldl' (+) 0 [1..100]
5050

   Tillmann
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail  
Servers.

  part000.txt - is OK
http://www.eset.com





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Cristian Baboi
On Fri, 11 Jan 2008 09:16:12 +0200, Lennart Augustsson  
[EMAIL PROTECTED] wrote:



Thank you Duncan, you took the words out of my mouth. :)


On Jan 10, 2008 5:42 PM, Duncan Coutts [EMAIL PROTECTED]  
wrote:




So let's imagine:

ones = 1 : ones

ones' = repeat 1
 where repeat n = n : repeat n

So you're suggesting that:

ones == ones = True
but
ones' == ones' = _|_


Well if that were the case then  it is distinguishing two equal values
and hence breaking referential transparency. We can fairly trivially
prove that ones and ones' are equal so == is not allowed to distinguish
them. Fortunately it is impossible to write == above, at least using
primitives within the language.


If one can prove ones == ones = True with some method, why that method  
cannot be made to work on ones' ?


Are you thinking about repeat (f x) by any chance ?



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Cristian Baboi
On Fri, 11 Jan 2008 09:11:52 +0200, Lennart Augustsson  
[EMAIL PROTECTED] wrote:



Some people seem to think that == is an equality predicate.
This is a big source of confusion for them; until they realize that == is
just another function returning Bool they will make claims like  
[1..]==[1..]

having an unnatural result.
The == function is only vaguely related to the equality predicate in  
that it

is meant to be a computable approximation of semantic equality (but since
it's overloaded it can be anything, of course).


I think that confusion came from the fact that the type of  == is called  
(Eq a)= a - a - Bool and not (Bla a) = a - a - Binary and not  
realizing it's just an overloaded polimorphic function.





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Cristian Baboi
On Fri, 11 Jan 2008 09:11:52 +0200, Lennart Augustsson  
[EMAIL PROTECTED] wrote:



Some people seem to think that == is an equality predicate.
This is a big source of confusion for them; until they realize that == is
just another function returning Bool they will make claims like  
[1..]==[1..]

having an unnatural result.
The == function is only vaguely related to the equality predicate in  
that it

is meant to be a computable approximation of semantic equality (but since
it's overloaded it can be anything, of course).




So let's imagine:

ones = 1 : ones

ones' = repeat 1
 where repeat n = n : repeat n


(==) :: Eq a = a - a - Bool

-- what is (y (y) ) by the way ?
-- how about ( y id ) ?

y f = f (y f).

ones :: Num a = [a]
ones = y (1 :)

repeat :: a - [a]
repeat = \n - y (n:)

ones' :: Num a = [a]
ones' = repeat 1 = (\n-y(n:)) 1 = y (1 : )

To be able to test them for equality, we must have Eq a.

So, the reason we cannot test them for equality is that we cannot test y  
(a : ) == y (a : ) where a == a is testable.





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Cristian Baboi
On Fri, 11 Jan 2008 13:29:35 +0200, Wolfgang Jeltsch  
[EMAIL PROTECTED] wrote:



Am Freitag, 11. Januar 2008 10:54 schrieb Wilhelm B. Kloke:

Wolfgang Jeltsch [EMAIL PROTECTED] schrieb:
 However, the fact that (0 / 0) == (0 / 0) yields False is quite  
shocking.
  It doesn?t adhere to any meaningful axiom set for Eq.  So I think  
that

 this behavior should be changed.  Think of a set implementation which
 uses (==) to compare set elements for equality.  The NaN behavior  
would
 break this implementation since it would allow for sets which contain  
NaN

 multiple times.

You forget, that the intention of NaN is denial of membership of any  
set of

numbers.


This doesn’t matter.  The Set data type I’m talking about would not know  
about

NaN and would therefore allow multiple NaNs in a set.


This is a good thing because one can define natural numbers with such sets  
:-)




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Cristian Baboi
On Fri, 11 Jan 2008 14:21:45 +0200, [EMAIL PROTECTED]  
wrote:



Ketil Malde:

Wolfgang Jeltsch:
However, the fact that (0 / 0) == (0 / 0) yields False is quite  
shocking.

It doesn’t adhere to any meaningful axiom set for Eq.


Tough luck, but that's how floating point works, and what the
numericalists know, and possibly even love (although I have my
doubts).  Sanitizing this behavior would make Haskell less usable for
real-world numerical problems.

As a compromise, what about an option to make NaN (and presumably the
infinities) cause an immediate exception?  (And, cetero censeo,
exceptions for Int overflow as well.)


People, you are monsters.
First, despite the *common, well known* truth that Haskell is not
Mathematics, this illusion seems to be extremely persistent! Haskell is
a victim -
no, some users are victims of its success as a formal language, not just
as a coding tool... They *want* to have Eq as they imagine the equality,
including the comparison between incomparable. This is BTW a long  
standing
philosophical problem. For centuries some speculative guys tried to  
analyse

such assertions as God == God, or death==death. Or myself==myself.
Of course, even if they produced some cute conclusions, they had no
whatsoever sense for the others. Now we have the modern variants of it:
NaN == NaN, bottom == bottom ...


Well, Haskell has this referential transparency thing which say that a  
function is a function and you will never be able to build anything else  
:-)






 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-11 Thread Cristian Baboi

The thing is that y already is a *builtin* function in Haskell.

On Fri, 11 Jan 2008 15:59:50 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Cristian Baboi [EMAIL PROTECTED] wrote:




 So let's imagine:

 ones = 1 : ones

 ones' = repeat 1
  where repeat n = n : repeat n

(==) :: Eq a = a - a - Bool

-- what is (y (y) ) by the way ?
-- how about ( y id ) ?

y f = f (y f).

ones :: Num a = [a]
ones = y (1 :)

repeat :: a - [a]
repeat = \n - y (n:)

ones' :: Num a = [a]
ones' = repeat 1 = (\n-y(n:)) 1 = y (1 : )

To be able to test them for equality, we must have Eq a.

So, the reason we cannot test them for equality is that we cannot
test y (a : ) == y (a : ) where a == a is testable.


Yes, thanks. I actually do think that many things would be easier if
every recursion would be translated to its fixpoint, making the term
tree completely finite and defining y internal, as it's arcane, black
magic.






 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Cristian Baboi

On Thu, 10 Jan 2008 10:22:03 +0200, Mitar [EMAIL PROTECTED] wrote:


Hi!

Why is 0/0 (which is NaN)  1 == False and at the same time 0/0  1 ==
False. This means that 0/0 == 1? No, because also 0/0 == 1 == False.

I understand that proper mathematical behavior would be that as 0/0 is
mathematically undefined that 0/0 cannot be even compared to 1.

There is probably an implementation reason behind it, but do we really
want such hidden behavior? Would not it be better to throw some kind
of an error?


Mitar


I think it's a bug.
Here is why:

let f = (\x - x/0) in f 0 == f 0

Referential transparency say that f 0 must equal to f 0, but in this case  
it is not. :-)






 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Cristian Baboi
On Thu, 10 Jan 2008 10:48:51 +0200, Benja Fallenstein  
[EMAIL PROTECTED] wrote:



Hi Mitar,

On Jan 10, 2008 9:22 AM, Mitar [EMAIL PROTECTED] wrote:

I understand that proper mathematical behavior would be that as 0/0 is
mathematically undefined that 0/0 cannot be even compared to 1.


My understanding is that common mathematical practice is that
comparing an undefined value to anything (including itself) always
yields false; x /= x is sometimes used to formalize x is
undefined.


Why let a = a in a /= a is not False ?



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Cristian Baboi
On Thu, 10 Jan 2008 10:48:51 +0200, Benja Fallenstein  
[EMAIL PROTECTED] wrote:



Hi Mitar,

On Jan 10, 2008 9:22 AM, Mitar [EMAIL PROTECTED] wrote:

I understand that proper mathematical behavior would be that as 0/0 is
mathematically undefined that 0/0 cannot be even compared to 1.


My understanding is that common mathematical practice is that
comparing an undefined value to anything (including itself) always
yields false; x /= x is sometimes used to formalize x is
undefined.


How about this:

f 1 = 1
f 2 = 2


f 3 /= f 3




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Cristian Baboi

and there is no such thing as the same bottom right ?

On Thu, 10 Jan 2008 11:13:05 +0200, Ketil Malde [EMAIL PROTECTED]  
wrote:



Cristian Baboi [EMAIL PROTECTED] writes:


I think it's a bug.
Here is why:

let f = (\x - x/0) in f 0 == f 0

Referential transparency say that f 0 must equal to f 0, but in this
case  it is not. :-)


I think you are wrong.  Referential transparency says that you can
replace any occurence of 'f 0' with another expression of the same
value, it does not say anything about the behaviour of (==).

-k





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Cristian Baboi

On Thu, 10 Jan 2008 11:23:51 +0200, Yitzchak Gale [EMAIL PROTECTED] wrote:


Cristian Baboi wrote:

and there is no such thing as the same bottom right ?



Yes and no.


Semantically, Yes and No is bottom ?



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Cristian Baboi

On Thu, 10 Jan 2008 10:22:03 +0200, Mitar [EMAIL PROTECTED] wrote:


Hi!

Why is 0/0 (which is NaN)  1 == False and at the same time 0/0  1 ==
False. This means that 0/0 == 1? No, because also 0/0 == 1 == False.

I understand that proper mathematical behavior would be that as 0/0 is
mathematically undefined that 0/0 cannot be even compared to 1.

There is probably an implementation reason behind it, but do we really
want such hidden behavior? Would not it be better to throw some kind
of an error?


NaN is not 'undefined'

(0/0) /= (0/0) is True
(0/0) == (0/0) is False

You can use these to test for NaN.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Cristian Baboi

On Fri, 11 Jan 2008 08:34:10 +0200, Don Stewart [EMAIL PROTECTED] wrote:


NaN is not 'undefined'

(0/0) /= (0/0) is True
(0/0) == (0/0) is False

You can use these to test for NaN.



You can also use isNaN :)

Prelude isNaN (1/0)
False
Prelude isNaN (0/0)
True


Not true in Hugs.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: US Homeland Security program language security risks

2008-01-06 Thread Cristian Baboi
On Sun, 06 Jan 2008 17:19:31 +0200, Daniel Fischer  
[EMAIL PROTECTED] wrote:



Am Sonntag, 6. Januar 2008 15:54 schrieb Achim Schneider:

Daniel Fischer [EMAIL PROTECTED] wrote:
 Am Sonntag, 6. Januar 2008 15:18 schrieb Andrew Coppin:
  Daniel Fischer wrote:
   Just because I don't know:
   what bugs would be possible in a language having only the
   instruction return ()
 
  Bug #1: You cannot write any nontrivial programs. ;-)

 That's not a bug, that's a feature.

That's an interesting task: Design a non-touring complete,
restricted language in which every expression is decidable, without
making the language unusable for usual programming problems.



I'm not a logician, but didn't Gödel prove that you couldn't express the
(full) arithmetic of natural numbers in such a language?
Of course it might be possible to express a sufficiently interesting  
part of

it, but I should be surprised.


Neither do I, but if you have non turing algorithms, maybe you could do it.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Consensus about databases / serialization

2008-01-02 Thread Cristian Baboi
I recommend you read Extending the database relational model to capture  
more meaning by E.F. Codd.



On Wed, 02 Jan 2008 13:50:46 +0200, Peter Verswyvelen [EMAIL PROTECTED]  
wrote:

As I'm a selfmade man, I never really studied relational databases in
detail. My intuition told me that the relational part was not really
suitable for the 3D data, 2D images, animation curves, state machines,  
and

other data I encountered in the videogame and animation business. I could
always get away with files, and for the applications I needed to deploy,
plugging in a couple of extra gigabytes of RAM and serializing the  
object

state to disk was more practical, cheaper and faster.


However, a couple of years ago I started studying computer science (I  
seem

to do the theory after the practice, weird behavior ;-) at the Open
University, and one of the exams I did was about databases. Initially  
this

course convinced me that databases are actually very nice, but the course
ended with a topic on object oriented databases, which were designed to  
make
storing data like 3D models, graphs, networks, and complex  
datastructures

more practical. Duh.


Since then, I did deploy a few commercial applications for customers  
using
databases, which worked fine for the typical simple/flat database  
data. I

hated embedding a dynamic untyped language like SQL, as much as I hated
embedding code in HTML or XML. IMHO it feels UGLY and unsafe. Regarding  
the
other popular data storage format - XML - I did use that a lot, but it  
seems

like going back to the stone ages, when hierarchical stores/databases got
invented (and ditched?)


Now, initially after an introduction to Microsoft's LINQ, and recently
having read a very brief overview of HAppS, it seems I'm not the only one
with those feelings.


Ouch, this introduction got way to long, sorry about that ;-)


Finally some practical questions:

.regarding Haskell and databases, the page
http://haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces
describes a few, but which are the ones that are stable and practical?  
Any

user experiences?

.HApps is not listed in the page above, because it does not use
databases? Is HApps reliable or experimental, and does it scale well? Any
success stories?

.regarding Haskell and serialization, I don't think that
implementing Read/Show is a good way for real serialization, so what  
other

options exist? I could find some libraries at
http://hackage.haskell.org/packages/archive/pkg-list.html#cat:Data, but
again which are the most practical and stable? When programming in  
C++/MFC
and C#/.NET, I tended to develop my own serialization frameworks because  
I

used that for many things, like logging commands to disk, performing
undo/redo, intra and inter process cut/copy/paste, save/load, etc.

.Regarding serialization, I'm kinda curious how ADTs and even  
GADTs
are stored and retrieved in a relational database? I guess it could be  
done

using BLOBs and serialization to ByteStrings, so bypassing a lot of the
database table structures?

.If I would want to experiment with say HAppS, the way I  
understand

it, I first would first have to study Scratch your boilerplate and
Template Haskell, and maybe some other language features? I'm still new  
to
Haskell, and the road to understanding all language elements and  
extensions
is very long, so sequentially learning it would be insane I guess. I  
have no
practical experience with TH, but I spent a long time trying to do  
aspect

oriented programming in C# without success, so TH looks uber to me.


Thanks a lot and best wishes for 2008?


Peter




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-31 Thread Cristian Baboi

It give Something.

On Mon, 31 Dec 2007 10:27:38 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Cristian Baboi [EMAIL PROTECTED] wrote:


How about

a :: Something
a = let x = x in x


:t a
would give (a - [a]), not Something, or am I mistaken?






 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-31 Thread Cristian Baboi

On Mon, 31 Dec 2007 10:40:13 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


It seems like you're trying to solve the halting problem.


I didn't know that.


Slurping any
infinite data structure makes your program perform rather badly, I'm
afraid.


What is infinite in let x = x in x ?

What I see is that I cannot prevent building of infinite data structures  
without investing some time to find a way.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-31 Thread Cristian Baboi

On Mon, 31 Dec 2007 10:59:28 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Achim Schneider [EMAIL PROTECTED] wrote:


Cristian Baboi [EMAIL PROTECTED] wrote:

 What is infinite in let x = x in x ?
  ^   ||
  |___/|
  \/


a = let x = x in x
is actually only quite verbose for
a = undefined,

the only difference being that undefined is a nicer _|_ than let x = x
in x.



I could have written this instead:

a :: Something
a = a

Which is nicer than undefined.





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-31 Thread Cristian Baboi

On Mon, 31 Dec 2007 11:14:39 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Cristian Baboi [EMAIL PROTECTED] wrote:




I could have written this instead:

a :: Something
a = a

Which is nicer than undefined.


[EMAIL PROTECTED] ~ % ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude let a = undefined
Prelude a
*** Exception: Prelude.undefined
Prelude let a = a
Prelude a
Interrupted.



nope, it isn't.


Well, it depends on what you think is nicer.
For me it looks shorter than undefined and it don't rely on the library.


And then
let a = a
is more defined than the other two... only the equation is _|_, not the
value that is assigned. Value that is equated? Term? Jonathan, please
beat me.


This is over my head.
If let a = a is more defined, then why (print a) won't stop ?



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-31 Thread Cristian Baboi

On Mon, 31 Dec 2007 11:14:39 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Cristian Baboi [EMAIL PROTECTED] wrote:


On Mon, 31 Dec 2007 10:59:28 +0200, Achim Schneider [EMAIL PROTECTED]
wrote:



I could have written this instead:

a :: Something
a = a

Which is nicer than undefined.



[EMAIL PROTECTED] ~ % ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
Loading package base ... linking ... done.
Prelude let a = undefined
Prelude a
*** Exception: Prelude.undefined
Prelude let a = a
Prelude a
Interrupted.



nope, it isn't.


If you try it again

Prelude a
*** Exception: Stack overflow



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-31 Thread Cristian Baboi

Nice! Thank you.

On Mon, 31 Dec 2007 12:56:42 +0200, Ryan Ingram [EMAIL PROTECTED]  
wrote:



On 12/30/07, Cristian Baboi [EMAIL PROTECTED] wrote:


Thank you.

data Something = This | S Something

ppp :: Something - String

ppp This = 
ppp (S x) = 'S':(ppp x)


How can I prevent one to pass  'let x = S x in x' to ppp ?



 {-# LANGUAGE GADTs, EmptyDataDecls #-}
data Z
data S a

data Something a where
This :: Something Z
S :: Something a - Something (S a)

ppp :: Something a - String
ppp This =  
ppp (S x) = 'S' : ppp x







 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Web server continued

2007-12-31 Thread Cristian Baboi
On Mon, 31 Dec 2007 14:36:02 +0200, Joost Behrends [EMAIL PROTECTED]  
wrote:



I forgot 2 things:


The distinction between '=' and '==' is much like in C, although mixing
them up is not so dangerous like in C. ':=' and '=' like in Wirth
languages would be nicer.



Strangely nobody reacted on this. That a=a+1 is an infinite recursion  
here


What is more strange is that a = a + 1 and a = 1 + a are somehow distinct.
The second give a stack overflow almost instanly, but the first don't.



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi

On Sat, 29 Dec 2007 21:12:21 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Try writing a program that makes me say hello world as many times as
you press my nose.


Be careful what you wish for. :-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sat, 29 Dec 2007 21:49:16 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 29 Dec 2007, at 5:01 AM, Cristian Baboi wrote:


By portable I mean: works on the same machine, with the same OS, but  
with different Haskell implementation.


Ah, you can't.  But, again, what are you trying to do?  Re-compiling  
your software for each implementation seems like a perfectly reasonable  
thing to do, given the differences between them.


Recompiling my software will not save a function created by the software  
at runtime.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 18:39:51 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 30 Dec 2007, at 10:14 AM, Cristian Baboi wrote:

On Sat, 29 Dec 2007 21:49:16 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 29 Dec 2007, at 5:01 AM, Cristian Baboi wrote:


By portable I mean: works on the same machine, with the same OS, but  
with different Haskell implementation.


Ah, you can't.  But, again, what are you trying to do?  Re-compiling  
your software for each implementation seems like a perfectly  
reasonable thing to do, given the differences between them.


Recompiling my software will not save a function created by the  
software at runtime.


Which is a different problem than the one solved by dynamic linking.   
Again, why do you want to do this?


I think they are not as different as you think they are.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 18:34:08 +0200, Daniel Fischer  
[EMAIL PROTECTED] wrote:



True, but again, what are you trying to do?


I've already did what I was trying to do.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] The semantics of constructor patterns

2007-12-30 Thread Cristian Baboi
In section 4.3.3., chapter 4: Structured types and the semantics of  
pattern-matching,  by S.Peyton Jones and Philip Wadler, there is this  
equation:


Eval[[\(s p1 p2 ... pt).E]] (s a1 a2 ...at) = Eval[[\p1 ... \pt.E]] a1 ...  
at


The text say:
To apply \(s p1 ... pt).E to an argument A we first evaluate A to find  
out what sort of object it is.
Finally, if A was built with the same constructor as the patern, then the  
first rule applies.


What I don't get it :

(s a1 a2 ... at) must be the value of A in the semantic domain. Let call  
that value a.
Then how can one know if a was built with (s a1 a2 ... at) and not with  
(egg b1 b2) ?





___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 19:10:44 +0200, Daniel Fischer  
[EMAIL PROTECTED] wrote:



Am Sonntag, 30. Dezember 2007 17:55 schrieb Cristian Baboi:

On Sun, 30 Dec 2007 18:34:08 +0200, Daniel Fischer

[EMAIL PROTECTED] wrote:
 True, but again, what are you trying to do?



I've already did what I was trying to do.



Congrats. How?


By talking with you.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 19:02:11 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 30 Dec 2007, at 10:54 AM, Cristian Baboi wrote:

On Sun, 30 Dec 2007 18:39:51 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 30 Dec 2007, at 10:14 AM, Cristian Baboi wrote:

On Sat, 29 Dec 2007 21:49:16 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 29 Dec 2007, at 5:01 AM, Cristian Baboi wrote:


By portable I mean: works on the same machine, with the same OS,  
but with different Haskell implementation.


Ah, you can't.  But, again, what are you trying to do?  Re-compiling  
your software for each implementation seems like a perfectly  
reasonable thing to do, given the differences between them.


Recompiling my software will not save a function created by the  
software at runtime.


Which is a different problem than the one solved by dynamic linking.   
Again, why do you want to do this?


I think they are not as different as you think they are.


I think they're very different --- dynamic libraries can be built by  
running the compiler, whatever you're asking for can't.


More generally, dynamic libraries are supported by every production- 
quality compiled language in existence; I know of no language that can  
do what you're asking for.


I think, again, that what you really want is a reason to discredit  
Haskell.


A simple question:

Can you write the value of x to a file where x = (1:x) ?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The semantics of constructor patterns

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 19:13:47 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 30 Dec 2007, at 11:10 AM, Cristian Baboi wrote:

In section 4.3.3., chapter 4: Structured types and the semantics of  
pattern-matching,  by S.Peyton Jones and Philip Wadler, there is this  
equation:


Eval[[\(s p1 p2 ... pt).E]] (s a1 a2 ...at) = Eval[[\p1 ... \pt.E]] a1  
... at


The text say:
To apply \(s p1 ... pt).E to an argument A we first evaluate A to find  
out what sort of object it is.
Finally, if A was built with the same constructor as the patern, then  
the first rule applies.


What I don't get it :

(s a1 a2 ... at) must be the value of A in the semantic domain. Let  
call that value a.
Then how can one know if a was built with (s a1 a2 ... at) and not with  
(egg b1 b2) ?


I suspect that s and egg are constructors, in which case their images  
are (by definition) mutually exclusive.


I have not seen that definition in the book.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 19:16:04 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



If you want help, you would have an easier time getting it if you came  
here with /programming/ problems.  Most of us enjoy programming quite a  
bit, and are eager to help with such, but this sort of thing is more of  
a distraction, really.



Thank you, but I don't need help with programming. I can do that myself.
The help I need is for understanding Haskell.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 19:19:11 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:


When you can convince me that continuing this discussion will be of use  
/to the Haskell community/, I will until then, goodbye.


I won't even try to do that.
Goodbye.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] The semantics of constructor patterns

2007-12-30 Thread Cristian Baboi
Thank you. The thing is that when talking about the semantic of Prolog,  
one can choose any set as the semantic domain to start, and then a reason  
is given for choosing the Herbrand universe.


On Sun, 30 Dec 2007 19:23:00 +0200, Benja Fallenstein  
[EMAIL PROTECTED] wrote:



Hi Cristian,

On Dec 30, 2007 6:10 PM, Cristian Baboi [EMAIL PROTECTED] wrote:

What I don't get it :

(s a1 a2 ... at) must be the value of A in the semantic domain. Let call
that value a.
Then how can one know if a was built with (s a1 a2 ... at) and not with
(egg b1 b2) ?


Because the semantic domain is chosen so that (s a1 a2 ... at) and
(egg b1 b2) are distinct objects.

More precisely, the domain corresponding to (for example) the type

data T = C1 T11 T12 | C2 T21 T22

should be isomorphic to the domain

[[T]] = lift (([[T11]] * [[T12]]) + ([[T21]] * [[T22]]))

where * is cartesian product, + is disjoint sum (e.g., X+Y = {(1,x) |
x in X} union {(2,y) | y in Y}, and 'lift' adds the bottom element to
the domain.

So here, C1 and C2 correspond to the two sides of the disjoint sum,
meaning you can tell them apart.

Hope that helps?

- Benja



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 20:00:05 +0200, Daniel Fischer  
[EMAIL PROTECTED] wrote:



Am Sonntag, 30. Dezember 2007 18:16 schrieb Cristian Baboi:


A simple question:

Can you write the value of x to a file where x = (1:x) ?



Not in finite time and space :)


I used the word 'value' by mistake.
A notation of the value of x.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 20:24:23 +0200, Daniel Fischer  
[EMAIL PROTECTED] wrote:



Am Sonntag, 30. Dezember 2007 19:04 schrieb Cristian Baboi:

On Sun, 30 Dec 2007 20:00:05 +0200, Daniel Fischer

[EMAIL PROTECTED] wrote:
 Am Sonntag, 30. Dezember 2007 18:16 schrieb Cristian Baboi:
 A simple question:

 Can you write the value of x to a file where x = (1:x) ?

 Not in finite time and space :)

I used the word 'value' by mistake.
A notation of the value of x.



I suppose
let x = 1:x in x
is not what you're after?


Yes! Can Haskell do the same ?

I mean this:

module Module where

a= let x=1:x in x

main = do something to write a (a notation for a) to file

The function must work if one change a to let x=2:x in x, let x=1:2:3:x  
and variations on the same theme.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi
On Sun, 30 Dec 2007 21:07:44 +0200, Daniel Fischer  
[EMAIL PROTECTED] wrote:



Am Sonntag, 30. Dezember 2007 19:31 schrieb Cristian Baboi:




I mean this:

module Module where

a= let x=1:x in x

main = do something to write a (a notation for a) to file

The function must work if one change a to let x=2:x in x, let x=1:2:3:x
and variations on the same theme.



Can Java, C?


I think most of us can write a C program that can print circular lists.



What do you mean by 'notation'?


I might have used the wrong word.
Can you write the NUMBER 1 on a piece of paper ?
I think you cannot. You must use some encoding for it.
The same thing with  let x = x in x.

How can one print numbers in Haskell ?
I don't understand.

When I say print (2+4), why 6 is printed and not 10 - 4 ?



Would
main = do
txt - readFile Module.hs
let definitions = parseModule txt
case lookup a definitions of
  Nothing - putStrLn No definition for a
  Just rhs - writeFile Notation.hs (prettyprint rhs)
satisfy you?


Yes, but there is a little problem with 'txt- readFile Module.hs and  
case lookup a ... '

You see, I don't know if I must print a or b.


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi

Thank you.

data Something = This | S Something

ppp :: Something - String

ppp This = 
ppp (S x) = 'S':(ppp x)


How can I prevent one to pass  'let x = S x in x' to ppp ?


On Sun, 30 Dec 2007 23:25:19 +0200, Chaddaï Fouché  
[EMAIL PROTECTED] wrote:



2007/12/30, Chaddaï Fouché [EMAIL PROTECTED]:

2007/12/30, Cristian Baboi [EMAIL PROTECTED]:
 A simple question:

 Can you write the value of x to a file where x = (1:x) ?

Yes, but you'll have to write it yourself, because Haskell can't
decide by itself that this value is infinite and try to print it with
a recursive definition, if it could do that, it could decide the
halting problem and that's not possible.


Sorry, I'll try to be more precise since Cristian is pretty sticky
with details when he can use them in its sense...

In the particular case of x = (1:x), it can be detected that the
structure is circular in memory and so infinite, but in the general
case (for example if you replace (1:x) by (1:f x)) it can't be decided
if the value is finite or infinite. You can't do a printer that do
what you want in Haskell itself but you could probably do it with a VM
or with compiler support, but it would be extremely tricky, also it
would _always_ use the running form, even if this form isn't the
optimal for storage (for example a filter of a huge list that results
in an empty list would take enormously more place than with a normal
printer).





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-30 Thread Cristian Baboi

How about

a :: Something
a = let x = x in x

  ppp a

On Mon, 31 Dec 2007 09:11:12 +0200, Cristian Baboi [EMAIL PROTECTED]  
wrote:



Thank you.

data Something = This | S Something

ppp :: Something - String

ppp This = 
ppp (S x) = 'S':(ppp x)


How can I prevent one to pass  'let x = S x in x' to ppp ?




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-29 Thread Cristian Baboi
On Sat, 29 Dec 2007 01:42:54 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



Here is how I want print to be in Haskell

print :: (a-b) - (a-b)

with print = id, but the following side effect:

- I want to call the print function today, and get the value tomorrow.


Sorry, simply couldn't resist:



Put a very long timing loop in the middle.


Well, that kind of loop won't work.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-29 Thread Cristian Baboi
On Sat, 29 Dec 2007 02:08:14 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:




How can one make portable dynamic libraries then ?


If by portable you mean, works on /both/ OSs, then GHC-specific should  
be portable enough for you...


By portable I mean: works on the same machine, with the same OS, but with  
different Haskell implementation.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-29 Thread Cristian Baboi
On Sat, 29 Dec 2007 13:01:44 +0200, Cristian Baboi  
[EMAIL PROTECTED] wrote:


On Sat, 29 Dec 2007 02:08:14 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:




How can one make portable dynamic libraries then ?


If by portable you mean, works on /both/ OSs, then GHC-specific should  
be portable enough for you...


By portable I mean: works on the same machine, with the same OS, but  
with different Haskell implementation.


I should have used compatible.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Sending bottom to his room

2007-12-29 Thread Cristian Baboi
In The Implementation of Functional Programming Languages by S.P. Jones,  
section 2.5.3, page 32 it is written:



Eval [[*]] a b = a x b
Eval [[*]] _|_ b = _|_
Eval [[*]] a _|_ = _|_

but in section 2.5.2 it is said that _|_ is an element of the value domain.
What business does it have on the left side of the '=' ?

Can you help me send him to his room ?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Sending bottom to his room

2007-12-29 Thread Cristian Baboi

Sorry, I think a and b are from the value domain.


On Sat, 29 Dec 2007 13:14:09 +0200, Cristian Baboi  
[EMAIL PROTECTED] wrote:


In The Implementation of Functional Programming Languages by S.P. Jones,  
section 2.5.3, page 32 it is written:



Eval [[*]] a b = a x b
Eval [[*]] _|_ b = _|_
Eval [[*]] a _|_ = _|_

but in section 2.5.2 it is said that _|_ is an element of the value  
domain.

What business does it have on the left side of the '=' ?

Can you help me send him to his room ?



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Sending bottom to his room

2007-12-29 Thread Cristian Baboi

On Sat, 29 Dec 2007 13:30:03 +0200, Luke Palmer [EMAIL PROTECTED] wrote:

On Dec 29, 2007 11:14 AM, Cristian Baboi [EMAIL PROTECTED]  
wrote:

In The Implementation of Functional Programming Languages by S.P. Jones,
section 2.5.3, page 32 it is written:


Eval [[*]] a b = a x b
Eval [[*]] _|_ b = _|_
Eval [[*]] a _|_ = _|_

but in section 2.5.2 it is said that _|_ is an element of the value  
domain.

What business does it have on the left side of the '=' ?


I don't know the book you're talking about, but I suspect that this is  
not
a definition of a function in a language, but rather the denotational  
semantics

for a function.


Yes. Eval is the thing that do that.


Just as mathematics is allowed to categorize all
turing machines
into two categories (those that halt and those that do not), even
though to actually
do this is impossible, so too can mathematics talk about what a function  
returns

when given _|_, even though it is impossible in general to know when
you actually
do have _|_ or you're just waiting for a value.


What confused me is the Eval seems to be defined by recursion, but maybe  
it is not.

It would have been clear if it was written

Eval [[*]] env = x where x is extended to handle _|_
The recursivity I was talking about is:

Eval([[\x.E]], env) a = Eval([[E]], env[x=a])
Eval([[E1 E2]],env) = Eval([[E1]],env) (Eval([[E2]],env))

It appears as if  lambda calculus is defined by lambda calculus.

These are equations that Eval must satisfy, but the text call '='  'define'

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Sending bottom to his room

2007-12-29 Thread Cristian Baboi

On Sat, 29 Dec 2007 16:01:51 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Cristian Baboi [EMAIL PROTECTED] wrote:


It appears as if  lambda calculus is defined by lambda calculus.




Yes. id (lambda calculus) = lambda calculus. You might try to point
back to yourself when being asked who you are to see the advantage of
this technique.



The next question is if id is well defined.
There is such a function ?
How many of them ?


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi

Thank you.

It sounds like a limit. xn -- x for n --  :-)

How can I get that maximal value when I start from a non maximal one ?

[1 .. ] and x=1:x are maximal ?


On Fri, 28 Dec 2007 11:21:36 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



How can I test that partial order in Haskell ?


You can't. It's kinda internal. More specifically, if you try to compute  
a value, which is not maximal in this order, you'll get an error or loop  
forever. But you still can use such values in your programs if you don't  
try to compute them. The point is, maximal values are the only  
interesting ones, and all others are just approximations.


In fact, you only have to worry about non-maximal values when you use  
recursion. The fundamental property of Haskell is that it computes the  
least fixed point. For example, if f maps (_|_) to (_|_), then let x =  
f x in x will evaluate to (_|_) - and you loop forever, see above.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 12:01:51 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



It sounds like a limit. xn -- x for n --  :-)


Yeah, that's right.


If xn is monotone, then I only have to worry when it is not bounded, right  
?



How can I get that maximal value when I start from a non maximal one ?


Not a problem. For example, const 1 maps each value (even (_|_)) to  
the maximal value 1.



[1 .. ] and x=1:x are maximal ?


Can you give me some examples of non maximal ones ?



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi

Thank you.

This is what I understand so far:

- the maximal values is what is usually called data
- the non maximal are what is usually   called code
- in functional languages one can be given non maximal values (code) as  
input


Is that right ?


On Fri, 28 Dec 2007 12:01:51 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



It sounds like a limit. xn -- x for n --  :-)


Yeah, that's right.


How can I get that maximal value when I start from a non maximal one ?


Not a problem. For example, const 1 maps each value (even (_|_)) to  
the maximal value 1.



[1 .. ] and x=1:x are maximal ?


Yes.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 12:01:51 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:




[1 .. ] and x=1:x are maximal ?


Yes.



How can a Haskell implementation recognize a maximal value ?

x=1:x for example.



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 12:03:04 +0200, apfelmus [EMAIL PROTECTED]  
wrote:



Cristian Baboi wrote:

 http://en.wikipedia.org/wiki/First-class_object
 The term was coined by Christopher Strachey in the context of  
“functions as first-class citizens” in the mid-1960's.[1]

 Depending on the language, this can imply:
1.  being expressible as an anonymous literal value
2.  being storable in variables
3.  being storable in data structures
4.  having an intrinsic identity (independent of any given name)
5.  being comparable for equality with other entities
6.  being passable as a parameter to a procedure/function
7.  being returnable as the result of a procedure/function
8.  being constructable at runtime
9.  being printable
10. being readable
11. being transmissible among distributed processes
12. being storable outside running processes
 I'll guess that 5,9,12 does not apply to Haskell functions.


Exactly, together with 10 and 11 (when the distributed processes are on  
different machines).


But there is good reason that those things can't be done in Haskell.  
With extensional equality (two functions are considered equal if they  
yield the same result on every possible argument) number 5 is  
undecidable.


I didn't know 5 as a number is undecidable :-)


Similarly, there cannot be functions



   print   :: (Int - Int) - String
   compile :: String - (Int - Int)

with

   compile . print = id


A  print  function based on an intensional representation (assembly,  
byte code, etc.) would have to distinguish extensionally equal functions



   print f ≠ print g   although   f = g



which is not allowed.


Ok. I understand that there cannot be pairs like (print,compile) above.
But I was told that compile (quality number 10), can be defined.

About print above, I do not intend to make a Haskell String from a Haskell  
function.

This is why I said something about mixing levels of abstractions.

More importantly, I don't quite understand your question. If you  
definitively need 9-12 for a practical problem at hand, then you may  
want to take a look at the functional language Clean


   http://clean.cs.ru.nl/

which is similar to Haskell but offers 9-12 in some form.


How can be Clean similar to Haskell and at the same time satisfy 9-12 ?
I tryed Clean. I like it very much.

I have some silly little problems with it:
- its only 32 bit
- it doesn't support Unicode
- I don't like those type adnotations. Look as ugly as Lisp () to me.
- it's not free
- the linux version seems abandoned.
- there are some issues with # expressions (let before) that I don't fully  
understand

- the IO seems easyer in Haskell than in Clean

Otherwise I like it better than Haskell.


In all other cases, an email thread is not a good (often not even  
successful) way to get a coherent world view on Haskell (or on  
something  else) since this necessarily involves nitpicking  
philosophical questions. In my experience, interrogating one person in  
real-time in audio and interrogating books are the best ways to do  
that.


In my experience, different people have different world views, and one  
cannot get that from books only.




Concerning books, maybe



   The Haskell Road to Logic, Maths and Programming
   http://www.cwi.nl/~jve/HR



is for you.


Thank you.


More books on



   http://haskell.org/haskellwiki/Books



You don't have to buy them, borrow them from a library.


I'l try borrow them when I'll be visiting Munich next year, but I don't  
think I'll have enough time to read them.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi

Here is how I want print to be in Haskell

print :: (a-b) - (a-b)

with print = id, but the following side effect:

- I want to call the print function today, and get the value tomorrow.



On Fri, 28 Dec 2007 12:03:04 +0200, apfelmus [EMAIL PROTECTED]  
wrote:



Cristian Baboi wrote:

 http://en.wikipedia.org/wiki/First-class_object
 The term was coined by Christopher Strachey in the context of  
“functions as first-class citizens” in the mid-1960's.[1]

 Depending on the language, this can imply:
1.  being expressible as an anonymous literal value
2.  being storable in variables
3.  being storable in data structures
4.  having an intrinsic identity (independent of any given name)
5.  being comparable for equality with other entities
6.  being passable as a parameter to a procedure/function
7.  being returnable as the result of a procedure/function
8.  being constructable at runtime
9.  being printable
10. being readable
11. being transmissible among distributed processes
12. being storable outside running processes
 I'll guess that 5,9,12 does not apply to Haskell functions.


Exactly, together with 10 and 11 (when the distributed processes are on  
different machines).


But there is good reason that those things can't be done in Haskell.  
With extensional equality (two functions are considered equal if they  
yield the same result on every possible argument) number 5 is  
undecidable. Similarly, there cannot be functions


   print   :: (Int - Int) - String
   compile :: String - (Int - Int)

with

   compile . print = id

A  print  function based on an intensional representation (assembly,  
byte code, etc.) would have to distinguish extensionally equal functions


   print f ≠ print g   although   f = g

which is not allowed.



Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail  
Servers.

  part000.txt - is OK
http://www.eset.com





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
But I guess it won't work because the compiler will optimize it and the  
call will disappear.



On Fri, 28 Dec 2007 14:58:53 +0200, Cristian Baboi [EMAIL PROTECTED]  
wrote:



Here is how I want print to be in Haskell

print :: (a-b) - (a-b)

with print = id, but the following side effect:

- I want to call the print function today, and get the value tomorrow.





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 15:29:00 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



 take 5 [1,2,3,4,5,undefined]
(What would GHCi print?


[1,2,3,4,5]


Then please square that with your comment that we don't care how much of
the list gets evaluated.)


I don't care if it evaluates it, reads it's answer from some internal  
table, or consult it's lawyer. I just want it to agree with my reasoning  
about complete partial orders; that's all I need. I don't know how to  
explain this clearer.


This purity of Haskell will allways interfere with practical matters that  
cannot be described in Haskell.






 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 16:10:15 +0200, Jules Bean [EMAIL PROTECTED]  
wrote:



It won't work because haskell functions can't have side-effects.

I'm not quite sure what you're trying to say here.

Jules



What I am trying to say is:
- storing something to disk does not mean one must have a function to  
convert that something to a Haskell String
- I want to be able to use a function defined in one process in other  
process even if the two does not run at the same time




Cristian Baboi wrote:
But I guess it won't work because the compiler will optimize it and the  
call will disappear.
  On Fri, 28 Dec 2007 14:58:53 +0200, Cristian Baboi  
[EMAIL PROTECTED] wrote:



Here is how I want print to be in Haskell

print :: (a-b) - (a-b)

with print = id, but the following side effect:

- I want to call the print function today, and get the value tomorrow.



   Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail  
Servers.

 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail  
Servers.

  part000.txt - is OK
http://www.eset.com





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 16:34:23 +0200, apfelmus [EMAIL PROTECTED]  
wrote:



Jules Bean wrote:

Cristian Baboi wrote:

But I guess it won't work because the compiler will optimize it
and the call will disappear.


I'm not quite sure what you're trying to say here.


(That's the world view on Haskell issue I mean. I know this feeling  
with physics: what the heck are they talking about, this is just  
mathematically wrong, ill-defined or otherwise void of contents?)



Let me ask you 3 simple questions.
Can one use Haskell to make dynamically linked libraries (DLL on Windows,  
so on Linux) ?


If yes, what is in them ?
If not, why not ?



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 18:32:05 +0200, Jules Bean [EMAIL PROTECTED]  
wrote:



Cristian Baboi wrote:

Let me ask you 3 simple questions.
Can one use Haskell to make dynamically linked libraries (DLL on  
Windows, so on Linux) ?


The short answer is yes.


The long answer is that this is not a feature of haskell, but rather a  
feature of certain programs, which happen to be mostly but not entirely  
written in haskell, in particular, the haskell compiler. GHC can produce  
dynamically linked libraries.


What you choose not to notice is the context in which I asked these  
questions.

The context is: Haskell functions as first-class objects.
What I am interested in the first place is dynamically linked libraries  
written in Haskell and used in Haskell.

The interface with other languages like C come second.


 If yes, what is in them ?



Object code, mostly. Sometimes a little data.


What is the definition of an entry point in Haskell ?
What is the semantics of those entry points ?


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi

On Fri, 28 Dec 2007 18:27:29 +0200, Achim Schneider [EMAIL PROTECTED] wrote:


Wolfgang Jeltsch [EMAIL PROTECTED] wrote:


Am Freitag, 28. Dezember 2007 07:49 schrieben Sie:
 On Thu, 27 Dec 2007 18:19:47 +0200, Wolfgang Jeltsch
 [EMAIL PROTECTED] wrote:
  Am Donnerstag, 27. Dezember 2007 16:34 schrieb Cristian Baboi:
  I'll have to trust you, because I cannot test it.
 
  let x=(1:x); y=(1:y) in x==y .
 
  I also cannot test this:
 
  let x=(1:x); y=1:1:y in x==y
 
  In these examples, x and y denote the same value but the result
  of x == y is _|_ (undefined) in both cases.  So (==) is not
  really equality in Haskell but a kind of weak equality: If x
  doesn’t equal y, x == y is False, but if x equals y, x == y might
  be True or undefined.

 Thank you.

 I can only notice that y always has an even number of 1, which is
 not the case for x :-)

Both have an infinite number of 1.  Why do you say “always”?  It
seems that you think of x and y as “variables” whose values change
over time.  This is not the case.  They both have a single value for
all time: the infinite list consisting only of 1.



Does that then mean that
[1] = [1,1]


No. If you try to learn Haskell don't listen to  me. :-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Wikipedia on first-class object

2007-12-28 Thread Cristian Baboi
On Fri, 28 Dec 2007 19:18:33 +0200, ChrisK [EMAIL PROTECTED]  
wrote:



This thread is obviously a source of much fun.  I will play too.


Well, it starts with Wikipedia ... :-)



What is the definition of an entry point in Haskell ?


Haskell does not have such a concept.  At all.  An implementation may  
have

such a concept.


Then a Haskell module know nothing about them.

Most people on this list define Haskell as any attempt at an  
implementation of
one of the standards which define Haskell, most recently the Hakell 98  
standard.


This can be nhc / yhc / ghc / hugs / winhugs / helium / jhc.  Some of  
these
compile to native code, some compile to byte code for a virtual  
machine.  If an
implementation can compile separately, then it might support dynamic  
libraries.

 If so then a specific version of that compiler will define its own
implementation specific concept of an entry point.


How can one make portable dynamic libraries then ?


What is the semantics of those entry points ?



It depends.  For recent ghc versions, see its user manual:
http://haskell.org/ghc/docs/latest/html/users_guide/ffi-ghc.html#ffi-library
http://haskell.org/ghc/docs/latest/html/users_guide/win32-dlls.html


The conclusion:

Portable Haskell Dynamic libraries does not exists.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Function Stores

2007-12-28 Thread Cristian Baboi

Here is what I was able to come up with:


module Store where

data FStore1 a b  = Empty1 | FS1 ( a-b , FStore1 a b )

store1 :: (a-b) - (FStore1 a  b)
store1 f = let x = FS1 (f, x) in x

data FStore2 a b = Empty2 | FS2 ( a-b , FStore2 a b, FStore2 a b )

store2 :: (a-b) - (FStore2 a b)
store2 f = let x = FS2 (f,x,x) in x


First I tryed store1, but after a while it went out of business.
Second I tryed other business model with store2. Same result.

Then I tryed to make a street of stores.
After a while, they all went out of business.

Then I tryed to make several streets of stores.
After a while they all went out of business.

Then I tryed to make an infinite street of stores.
After a while they all went out of business.

Then, following some rumors that there is a store on that street with some  
function in stock that might be willing to give it away, I noticed that  
the street disappeared, and I cannot go to that store.


Can you help me find it ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Fwd: Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi



--- Forwarded message ---
From: Cristian Baboi [EMAIL PROTECTED]
To: Yitzchak Gale [EMAIL PROTECTED]
Cc:
Subject: Re: [Haskell-cafe] Wikipedia on first-class object
Date: Thu, 27 Dec 2007 12:21:44 +0200

I think I found the answer to why functions cannot be written to files.

This is by design. Haskell must be free.
Enabling writing functions to files, might make it ilegal in some
countries. :-)


On Thu, 27 Dec 2007 11:10:21 +0200, Yitzchak Gale [EMAIL PROTECTED] wrote:


Like any type, only certain operations make
sense on functions. Strings can be compared to each
other for equality and written to a disk, and you
can take the logarithm of a float, but none of those
operations make sense for functions. In particular,
two functions are equal only if they produce
the same value for every input, and in general it is
impossible for a computer to check that.

-Yitz


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail  
Servers.

  part000.txt - is OK
http://www.eset.com





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
Thinking about files and types, I recalled that in Pascal files must have  
types.



On Thu, 27 Dec 2007 12:40:22 +0200, Yitzchak Gale [EMAIL PROTECTED] wrote:

I'm not sure that in Haskell one can say that storing a value of some  
type

to disk is an operation defined on that type.


It is. For example:

hPutStr :: Handle - String - IO ()

The result type of this function is IO (), which means an
IO action. In this case, the semantics of the action are
that, when performed, it writes the bytes into a file.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi

On Thu, 27 Dec 2007 14:37:51 +0200, Yitzchak Gale [EMAIL PROTECTED] wrote:


I wrote:

Like any type, only certain operations make
sense on functions...


Yes, but one can store the result of an operation to disk except in  
the

particular case the result happen to be a function.



No, you can only store the result of an operation to
disk in the particular case that the result type represents
a list of bytes. Otherwise, you have to serialize it first...
But it is not clear at all how you could define a general
serialization method for functions.



Isn't that confusing levels of abstractions ?
Of course functions are bytes, 'cause they are already stored as bytes  
in

RAM.


That is just the point. A function in Haskell is an abstraction,
not bytes in RAM.

The compiler might implement the same function in several places,
with different bytes in each place. Or it might decide to combine it
into other functions, and not store any bytes in RAM at all for this
function.

The function itself represents a way of doing a calculation. It is not an
object that can do the calculation.



I think you try to say that the time cannot be stored.



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi

On Thu, 27 Dec 2007 14:37:51 +0200, Yitzchak Gale [EMAIL PROTECTED] wrote:



I wrote:

Like any type, only certain operations make
sense on functions...


Yes, but one can store the result of an operation to disk except in  
the

particular case the result happen to be a function.



No, you can only store the result of an operation to
disk in the particular case that the result type represents
a list of bytes. Otherwise, you have to serialize it first...
But it is not clear at all how you could define a general
serialization method for functions.



Isn't that confusing levels of abstractions ?
Of course functions are bytes, 'cause they are already stored as bytes  
in

RAM.



That is just the point. A function in Haskell is an abstraction,
not bytes in RAM.



The compiler might IMPLEMENT the same function in several places,
with different bytes in each place. Or it might decide to combine it
into other functions, and not store any bytes in RAM at all for this
function.


See ?


The function itself represents a way of doing a calculation. It is not an
object that can do the calculation.


Then trees of functions are ...


I'm not sure that in Haskell one can say that storing a value
of some type to disk is an operation defined on that type.



It is. For example:
hPutStr :: Handle - String - IO ()



And this is a property of the type String ?
The function hPutStr appears in the definition of the type String ?



Ah, you are thinking of operation on a type in the OOP sense.
Sorry, I wasn't clear. When I said only certain operations make
sense on each type, I just meant that there are only certain
things you can do with the type. In Haskell, the things you can
do with a type are the functions you can define that mention that
type in their signature.


How can one define in the language STORAGE of things ?
Storage of numbers for example ?
You said that the TYPE of a function forbids me somehow to store it in a  
file.
Now I understand that not the type forbids me, but the lack of a function  
with apropriate types.






 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 14:02:36 +0200, Lennart Augustsson  
[EMAIL PROTECTED] wrote:



Comparing functions is certainly possible in Haskell, but there's no
standard function that does it.
If course, it might not terminate, but the same is true for many other
comparable objects in Haskell, e.g., infinite lists (which are  
isomorphic to

Nat-T).


The list [1 .. ] is a single value in Haskell ?




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Fwd: Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi


How about x below:

let x=(1:x) in x ?

Is x a single value in Haskell ?

--- Forwarded message ---
From: Cristian Baboi [EMAIL PROTECTED]
To: Lennart Augustsson [EMAIL PROTECTED]
Cc: haskell-cafe@haskell.org haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] Wikipedia on first-class object
Date: Thu, 27 Dec 2007 16:08:58 +0200

On Thu, 27 Dec 2007 14:02:36 +0200, Lennart Augustsson
[EMAIL PROTECTED] wrote:


Comparing functions is certainly possible in Haskell, but there's no
standard function that does it.
If course, it might not terminate, but the same is true for many other
comparable objects in Haskell, e.g., infinite lists (which are  
isomorphic to

Nat-T).


The list [1 .. ] is a single value in Haskell ?




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 14:42:37 +0200, Bulat Ziganshin  
[EMAIL PROTECTED] wrote:



Hello Cristian,

Thursday, December 27, 2007, 12:19:08 PM, you wrote:


Yes, but one can store the result of an operation to disk except in the
particular case the result happen to be a function.



how can values of type T be saved to disk?


I don't know. I'm a beginner in Haskell, and I down't know about T.
You mean they cannot ?
I was under the impression that the purpose of computers cannot be  
fulfiled if we cannot get the result of computations out of the computers.







 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
Good to know. I intended to use Haskell for algorithms, but it seems it is  
not so good at them.



On Thu, 27 Dec 2007 17:52:19 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 27 Dec 2007, at 9:47 AM, Cristian Baboi wrote:





I don't know. I'm a beginner in Haskell, and I down't know about T.
You mean they cannot ?
I was under the impression that the purpose of computers cannot be  
fulfiled if we cannot get the result of computations out of the  
computers.


Haskell is not a computer programming language; Haskell  
implementations are not required to run on computers.  Haskell is a  
formal notation for computation (completely unrelated to the Von  
Neuman machine sitting on your desk).  It can be implemented on Von  
Neuman machines, because they are still universal Turing machines,  
but it is /not/ a radical attack on the problem of programming  
peripherals!


I suppose it can run on pebbles.


Any language can be emulated on pebbles; unlike most languages,  
Haskell can be compiled directly to them.


jcc


I know, and in this case one doesn't need IO.
The result is a nice collection of asorted pebbles.


Which is why Haskell treats IO as a domain specific language.

jcc





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 16:50:10 +0200, Lennart Augustsson  
[EMAIL PROTECTED] wrote:



Absolutly.  Every expression in Haskell denotes a value.
Now, we've not agreed what value means, but to me it is a value. :)


It is one value, or several ?


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[4]: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 16:12:04 +0200, Bulat Ziganshin  
[EMAIL PROTECTED] wrote:



Hello Cristian,

Thursday, December 27, 2007, 3:51:17 PM, you wrote:

Yes, but one can store the result of an operation to disk except in  
the

particular case the result happen to be a function.



how can values of type T be saved to disk?



I don't know.
I'm a beginner in Haskell, and I down't know about T.



here T is any type. you said that values of ANY TYPE can be saved to
disk, so show us the way


The way is toward west.

I said except functions. I'll add instances of IO.



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi

I'll have to trust you, because I cannot test it.

let x=(1:x); y=(1:y) in x==y .

I also cannot test this:

let x=(1:x); y=1:1:y in x==y





On Thu, 27 Dec 2007 17:29:12 +0200, Lennart Augustsson  
[EMAIL PROTECTED] wrote:



One value.  One infinite value.

On Dec 27, 2007 3:53 PM, Cristian Baboi [EMAIL PROTECTED] wrote:


On Thu, 27 Dec 2007 16:50:10 +0200, Lennart Augustsson
[EMAIL PROTECTED] wrote:

 Absolutly.  Every expression in Haskell denotes a value.
 Now, we've not agreed what value means, but to me it is a value. :)

It is one value, or several ?


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail  
Servers.

 part000.txt - is OK
http://www.eset.com





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail  
Servers.

  part000.txt - is OK
  part001.htm - is OK
http://www.eset.com





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi




I don't know. I'm a beginner in Haskell, and I down't know about T.
You mean they cannot ?
I was under the impression that the purpose of computers cannot be  
fulfiled if we cannot get the result of computations out of the  
computers.


Haskell is not a computer programming language; Haskell  
implementations are not required to run on computers.  Haskell is a  
formal notation for computation (completely unrelated to the Von  
Neuman machine sitting on your desk).  It can be implemented on Von  
Neuman machines, because they are still universal Turing machines, but  
it is /not/ a radical attack on the problem of programming peripherals!


I suppose it can run on pebbles.


Any language can be emulated on pebbles; unlike most languages, Haskell  
can be compiled directly to them.


jcc


I know, and in this case one doesn't need IO.
The result is a nice collection of asorted pebbles.



 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 17:39:25 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 27 Dec 2007, at 6:51 AM, Cristian Baboi wrote:

On Thu, 27 Dec 2007 14:42:37 +0200, Bulat Ziganshin  
[EMAIL PROTECTED] wrote:



Hello Cristian,

Thursday, December 27, 2007, 12:19:08 PM, you wrote:

Yes, but one can store the result of an operation to disk except in  
the

particular case the result happen to be a function.



how can values of type T be saved to disk?


I don't know. I'm a beginner in Haskell, and I down't know about T.
You mean they cannot ?
I was under the impression that the purpose of computers cannot be  
fulfiled if we cannot get the result of computations out of the  
computers.


Haskell is not a computer programming language; Haskell implementations  
are not required to run on computers.  Haskell is a formal notation for  
computation (completely unrelated to the Von Neuman machine sitting on  
your desk).  It can be implemented on Von Neuman machines, because they  
are still universal Turing machines, but it is /not/ a radical attack on  
the problem of programming peripherals!


I suppose it can run on pebbles.


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 18:45:23 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



On 27 Dec 2007, at 9:57 AM, Cristian Baboi wrote:

Good to know. I intended to use Haskell for algorithms, but it seems it  
is not so good at them.


Very sad.  The entire point of Haskell is that it allows the user to  
transcend the algorithm as a way of expressing computations.


I hope someday you may understand Haskell, rather than just criticizing  
it.


I'm begining to understand it. Criticizing it's just a tehnique to allow  
me to understand it better.


This is what I understood:

- there is no distinction of data from functions. This seem more like a  
matter of definiton: what I call X, the X + Y or just X.


- functions can be manipulated the same way as data. This does not sound  
right.


- functions can be manipulated as easy as data. This seems better.

- functional programming is declarative. One may take a picture of all  
those pebbles, but their arrangemant does not make sense to him because no  
part of it resemble the original description.


- one cannot print things that cannot be traversed in a sequential way

The last two seems to be in contradiction.







 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 18:13:57 +0200, Wolfgang Jeltsch  
[EMAIL PROTECTED] wrote:



Am Donnerstag, 27. Dezember 2007 16:57 schrieb Cristian Baboi:

On Thu, 27 Dec 2007 17:52:19 +0200, Jonathan Cast
 Which is why Haskell treats IO as a domain specific language.

Good to know. I intended to use Haskell for algorithms, but it seems it  
is

not so good at them.



Why is I/O needed for algorithms?


And the fact that I/O is embedded into Haskell as a kind of a domain  
specific
language doesn’t mean that Haskell is bad at I/O.  As Simon Peyton Jones  
put

it: Haskell is the world’s finest imperative programming language.



An algorithm is a finite recipe that allow one to solve a class of  
problems in a mechanical way.

To be able to use the algorithm one must be able to read it.
To be able to communicate the algorithm, one must be able to write it.

When I mentioned that IO is not needed for pebbles, I was joking.


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 18:14:53 +0200, Wolfgang Jeltsch  
[EMAIL PROTECTED] wrote:



Am Donnerstag, 27. Dezember 2007 15:53 schrieb Cristian Baboi:

On Thu, 27 Dec 2007 16:50:10 +0200, Lennart Augustsson

[EMAIL PROTECTED] wrote:
 Absolutly.  Every expression in Haskell denotes a value.
 Now, we've not agreed what value means, but to me it is a value. :)

It is one value, or several ?



It is one value with parts that are values themselves.


It is one value or a SET of values ?
What are the parts ?





 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 18:19:47 +0200, Wolfgang Jeltsch  
[EMAIL PROTECTED] wrote:



Am Donnerstag, 27. Dezember 2007 16:34 schrieb Cristian Baboi:

I'll have to trust you, because I cannot test it.

let x=(1:x); y=(1:y) in x==y .

I also cannot test this:

let x=(1:x); y=1:1:y in x==y


In these examples, x and y denote the same value but the result of x ==  
y is
_|_ (undefined) in both cases.  So (==) is not really equality in  
Haskell but

a kind of weak equality: If x doesn’t equal y, x == y is False, but if x
equals y, x == y might be True or undefined.


Thank you.

I can only notice that y always has an even number of 1, which is not the  
case for x :-)




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 17:35:54 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:



Only on Von Neuman machines.  Haskell implementations are not required  
to run on Von Neuman machines.  That's why the language is called  
functional.  (Imperative languages, by contrast, are just abstractions  
of the underlying Von Neuman architecture, which is probably the source  
of your confusion).


Can you tell me what is it that make a language imperative ?

When I learned about formal grammars and languages, there was no  
discussion about this.




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] Wikipedia on first-class object

2007-12-27 Thread Cristian Baboi
On Thu, 27 Dec 2007 17:39:25 +0200, Jonathan Cast  
[EMAIL PROTECTED] wrote:


Haskell is not a computer programming language; Haskell implementations  
are not required to run on computers.  Haskell is a formal notation for  
computation (completely unrelated to the Von Neuman machine sitting on  
your desk).  It can be implemented on Von Neuman machines, because they  
are still universal Turing machines, but it is /not/ a radical attack on  
the problem of programming peripherals!


How do you call that thing that implement Haskell ?




 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] CAF's in Haskell

2007-12-26 Thread Cristian Baboi
On Wed, 26 Dec 2007 17:16:22 +0200, Neil Mitchell [EMAIL PROTECTED]  
wrote:



Hi,

Are CAF's specified in the Haskell report? I couldn't find them  
mentioned.


If not, why do all Haskell compilers support them? Is there some paper
which persuaded everyone they were a good idea, or some reference I
could look up?


I found this in the wiki

http://www.haskell.org/haskellwiki/Constant_applicative_form

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Wikipedia on first-class object

2007-12-26 Thread Cristian Baboi

 http://en.wikipedia.org/wiki/First-class_object

The term was coined by Christopher Strachey in the context of “functions  
as first-class citizens” in the mid-1960's.[1]


Depending on the language, this can imply:
1.  being expressible as an anonymous literal value
2.  being storable in variables
3.  being storable in data structures
4.  having an intrinsic identity (independent of any given name)
5.  being comparable for equality with other entities
6.  being passable as a parameter to a procedure/function
7.  being returnable as the result of a procedure/function
8.  being constructable at runtime
9.  being printable
10. being readable
11. being transmissible among distributed processes
12. being storable outside running processes

I'll guess that 5,9,12 does not apply to Haskell functions.


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Printing and Referential transparency excuse

2007-12-25 Thread Cristian Baboi
On Tue, 25 Dec 2007 11:05:59 +0200, Derek Elkins  
[EMAIL PROTECTED] wrote:



On Mon, 2007-12-24 at 11:15 +0200, Cristian Baboi wrote:



How can I define a function to do the inverse operation ?
   g :: String - ( a - b )

This time I cannot see how referential transparency will deny it.
What's the excuse now ?


Referential transparency has nothing to with this.  The problem here is
parametricity.  However, if you give a non-parametric type (or add
appropriate class constraints on a and b, or add (phantom) type
information to the input), e.g. String - (Int - Int) then there is no
trouble at all.



Thank you.

I finished reading the Haskell Language Report and I noticed that the  
class Show and Read are toys.

I'll try to define some String - (a - b) functions some other time.

I wonder if parametricity is the only problem.
I guess that I'll have some problem with the arity of the result, but  
currying may help.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Printing and Referential transparency excuse

2007-12-24 Thread Cristian Baboi
While reading the Haskell language report I noticed that function type is  
not an instance of class Read.


I was told that one cannot define them as an instance of class Show  
without breaking referential transparency or printing a constant.


  f :: (a-b)-String
  f x = bla bla bla

How can I define a function to do the inverse operation ?
  g :: String - ( a - b )

This time I cannot see how referential transparency will deny it.
What's the excuse now ?

I'm at the begining of chapter 7, but I have the feeling I'll not find the  
answer in there.



Thank you.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Printing and Referential transparency excuse

2007-12-24 Thread Cristian Baboi
On Mon, 24 Dec 2007 11:27:11 +0200, apfelmus [EMAIL PROTECTED]  
wrote:



Cristian Baboi wrote:



 How can I define a function to do the inverse operation ?
  g :: String - ( a - b )
 This time I cannot see how referential transparency will deny it.
What's the excuse now ?


The new excuse is that a better name for  g  is



   full-fledged-compiler :: String - (Int - Int)


(the function returned by  g  better not have a polymorphic type). Which  
programming language should the argument  String  be written in?


Cobol, what else ?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi

Let me show you an example to prove it.
The example is limited to composition of unary functions defined on int
   u::Int-Int
   v::Int-Int
   o ::(Int-Int)-(Int-Int)-(Int-Int)
   o u v= \x-u(v(x))


#include stdio.h
#include conio.h

#include functional.h

int f1(int x){
return x+x;
}
int f2(int x){
return 2*x;
}
int g1(int x){
return x+1;
}
int g2(int x){
return x-1;
}

#define P1 P0 int main(){
#define P2 P1  printf(%d,%d,%d\n,2,
#define P3   O(f1,f2,P2)(2),
#define P4   O(g1,g2,P3)(3));
#define P5 P4  getch();
#define P6 P5 }

MAIN P6


Here is the file functional.h

#define FUNC2(x,y) x##y
#define FUNC1(x,y) FUNC2(x,y)
#define FUNC(x) FUNC1(x,__COUNTER__)

#define COMP(c,f,g,p) \
 int c (int x) { return f(g(x)); }; \
 p \
 c

#define O(f,g,p)  COMP( FUNC(a), f, g, p)

#define P0
#define MAIN

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 14:28:56 +0200, Paul Johnson [EMAIL PROTECTED]  
wrote:



Cristian Baboi wrote:

Let me show you an example to prove it.
This reminds me of arguments in the late 80s and early 90s that C could  
do OO programming via function pointers, so there was no need for OO  
languages.


What is Objective C ,if not just C with some syntactic sugar ?

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Fwd: Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi



--- Forwarded message ---
From: Cristian Baboi [EMAIL PROTECTED]
To: Jules Bean [EMAIL PROTECTED]
Cc:
Subject: Re: [Haskell-cafe] Functions are first class values in C
Date: Sat, 22 Dec 2007 15:58:50 +0200

On Sat, 22 Dec 2007 14:09:13 +0200, Jules Bean [EMAIL PROTECTED]
wrote:


Cristian Baboi wrote:

Let me show you an example to prove it.



That's not C.
That's the C preprocessor, which is a textual substitution macro  
language.


Well, the preprocessor is part of the language in a way. These two come
together.

Macros certainly aren't first class (you can't pass a macro to a  
function, only its expansion).


In Haskell I cannot pass a function to a function, only its expansion.

C does support function pointers, which are something like first class  
functions. The main things C lacks which people associate with true  
first-class function is:



The ability to construct anonymous/local functions.


If you look at the example you will see I've done that.

The ability to capture local variables and return a function with some  
variables bound.


If I can construct anonymous functions and constants, I can construct
functions with some variables bound.



The ability to write type-safe functions with polymorphic arguments.


I didn't know this must be a property of first-class functions.
C is staticaly typed, so type errors will be detected.


Haskell is just C with some syntactic sugar :-)


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 14:55:44 +0200, Peter Verswyvelen [EMAIL PROTECTED]  
wrote:


Before I knew Haskell, the OO community started to embrace the concept  
of interfaces more and more (aka purely abstract classes). Furthermore  
in OO, many bugs are caused IMO by keeping track of mutable state and  
caches (which is often premature optimization). So for complicated  
tasks, I tended to use more and more immutable objects, e.g. objects  
that could be constructed once, but not mutated. And then I noticed that  
it was often not needed to precompute all the values that got passed to  
the constructor, so I added C# properties that computed the inner  
cached values once, lazily.


Lazy constant in C:

int C1 (){
return 7;
}
C1 is computed only when you apply the operator () to it.

IMO Haskell embraces the above ideas and much more, with the difference  
it encapsulates these ideas nicely and concisely, so you need only a  
fraction of the lines of code :)


This is why we have syntactic sugar :)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 16:25:26 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



That's not C.
That's the C preprocessor, which is a textual substitution macro  
language.


Well, the preprocessor is part of the language in a way. These two come
together.



No. In fact, these are even two different programs, see man cpp.


These two different programs come together.

Macros certainly aren't first class (you can't pass a macro to a  
function, only its expansion).


In Haskell I cannot pass a function to a function, only its expansion.



What do you mean by expansion? Can you clarify this?


f1=\x-x+1
f2=\x-2*x
g=\x-x.f1
h=\x-x.(\x-x+1)

h is g

C does support function pointers, which are something like first class  
functions. The main things C lacks which people associate with true  
first-class function is:



The ability to construct anonymous/local functions.


If you look at the example you will see I've done that.


No. Your compose macro is not a function; for example, you can't use  
it as an argument to itself (which is easy in Haskell: (.)(.))


Ok.

The ability to capture local variables and return a function with some  
variables bound.


If I can construct anonymous functions and constants, I can  
construct

functions with some variables bound.


See above. You can't.


Ok.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 16:26:18 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



Lazy constant in C:

int C1 (){
return 7;
}
C1 is computed only when you apply the operator () to it.



But that's not the point of lazyness. Lazy value is computed only ONCE.


Ok. I guess I cannot be sure I'll call C1 only once.


How about this

int C1(){
static c1=-;
if(c1==-){
c1=7
}
return c1
}
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 16:55:08 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



In Haskell I cannot pass a function to a function, only its expansion.



What do you mean by expansion? Can you clarify this?


f1=\x-x+1
f2=\x-2*x
g=\x-x.f1
h=\x-x.(\x-x+1)

h is g


Not clear. Try starting with function's expansion is...



function's expansion is ... just like macro expansion.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Fwd: Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi



On Sat, 22 Dec 2007 16:48:51 +0200, Peter Verswyvelen [EMAIL PROTECTED]
wrote:


Cristian Baboi wrote

Lazy constant in C:
int C1 (){ return 7; }


Not really, this is not lazy, since it always recomputes the value 7.

To have lazy values in C you would have to do something like:

struct ValueInt
{
  int IsComputed;
  union
  {
int Value;
struct
{
   int (*ComputeValue)(void *args);
   void* Args;
};
  };
};

int GetLazyInt (ValueInt* v)
{
  if( !v-IsComputed )
  {
v-Value = v-ComputeValue(v-Args);
v-IsComputed = true;
  }
  return v-Value;
}

But this of course, is totally useless in C and very bulky. It's also  
impossible to know when to call freemem on the Args (hence garbage  
collection in FP), when *not* to use lazy values but strict values  
instead (hence strictness analysis in FP), etc...


I know FP have automatic garbage collection.
I know FP compilers use strictness analysis.

In C++ one can isolate memory management in constructors and destructors.
There are C compilers that are also able to do some optimizations.

I must say I had the same opinion as you had for many many years. I  
always thought functions as first class values where just function  
pointers, so what is it these Haskell/FP guys are so excited about? But  
if you dig deeper, you'll see the magic... Notice you will have to give  
yourself some time; it is very hard to get out of the imperative blob.  
E.g. I'm still being sucked into the imperative blob after my first year  
of Haskell hacking :)


PS: As I'm relatively new to Haskell, don't take the above C code too  
seriously; it certainly will not reflect the way a real Haskell system  
works.


I am new to Haskell, but not new to declarative programming. I programmed
in Prolog for several years, and I tryed LISP, but I don't liked the LISP
syntax.

I don't take my C example seriously either.
The thing is I think that for a language to have first-class functions,
it must be homoiconic if I understand the terms correctly.

Have you tryed to write a Haskell program that manipulate Haskell programs
?
Please don't tell me that Haskell compiler is written in Haskell, because
there are C compilers written in C.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 17:13:55 +0200, Philippa Cowderoy [EMAIL PROTECTED]  
wrote:




function's expansion is ... just like macro expansion.


No, it's not. Expanding variables (swapping f1 for \x-x+1) isn't the
evaluation mechanism in haskell, g and h really are semantically
equivalent values and we can't do actual computation just by expanding
variables. Whereas expanding a macro is equivalent to beta-reduction
(evaluating a function application), which isn't required before passing
something in Haskell. We pass functions, not just their results.

Here's a trivial example that does so:

(\x - x) (\x - x)

A lambda calculus classic that doesn't typecheck in Haskell:

(\x - x x) (\x - x x)



Feel free to try evaluating it!


Thank you for your message.

I tryed and this is what I've got:
ERROR - cannot find show function for:
*** Expression : (\x - x) (\x - x)
*** Of type: a - a


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Fwd: Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 17:18:18 +0200, Philippa Cowderoy [EMAIL PROTECTED]  
wrote:


The thing is I think that for a language to have first-class  
functions,

it must be homoiconic if I understand the terms correctly.



You're confusing functions with the terms that are used to define them.



The terms aren't first-class, the functions are. This is intentional: the
only way you can tell functions apart is if they give you different
results for the same parameter. Otherwise, what you have isn't a function
but a combination of a function and some extra structure.


I also confuse numbers with the terms that are used to define them (like  
1.2)


I guess I have to study more about this.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Functions are first class values in C

2007-12-22 Thread Cristian Baboi
On Sat, 22 Dec 2007 17:25:34 +0200, Philippa Cowderoy [EMAIL PROTECTED]  
wrote:



On Sat, 22 Dec 2007, Cristian Baboi wrote:

On Sat, 22 Dec 2007 17:13:55 +0200, Philippa Cowderoy  
[EMAIL PROTECTED]

wrote:

 Here's a trivial example that does so:

 (\x - x) (\x - x)

 A lambda calculus classic that doesn't typecheck in Haskell:

 (\x - x x) (\x - x x)

 Feel free to try evaluating it!

Thank you for your message.

I tryed and this is what I've got:
ERROR - cannot find show function for:
*** Expression : (\x - x) (\x - x)
*** Of type: a - a




Yep, that's because while it can evaluate it down to (\x - x) your
interpreter doesn't know how to print the result. You can demonstrate  
that

it works by then passing in something to that result though:

((\x -x) (\x - x)) 1


I know that.  The reason the interpreter doesn't know how to print the  
result is because converting functions to strings doesn't make sense.


Thank you.


You'll have to evaluate the other one by hand. Don't spend too long with
it though!


Don't worry, I'm lazy too :-)

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Cristian Baboi
On Tue, 18 Dec 2007 10:29:43 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



What I should have been told about upfront:
- the syntax for an expression
- the syntax for a block



Don't see your point.


The point is the syntax is introduced as transformation of layout form to  
non layout form.
As a user, I just want to be able to spot the basic components of a source  
file without thinking about transformation rules.



- the adhoc syntax rules (how to distinguish among a tuple and a
pharanthesized expression and how to find the start and end of a block  
for

example )


Oh, that's pretty easy, parenthesized expression is not divided by a  
comma.


Thanks! What is the end of a block ? What introduce new blocks ?
Is this legal (`plus`) x y ?
It's this a tuple ?  ([a,b,c,d ]) ?

etc.

- what guarantees are made by the LANGUAGE that an IO action (such as   
do

putStrLn Hello world ) is not performed twice


There are no such guarantees. If you write

a = putStrLn Hello world
main = do {a; a;}

then your putStrLn would be performed twice. IO actions are first-class  
values, that's a feature, not a bug.



What guarantees that by running the main, the string Hello world will be  
printed exactly twice ?



- the lambda expressions can be written (input) but cannot be printed
(output)



Yes, since two different lambda expressions can denote the same function.

I just want the sistem to be able to print one of these expressions !

Its this too much to ask ?
I find it very strange that I can write a lambda expresion, but the system  
cannot.



No, pattern matching bounds variables; if you write case x of {aa -  
...} then aa becomes a LOCAL variable for the case statement, and  
shadows the global definition. The same applies to u and v in h, except  
that in this case local variables shadow upper-level local variables.


Ok.


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: New to Haskell

2007-12-18 Thread Cristian Baboi
On Tue, 18 Dec 2007 11:56:36 +0200, Jon Fairbairn  
[EMAIL PROTECTED] wrote:



Cristian Baboi [EMAIL PROTECTED] writes:




- the syntax for a block


Not sure what you mean by block.

do a - [1..10]
   b - [3,4]
   return (a,b)

is an expression... you can write that same expression as
do {a - [1..10]; b - [3,4]; return (a,b)} too.



I mean anything that you can put between { }, and between ;



- the adhoc syntax rules (how to distinguish among a tuple
and a  pharanthesized expression



a tuple has commas in it. I'll grant that (x) not being a
1-tuple is a little ad-hoc, but there really is very little
ad-hockery in Haskell (and a 1-tuple behaves very much like
a plain value after all).


Is this ([1 ,2 ,3 ,4]) a tuple or what ?
It has commas in it!


- the fact that lambda expressions are not the same thing
as algebraic data values



It might help to know why you think they might be the same;
the syntax is different and the name is different...


Ah, just a thought, nothing more.
Lambda expressions are values, which is just data, after all.
Even C can apply a function variable to an argument (function pointers).



- what guarantees are made by the LANGUAGE that an IO action
(such as  do  putStrLn Hello world ) is not performed
twice



As has been pointed out, «do putStrLn Hello world» is an
expression that you can bind to a variable and use as many
times as you like. Incidentally, it means the same as
«putStrLn Hello World»; do connects a sequence of bindings
and expressions, so you don't need it if there's nothing to
be connected to.


Yes, but that was not the question.
What make you so sure it will be printed the exact number of times you  
intended ?



- the lambda expressions can be written (input) but cannot
be printed  (output)



This is a fundamental property of the language.  A lambda
expression is programme and at runtime the system doesn't
know one lambda expression from another (all it can do with
one is apply it to something).


Even C can apply a function variable to an argument (function pointers).
What make Haskell different beside the lazy evaluation and mutable  
variables things ?



The biggest problem for me, so far, is the last one.


I can't see how your example illustrates that, I'm afraid.


In a very strange way. Nevermind.


Here is some strange example:



What I don't understand is why I'm forced to use guards like
x==aa in cc,  when aa is clearly bounded (is 7) and why in
function h, the bounded u and  v become free variables in
the case expression.



I would have liked the language design to have permitted
case to pattern match against variables too, but the
question is, what would the syntax be?  There was a fair bit
of discussion about this when the language was designed (and
since), but no-one could come up with a good way of doing
it. One aspect of it is this: we want



f 0 = 42
f x = 3*x

to work, and we want all function definitions to be
translated into the core language in the same way,
so you get
f = \a - case a of
0 - 42
x - 3*x

and given that, you can't have a variable on the LHS of -
do anything other than get bound to the value of the
expression in the case (a in the example). It's not just a
the top level, either:

f Nothing = 0
f (Just n) = n+1

just means
f = \v - case v of
Nothing - 0
Just n - n+1

so you can't have variables inside constructors do anything
but get bound at that point.





Thank you very much!


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Cristian Baboi
On Tue, 18 Dec 2007 12:25:18 +0200, Miguel Mitrofanov  
[EMAIL PROTECTED] wrote:



 - the syntax for an expression
 - the syntax for a block
 Don't see your point.
The point is the syntax is introduced as transformation of layout form  
to

non layout form.
As a user, I just want to be able to spot the basic components of a  
source

file without thinking about transformation rules.



Well, most users are.

Are what ?

Able to spot or thinking about ...
Have you asked them all ?



Is this legal (`plus`) x y ?


Never tried to write this myself, it looks stupid.


What else haven't you tried to write by know ?

It's a kind of mirror, you know .



 then your putStrLn would be performed twice. IO actions are  
first-class

 values, that's a feature, not a bug.
What guarantees that by running the main, the string Hello world will  
be

printed exactly twice ?


What kind of guarantees do you want?


Written in blood.


I just want the sistem to be able to print one of these expressions !
Its this too much to ask ?


Yes, 'cause it means you want to embed almost all source code into the  
compiled program.


So ?


 Information from NOD32 
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
 part000.txt - is OK
http://www.eset.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


  1   2   >