Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread John Dorsey
Jules Bean wrote:

> I'm saying that we can change programs, and that changes their 
> denotation, and that's fine, and anyone can do that. But the denotation 
> of a program is supposed to be something independent of a particular 
> compiler or OS or MAC address or RAM size or any of the millions of 
> other things which probably don't change during the single run of a program.

And native Int size.  Should all Int's be in the IO Monad?
Should all floating point numerals be in the IO Monad?

Does your proposal push all non-portability into IO, making the
non-IO subset of Haskell a portable virtual machine specification?

Regards,
John

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Alexander Dunlap
On Tue, Oct 14, 2008 at 2:14 PM, Jules Bean <[EMAIL PROTECTED]> wrote:
> David Roundy wrote:
>>
>> On Tue, Oct 14, 2008 at 05:20:35PM +0100, Jules Bean wrote:
>>>
>>> Running a program on a different interpreter or compiler had better
>>> not change its denotation, otherwise it [the denotation] is not much
>>> use as a basis for reasoning.
>>
>> But you're saying above that we can't change programs, right? You
>> probably won't be surprised to hear that different compilers are
>> different programs.  And different packages are also different
>> programs.  Are you the only one who's allowed to fix bugs?
>
> No. I think we must be at cross purposes.
>
> I'm saying that we can change programs, and that changes their denotation,
> and that's fine, and anyone can do that. But the denotation of a program is
> supposed to be something independent of a particular compiler or OS or MAC
> address or RAM size or any of the millions of other things which probably
> don't change during the single run of a program.
>
> Putting these things into the IO monad is not an abuse of the IO monad. It
> is simply an acknowledgement that they are runtime things, and not
> denotational constructs.
>
>
> Jules
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

But they aren't runtime constructs, they are compile-time constructs,
just like how (+) has a different meaning when you are on Windows than
it does when you are on Linux: they have different ways of allocating
memory, adding two numbers, putting the result somewhere, etc. Really,
they still denote the same thing ("add two numbers"), they just
abstract over system-dependent details.

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Jules Bean

David Roundy wrote:

On Tue, Oct 14, 2008 at 05:20:35PM +0100, Jules Bean wrote:

Running a program on a different interpreter or compiler had better
not change its denotation, otherwise it [the denotation] is not much
use as a basis for reasoning.


But you're saying above that we can't change programs, right? You
probably won't be surprised to hear that different compilers are
different programs.  And different packages are also different
programs.  Are you the only one who's allowed to fix bugs?


No. I think we must be at cross purposes.

I'm saying that we can change programs, and that changes their 
denotation, and that's fine, and anyone can do that. But the denotation 
of a program is supposed to be something independent of a particular 
compiler or OS or MAC address or RAM size or any of the millions of 
other things which probably don't change during the single run of a program.


Putting these things into the IO monad is not an abuse of the IO monad. 
It is simply an acknowledgement that they are runtime things, and not 
denotational constructs.



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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Jason Dusek
Jonathan Cast <[EMAIL PROTECTED]> wrote:
> David Roundy wrote:
>> Jules Bean wrote:
>>> David Roundy wrote:
 How does it interact with fixing bugs (which means changing
 mathematical and universal constant functions--since all
 functions are constants)?
>>>
>>> That's fine. Changing a program changes it denotation.
>>>
>>> Running a program on a different interpreter or compiler had
>>> better not change its denotation, otherwise it [the
>>> denotation] is not much use as a basis for reasoning.
>>
>> But you're saying above that we can't change programs, right?
>> You probably won't be surprised to hear that different
>> compilers are different programs.
>
> This `problem' is already solved by the theory of logical
> relations.

  Could you say more about this?

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Jonathan Cast
On Tue, 2008-10-14 at 12:31 -0400, David Roundy wrote:
> On Tue, Oct 14, 2008 at 05:20:35PM +0100, Jules Bean wrote:
> > David Roundy wrote:
> >> On Tue, Oct 14, 2008 at 04:05:23PM +0100, Jules Bean wrote:
> >>> Constants are mathematical and universal, like pi. That is what the
> >>> semantics of haskell say.
> >>
> >> Where do the semantics of haskell say this? 
> >
> > You should better ask 'which semantics?'.
> >
> > The semantics in which a value of type "Int -> Int" is denoted by a
> > mathematical function from Int to Int. In that semantics a value of
> > type "Int" denotes a specific Int.  And that denotation is, of
> > course, entirely independent of compiler or OS or package or dynamic
> > loading or any concern like that.
> >
> > This is, to my mind the "often assumed but never written down"
> > semantics of haskell. It's certainly the semantics *I* want haskell
> > to have.
> >
> > > How does it interact with fixing bugs (which means changing
> > > mathematical and universal constant functions--since all functions
> > > are constants)?
> >
> > That's fine. Changing a program changes it denotation.
> >
> > Running a program on a different interpreter or compiler had better
> > not change its denotation, otherwise it [the denotation] is not much
> > use as a basis for reasoning.
> 
> But you're saying above that we can't change programs, right? You
> probably won't be surprised to hear that different compilers are
> different programs.

This `problem' is already solved by the theory of logical relations.

jcc


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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread David Roundy
On Tue, Oct 14, 2008 at 05:20:35PM +0100, Jules Bean wrote:
> David Roundy wrote:
>> On Tue, Oct 14, 2008 at 04:05:23PM +0100, Jules Bean wrote:
>>> Constants are mathematical and universal, like pi. That is what the
>>> semantics of haskell say.
>>
>> Where do the semantics of haskell say this? 
>
> You should better ask 'which semantics?'.
>
> The semantics in which a value of type "Int -> Int" is denoted by a
> mathematical function from Int to Int. In that semantics a value of
> type "Int" denotes a specific Int.  And that denotation is, of
> course, entirely independent of compiler or OS or package or dynamic
> loading or any concern like that.
>
> This is, to my mind the "often assumed but never written down"
> semantics of haskell. It's certainly the semantics *I* want haskell
> to have.
>
> > How does it interact with fixing bugs (which means changing
> > mathematical and universal constant functions--since all functions
> > are constants)?
>
> That's fine. Changing a program changes it denotation.
>
> Running a program on a different interpreter or compiler had better
> not change its denotation, otherwise it [the denotation] is not much
> use as a basis for reasoning.

But you're saying above that we can't change programs, right? You
probably won't be surprised to hear that different compilers are
different programs.  And different packages are also different
programs.  Are you the only one who's allowed to fix bugs?

I personally feel that it's a valuable feature that we're allowed to
implement distinct libraries with a shared API, which is a feature
that you claim violates the semantics you want haskell to have.

I would say that putting constants that are known at compile time into
the IO monad is an abuse of the IO monad, since those constants have
nothing to do with IO, and are in fact *constants* which cannot vary
at run time.

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Jules Bean

David Roundy wrote:

On Tue, Oct 14, 2008 at 04:05:23PM +0100, Jules Bean wrote:

David Roundy wrote:
Constants are mathematical and universal, like pi. That is what the
semantics of haskell say.


Where do the semantics of haskell say this? 


You should better ask 'which semantics?'.

The semantics in which a value of type "Int -> Int" is denoted by a 
mathematical function from Int to Int. In that semantics a value of type 
"Int" denotes a specific Int.  And that denotation is, of course, 
entirely independent of compiler or OS or package or dynamic loading or 
any concern like that.


This is, to my mind the "often assumed but never written down" semantics 
of haskell. It's certainly the semantics *I* want haskell to have.


> How does it interact with

fixing bugs (which means changing mathematical and universal constant
functions--since all functions are constants)?


That's fine. Changing a program changes it denotation.

Running a program on a different interpreter or compiler had better not 
change its denotation, otherwise it [the denotation] is not much use as 
a basis for reasoning.


Jules


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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread David Roundy
On Tue, Oct 14, 2008 at 04:39:38PM +0100, Claus Reinke wrote:
>> Where do the semantics of haskell say this? How does it interact with
>> fixing bugs (which means changing mathematical and universal constant
>> functions--since all functions are constants)?
>
> What semantics of haskell?-) But if there was one, it might not talk
> about separate compilation (it should, though), or packages. And if
> you consider cross-package inlining, separate package updates, or
> dynamic linking, etc, you might want to flag all variable constants as  
> {-# NOINLINE c #-}, and perhaps even switch of any CSE-style
> optimizations. The usual bag of tricks for unsafePerformIO constants.

But in this case you'd also have to use the same flags for any
functions you might want to edit later.  It's always the job of the
compiler and/or build system to ensure that the compile is consistent.
But claiming that it's wrong to edit your source code is downright
silly, even if it is true that the compiler could then be more
aggresive in its optimizations...

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Claus Reinke

Where do the semantics of haskell say this? How does it interact with
fixing bugs (which means changing mathematical and universal constant
functions--since all functions are constants)?


What semantics of haskell?-) But if there was one, it might not talk
about separate compilation (it should, though), or packages. And if
you consider cross-package inlining, separate package updates, or
dynamic linking, etc, you might want to flag all variable constants as 
{-# NOINLINE c #-}, and perhaps even switch of any CSE-style

optimizations. The usual bag of tricks for unsafePerformIO constants.

Claus

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Jules Bean

David Roundy wrote:

(Sure this is a weird situation, but I do like to think about worst
cases.)

In practice that is fine, with current RTSes and so on.

In principle it's not fine. A 'constant' should be constant over all 
time, not just constant over a particular library version or sub-version 
or a particular program invocation or OS or


No, constants don't have to constant over all time.  e.g. it's perfectly
fine for compilers to implement System.Info, whose sole purpose to provide
constants that are different in different library versions and OSs.

http://haskell.org/ghc/docs/latest/html/libraries/base/System-Info.html#v:os


I entirely disagree.

That API is broken. All those things should be in the IO monad.

I might have code which migrates at runtime between different OSes. Of 
course i can't, and even if I did, it would probably return something 
different like 'virtual haskell migration pseudo-OS', but that's not the 
point.


Constants are mathematical and universal, like pi. That is what the 
semantics of haskell say.


However, I don't claim this is terribly important. Or even a very 
interesting debate ;)


Jules



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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread David Roundy
On Tue, Oct 14, 2008 at 04:05:23PM +0100, Jules Bean wrote:
> David Roundy wrote:
 (Sure this is a weird situation, but I do like to think about worst
 cases.)
>>> In practice that is fine, with current RTSes and so on.
>>>
>>> In principle it's not fine. A 'constant' should be constant over all  
>>> time, not just constant over a particular library version or 
>>> sub-version or a particular program invocation or OS or
>>
>> No, constants don't have to constant over all time.  e.g. it's perfectly
>> fine for compilers to implement System.Info, whose sole purpose to provide
>> constants that are different in different library versions and OSs.
>>
>> http://haskell.org/ghc/docs/latest/html/libraries/base/System-Info.html#v:os
>
> I entirely disagree.
>
> That API is broken. All those things should be in the IO monad.
>
> I might have code which migrates at runtime between different
> OSes. Of course i can't, and even if I did, it would probably return
> something different like 'virtual haskell migration pseudo-OS', but
> that's not the point.
>
> Constants are mathematical and universal, like pi. That is what the
> semantics of haskell say.

Where do the semantics of haskell say this? How does it interact with
fixing bugs (which means changing mathematical and universal constant
functions--since all functions are constants)?

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread David Roundy
On Tue, Oct 14, 2008 at 02:05:02PM +0100, Jules Bean wrote:
> Mauricio wrote:
> >If I have a Haskell wrapper (with unsafe...)  over a function that's
> >never going to return different values and is always side-effect free,
> >but can change depending on compile time options of its library; my
> >program is running, and then the version of my library is updated by my
> >distribution smart instalation system, which does update versions of
> >libraries in use; is it possible that I get a wrong behavior of my
> >program?

If you're talking aout an FFI function, the best option (in my opinion)
would be to not import it in the IO monad, if possible.  Which you couldn't
do if it does something like allocate a C string... but in many cases this
would be the cleanest approach.

> >I do not understand enough about package management to understand how
> >running programs or libraries are updated, and less about how linking
> >works between Haskelll and libraries on other languages, so I don't know
> >if my program is guaranteed to stay with a single version of a library
> >for each run.
> >
> >(Sure this is a weird situation, but I do like to think about worst
> >cases.)
> 
> In practice that is fine, with current RTSes and so on.
> 
> In principle it's not fine. A 'constant' should be constant over all 
> time, not just constant over a particular library version or sub-version 
> or a particular program invocation or OS or

No, constants don't have to constant over all time.  e.g. it's perfectly
fine for compilers to implement System.Info, whose sole purpose to provide
constants that are different in different library versions and OSs.

http://haskell.org/ghc/docs/latest/html/libraries/base/System-Info.html#v:os

> Who knows, maybe some future haskell runtime will be able to perform the 
> trickery you describe and will cause this to break ;)

No, that sort of trickery breaks referential transparency, and itself is
unsafe.  It is in fact safe to assume that the RTS will never break
referential transparency.

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


Re: [Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Jules Bean

Mauricio wrote:

Hi,

If I have a Haskell wrapper (with unsafe...)
over a function that's never going to return
different values and is always side-effect
free, but can change depending on compile time
options of its library; my program is running,
and then the version of my library is updated
by my distribution smart instalation system,
which does update versions of libraries in
use; is it possible that I get a wrong behavior
of my program?

I do not understand enough about package
management to understand how running programs
or libraries are updated, and less about how
linking works between Haskelll and libraries
on other languages, so I don't know if my
program is guaranteed to stay with a single
version of a library for each run.

(Sure this is a weird situation, but I do
like to think about worst cases.)


In practice that is fine, with current RTSes and so on.

In principle it's not fine. A 'constant' should be constant over all 
time, not just constant over a particular library version or sub-version 
or a particular program invocation or OS or


Who knows, maybe some future haskell runtime will be able to perform the 
trickery you describe and will cause this to break ;)


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


[Haskell-cafe] Linking and unsafePerformIO

2008-10-14 Thread Mauricio

Hi,

If I have a Haskell wrapper (with unsafe...)
over a function that's never going to return
different values and is always side-effect
free, but can change depending on compile time
options of its library; my program is running,
and then the version of my library is updated
by my distribution smart instalation system,
which does update versions of libraries in
use; is it possible that I get a wrong behavior
of my program?

I do not understand enough about package
management to understand how running programs
or libraries are updated, and less about how
linking works between Haskelll and libraries
on other languages, so I don't know if my
program is guaranteed to stay with a single
version of a library for each run.

(Sure this is a weird situation, but I do
like to think about worst cases.)

Thanks,
MaurĂ­co

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