[Haskell-cafe] Re: Is there anyone out there who can translate C# generics into Haskell?

2008-01-06 Thread Achim Schneider
Jonathan Cast [EMAIL PROTECTED] wrote:

 On 4 Jan 2008, at 2:00 AM, Nicholls, Mark wrote:
 
  You may be right...but learning is not an atomic thingwherever I
  start I will get strange things happening.
 
 The best place to start learning Haskell is with the simplest type  
 features, not the most complicated.  And it's the simplest features  
 that are most unlike OO.
 
 Yes, Haskell will be `strange'.  But if you think you're `the  
 intersection' between Haskell and OO, you'll think things are  
 familiar, and you'll be surprised when they turn  out to be  
 different.  I'd concentrate on watching out for differences --- but  
 then I can't imagine how finding `familiar' ideas would help.
 
just a sec...

things like


data State = State 
{ winSize   :: IORef Size
, t :: IORef Int
, fps   :: IORef Float
, showFPS   :: IORef Bool
, showHelp  :: IORef Bool
, grabMouse :: IORef Bool
, mousePos  :: IORef (Maybe Position)
, mouseDelta :: IORef Position
, viewRot   :: IORef Vec3
, angle':: IORef GLfloat
, ballPos   :: IORef Vec2
, ballVel   :: IORef Vec2
}

makeState :: IO State
makeState = do
size - newIORef $ Size 0 0 
t' - newIORef 0
fps' - newIORef 0
sfps - newIORef False
gm - newIORef False
mp - newIORef Nothing
md - newIORef $ Position 0 0
sh - newIORef False
v - newIORef (0, 0, 0)
a - newIORef 0
bp - newIORef (0, 0)
bv - newIORef (0.002, 0.002) 
{ winSize = size
, t = t', fps = fps'
, showFPS = sfps, showHelp = sh
, grabMouse = gm, mousePos = mp, mouseDelta = md
, viewRot = v, angle' = a
, ballPos = bp, ballVel = bv
}

and

keyboard state (Char 'f') Down_ _ = showFPS state $~ not

modRot :: State - View - IO ()
modRot state (dx,dy,dz) = do
(x, y, z) - get $ viewRot state
viewRot state $= (x + dx, y + dy, z + dz)
postRedisplay Nothing

come to mind.

But then this has more to do with Monads than with classes. IO, in
particular, and GL and GLUT, which are state machines and
thus predestined for OOP.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


[Haskell-cafe] Am I blind?

2008-01-06 Thread Andrew Coppin

Don Stewart wrote:

---
Haskell Weekly News
Issue 68 - January 05, 2008
---

Announcements

   GHC 6.8.2. The GHC Team [2]announced the release of GHC 6.8.2,
   featuring optimisation improvements, improvements to ghci and fixes to
   standalone deriving.
  


I've searched all over the place, and I can't find this information 
actually announced anywhere except on the GHC homepage itself. And 
yet, I've seen emails bouncing around that appear to be replies to the 
announcement email. But I can't find the actual announcement email 
anywhere. Am I going mad?


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


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

2008-01-06 Thread Andrew Coppin

Galchin Vasili wrote:

Hello,
 
https://buildsecurityin.us-cert.gov/daisy/bsi/articles/knowledge/coding/295.html
 
I stumbled across this page. It seems that Haskell and other strongly 
typed functional languages like Ml/OCaml will fare much, much better, 
e.g. buffer overrun. Thoughts .  comments.


Human kind has yet to design a programming language which eliminates all 
possible bugs. ;-)


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


[Haskell-cafe] Concurrency questions

2008-01-06 Thread Andrew Coppin

Just a couple of things I was wondering about...

1. Is there some way to assign a priority to Haskell threads? (The 
behaviour I'd like is that high priority threads always run first, and 
low priority threads potentially never run at all unless there's an 
available processor which is completely idle.)


2. I have a situation where I have a thread generating some data and 
putting it into a mutable array, and another thread trying to read that 
data. Is there a way I can make the reader thread block if it tries to 
read a cell that hasn't been computed yet, but not introduce too much 
overhead for cells that have been filled in?


3. Would it be hard to make it so that the number of real threads (the 
RTS +N flag) could be adjusted at runtime?


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


Re: [Haskell-cafe] Am I blind?

2008-01-06 Thread Allan Clark




I've searched all over the place, and I can't find this information 
actually announced anywhere except on the GHC homepage itself. And 
yet, I've seen emails bouncing around that appear to be replies to the 
announcement email. But I can't find the actual announcement email 
anywhere. Am I going mad?



It was on just the Haskell rather than Haskell-cafe mailing list.
http://www.mail-archive.com/[EMAIL PROTECTED]/msg20759.html

regards
allan

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


Re: [Haskell-cafe] Am I blind?

2008-01-06 Thread Andrew Coppin

Allan Clark wrote:




I've searched all over the place, and I can't find this information 
actually announced anywhere except on the GHC homepage itself. And 
yet, I've seen emails bouncing around that appear to be replies to 
the announcement email. But I can't find the actual announcement 
email anywhere. Am I going mad?



It was on just the Haskell rather than Haskell-cafe mailing list.
http://www.mail-archive.com/[EMAIL PROTECTED]/msg20759.html


You're quite right - there it is - and yet I still can't find this 
through Gname. [Even though I now know what date to look at.] Odd...


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


Re: [Haskell-cafe] Concurrency questions

2008-01-06 Thread Felipe Lessa
On Jan 6, 2008 9:30 AM, Andrew Coppin [EMAIL PROTECTED] wrote:
 2. I have a situation where I have a thread generating some data and
 putting it into a mutable array, and another thread trying to read that
 data. Is there a way I can make the reader thread block if it tries to
 read a cell that hasn't been computed yet, but not introduce too much
 overhead for cells that have been filled in?

If your thread fills the array linearly, you could maintain a variable
shared by those threads that say the last cell computed, and have the
read thread check that before reading. I think this wouldn't create
too much overhead, although it seems like there must be something
cleverer somewhere.

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


[Haskell-cafe] Re: Concurrency questions

2008-01-06 Thread Achim Schneider
Andrew Coppin [EMAIL PROTECTED] wrote:

 2. I have a situation where I have a thread generating some data and 
 putting it into a mutable array, and another thread trying to read
 that data. Is there a way I can make the reader thread block if it
 tries to read a cell that hasn't been computed yet, but not introduce
 too much overhead for cells that have been filled in?
 
This
http://www.haskell.org/ghc/docs/latest/html/libraries/stm/Control-Concurrent-STM-TChan.html
could be what you're looking for.


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


Re: [Haskell-cafe] Concurrency questions

2008-01-06 Thread Andrew Coppin

Felipe Lessa wrote:

On Jan 6, 2008 9:30 AM, Andrew Coppin [EMAIL PROTECTED] wrote:
  

2. I have a situation where I have a thread generating some data and
putting it into a mutable array, and another thread trying to read that
data. Is there a way I can make the reader thread block if it tries to
read a cell that hasn't been computed yet, but not introduce too much
overhead for cells that have been filled in?



If your thread fills the array linearly, you could maintain a variable
shared by those threads that say the last cell computed, and have the
read thread check that before reading. I think this wouldn't create
too much overhead, although it seems like there must be something
cleverer somewhere.
  


That's just it - it fills the array in a fairly random order. (The 
*scanning* is, however, in linear order.)


It's not a big problem - I can wait for the entire array to be filled, 
and then scan it. But I'd like to do both in parallel if there's a 
reasonably easy way to do it.


I suppose an array of MVars would do it, but

1. How big is an MVar?

2. You have to take the data out of an MVar to read it. In other words, 
only 1 thread can read an MVar at once [by design]. This isn't truly a 
problem in the current case, but it's irritating in principle that I 
can't make it so that once the cell is written, multiple threads can 
read it simultaneously...


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


Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Yitzchak Gale
I wrote:
 What goes wrong with finite coproducts? The obvious thing to
 do would be to take the disjoint union of the sets representing the
 types, identifying the copies of _|_.

Jonathan Cast wrote:
 This isn't a coproduct.  If we have f x = 1 and g y = 2, then there
 should exist a function h such that h . Left = f and h . Right = g...
 But by your rule, Left undefined = Right undefined...
 Which is a contradiction...

OK, thanks.

 Unless, of course,
 your require your functions to be strict --- then both f and g above
 become illegal, and repairing them removes the problem.

You don't have to make them illegal - just not part
of your notion of coproduct. That is an entirely
category-theoretic concept, since Empty is bi-universal,
and a morphism is strict iff the diagram

   f
A --- B
 \ ^
  v/
 Empty

commutes.

However, the coproduct you get is the one I suggested,
namely Either !A !B, not the one we usually use.

  What is the lifted version you are referring to?

 Take the ordinary disjoint union, and then add a new _|_ element,
 distinct from both existing copies of _|_ (which are still distinct
 from each other).

 
   Of course, Haskell makes things even worse by lifting the
  product and exponential objects,
 
  OK, what goes wrong there, and what is the lifting?

 Again, in Haskell, (_|_, _|_) /= _|_.  The difference is in the function

 f (x, y) = 1

 which gives f undefined = undefined but f (undefined, undefined) =
 1.  Unfortunately, this means that (alpha, beta) has an extra _|_
 element  (_|_, _|_), so it's not the categorical product (which
 would lack such an element for the same reason as above).
 This is partly an implementation issue --- compiling pattern matching
 without introducing such a lifting requires a parallel implementation
 --- and partly a semantic issue --- data introduces a single level of
 lifting, every time it is used, and every constructor is completely
 lazy.

 Functions have the same issue --- in the presence of seq, undefined /
 = const undefined.

 Extensionality is a key part of the definition of all of these
 constructions.  The categorical rules are designed to require, in
 concrete categories, that the range of the two injections into a
 coproduct form a partition of the coproduct, the surjective pairing
 law (fst x, snd x) = x holds, and the eta reduction law (\ x - f x)
 = f holds.  Haskell flaunts all three; while some categories have few
 enough morphisms to get away with this (at least some times), Hask is
 not one of them.

 jcc


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


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

2008-01-06 Thread Derek Elkins
On Fri, 2007-12-28 at 17:54 -0600, Jonathan Cast wrote:

 Programming languages are generally classified into three groups,  
 imperative, functional, and logical.  The difference is in the style  
 of programming encouraged (or mandated, for older languages) by the  
 language.

Usually the divide is imperative v. declarative with the four major
paradigms (procedural, OO and logic, FP respectively) being subgroups of
those divisions.

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


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

2008-01-06 Thread Derek Elkins
On Sun, 2007-12-30 at 12:27 +0100, [EMAIL PROTECTED]
wrote:
[...]
 I don't understand your point. We know what swimming is: floating and
 moving autonomously. Thinking is different, since our thinking is (at least
 for some of us) conscious, and we have no idea what is the conscience.
 For goodness sake, I have *REALLY* the impression that those guys who
 speak about computability of the Universe, have the mentality of 18 century
 thinkers for whom the world was simple and mechanistic. Or even the
 mentality of people contemporary of Democritus, for whom everything
 reduced to some dance of atoms. 

Or a wave function for the Universe...

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


Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Derek Elkins
On Wed, 2008-01-02 at 15:49 +0200, Yitzchak Gale wrote:

[...]

 Some people are worried that this version of Hask is missing
 certain nice properties that one would like to have. For
 example, it was recently claimed on this list that tuples
 are not products in that category. (Or some such. I would be
 interested to see a demonstration of that.)

Johnathan has given such a demonstration (and it has been demonstrated
many times on this list since it's creation, it's well-known).

 I am not impressed by those complaints. As usual in category
 theory, you define corresponding notions in Hask, and prove
 that they are preserved under the appropriate functors.
 That should always be easy. And if ever it is not, then you
 have discovered an interesting non-trivial consequence of
 laziness that deserves study.

You are right not to be impressed by such complaints, but you
misrepresent people's views on this by saying that the worry about
such problems.

As you say (people say), these properties [that Hask is cartesian closed
to start] would be nice to have and are very convenient to assume which
is often safe enough.  Certainly computer scientists of a categorical
bent have developed (weaker) notions to use; namely, monoidal,
pre-monoidal, Freyd, and/or kappa categories and no doubt others.  Using
these, however, removes some of the allure of using a categorical
approach.  Also, there is a Haskell-specific problem at the very get-go.
The most obvious choice for the categorical composition operator
assuming the obvious choice for the arrows and objects does not work,
it does not satisfy the laws of a category assuming the = used in them
is observational equality.  Namely, id . f /= f /= f . id for all
functions f, in particular, it fails when f = undefined.  This can
easily be fixed by making the categorical (.) strict in both arguments
and there is no formal problem with it being different from Haskell's
(.), but it certainly is not intuitively appealing.

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


Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Yitzchak Gale
(sorry, I hit the send button)

 What is the lifted version you are referring to?

 Take the ordinary disjoint union, and then add a new _|_ element,
 distinct from both existing copies of _|_ (which are still distinct
 from each other).

Now why is that not the category-theoretic coproduct?
h . Left = f and h . Right = g both for _|_ and for finite
elements of the types. And it looks universal to me.

  Of course, Haskell makes things even worse by lifting the
 product and exponential objects,

 OK, what goes wrong there, and what is the lifting?

 Again, in Haskell, (_|_, _|_) /= _|_.  The difference is in the function
 f (x, y) = 1 which gives f undefined = undefined but
 f (undefined, undefined) = 1.

I don't get that one. Given any f and g, we define h x = (f x, g x).
Why do we not have fst . h = f and snd . h = g, both in Hask
and StrictHask? fst and snd are strict.

  Unfortunately, this means that (alpha, beta) has an extra _|_
 element  (_|_, _|_), so it's not the categorical product (which
 would lack such an element for the same reason as above).

The reason you can't adjoin an extra element to (A,B) in, say,
Set, is that you would have nowhere to map it under fst
and snd. But here that is not a problem, _|_ goes to _|_
under both.

 This is partly an implementation issue --- compiling pattern matching
 without introducing such a lifting requires a parallel implementation

That's interesting. So given a future platform where parallelizing
is much cheaper than it is today, we could conceivably have
a totally lazy version of Haskell. I wonder what it would be like
to program in that environment, what new problems would arise
and what new techniques would solve them. Sounds like a nice
research topic. Who is working on it?

 --- and partly a semantic issue --- data introduces a single level of
 lifting, every time it is used, and every constructor is completely
 lazy.

Unless you use bangs. So both options are available, and that
essentially is what defines Haskell as being a non-strict language.

 Functions have the same issue --- in the presence of seq, undefined /
 = const undefined.

Right. I am becoming increasingly convinced that the seq issue
is a red herring.

 Extensionality is a key part of the definition of all of these
 constructions.  The categorical rules are designed to require, in
 concrete categories, that the range of the two injections into a
 coproduct form a partition of the coproduct, the surjective pairing
 law (fst x, snd x) = x holds, and the eta reduction law (\ x - f x)
 = f holds.  Haskell flaunts all three; while some categories have few
 enough morphisms to get away with this (at least some times), Hask is
 not one of them.

That interpretation is not something that is essential in the notion
of category, only in certain specific examples of categories
that you know. Product and coproduct in any given category -
whether they exist, what they are like if they exist, and what alternative
constructions exist if they do not - reflect the nature of the structure
that the category is modeling.

I am interested in understanding the category Hask that represents
what Haskell really is like as a programming language. Not
under some semantic mapping that includes non-computable
functions, and that forgets some of the interesting structure
that comes from laziness (though that is undoubtably also
very interesting).

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


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

2008-01-06 Thread Mads Lindstrøm
Hi,

Andrew Coppin wrote:
 Galchin Vasili wrote:
  Hello,
   
  https://buildsecurityin.us-cert.gov/daisy/bsi/articles/knowledge/coding/295.html
   
  I stumbled across this page. It seems that Haskell and other strongly 
  typed functional languages like Ml/OCaml will fare much, much better, 
  e.g. buffer overrun. Thoughts .  comments.
 
 Human kind has yet to design a programming language which eliminates all 
 possible bugs. ;-)
And we never will. See http://en.wikipedia.org/wiki/Halting_problem .


Greetings,

Mads

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

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


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

2008-01-06 Thread Daniel Fischer
Am Sonntag, 6. Januar 2008 14:27 schrieb Mads Lindstrøm:
 Hi,

 Andrew Coppin wrote:
  Galchin Vasili wrote:
   Hello,
  
   https://buildsecurityin.us-cert.gov/daisy/bsi/articles/knowledge/coding
  /295.html
  
   I stumbled across this page. It seems that Haskell and other strongly
   typed functional languages like Ml/OCaml will fare much, much better,
   e.g. buffer overrun. Thoughts .  comments.
 
  Human kind has yet to design a programming language which eliminates all
  possible bugs. ;-)

 And we never will. See http://en.wikipedia.org/wiki/Halting_problem .


 Greetings,

 Mads


Just because I don't know:
what bugs would be possible in a language having only the instruction 
return () 
(';' for imperative programmers)?
Cheers,
Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-01-06 Thread Andrew Coppin

Mads Lindstrøm wrote:

Hi,

Andrew Coppin wrote:
  
Human kind has yet to design a programming language which eliminates all 
possible bugs. ;-)


And we never will.


Quite so. How can a machine possibly tell whether a given behaviour is a 
bug or an intended behaviour? This is impossible. ;-)


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


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

2008-01-06 Thread 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. ;-)

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


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

2008-01-06 Thread Achim Schneider
Daniel Fischer [EMAIL PROTECTED] wrote:

 Just because I don't know:
 what bugs would be possible in a language having only the instruction 
 return () 
 (';' for imperative programmers)?

/me waves meaningful with his hand.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Yitzchak Gale
I wrote:
 ...it was recently claimed on this list that tuples
 are not products in that category.

Derek Elkins wrote:
 Johnathan has given such a demonstration (and it has been demonstrated
 many times on this list since it's creation, it's well-known).

We're still working on it. I've not been convinced yet.
Sorry about my thickness.

Perhaps this should be on a nice wiki page somewhere.
I tried to convince David House to put it in the Wikibook
chapter, but he is right, that needs to simpler. There is
some discussion on the talk page for that
chapter, but no one spells out the details there, either.

 You are right not to be impressed by such complaints, but you
 misrepresent people's views on this by saying that they worry about
 such problems.

Sorry, I hope I am not misrepresenting anyone. I just
notice that people make assumptions about a so-called
category Hask, derive various conclusions, then mention
that they are not really true. Perhaps it is only me who is
worried.

 As you say (people say), these properties [that Hask is cartesian closed
 to start] would be nice to have and are very convenient to assume which
 is often safe enough.

I'd like to understand better what is true, so that I can understand
what is safe.

  Certainly computer scientists of a categorical
 bent have developed (weaker) notions to use; namely, monoidal,
 pre-monoidal, Freyd, and/or kappa categories and no doubt others.  Using
 these, however, removes some of the allure of using a categorical
 approach.

It would be nice to distill out of that the basics that are needed
to get the properties that we need for day-to-day work in
Haskell.

  Also, there is a Haskell-specific problem at the very get-go.
 The most obvious choice for the categorical composition operator
 assuming the obvious choice for the arrows and objects does not work...
 ...This can
 easily be fixed by making the categorical (.) strict in both arguments
 and there is no formal problem with it being different from Haskell's
 (.), but it certainly is not intuitively appealing.

I'm not sure it's so bad. First of all, not only is it not a formal
problem, it's also not really a practical problem - there will rarely
if ever be any difference between the two when applied in real
programs.

My opinion is that there would not be any problem with using
that version as (.) in the Prelude. Even if we never do, at least
we should then use (.!) when we state the so-called Monad laws.
It bothers me that Haskell's so-called monads really aren't.
That is bound to cause problems.

And it would be so easy to fix in most cases - just require monad
bind to be strict on the second parameter.

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


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

2008-01-06 Thread Peter Hercek

Mads Lindstrøm wrote:

Andrew Coppin wrote:
Human kind has yet to design a programming language which eliminates all 
possible bugs. ;-)

And we never will. See http://en.wikipedia.org/wiki/Halting_problem .


If you limit usage of general recursion (and rather favor structural
 recursion) then you can mitigate the halting problem.
But there always will be specification bugs (when one implenetes 
something else than what was needed).


Peter.

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


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

2008-01-06 Thread Daniel Fischer
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.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-01-06 Thread 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.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


[Haskell-cafe] Re: US Homeland Security program blahBlah...

2008-01-06 Thread jerzy . karczmarczuk

Peter Hercek writes:

Andrew Coppin wrote:


Human kind has yet to design a programming language which eliminates all 
possible bugs. ;-)

...you can mitigate the halting problem.
But there always will be specification bugs (when one implenetes something 
else than what was needed).


Look, you are descending an infinite ramp to conceptual hell, the hell of
triviality. Now, you will discuss what is needed, and from FP we get into
politics! 

But, if it is something you need... 


Read then the passage of Earthsea of Ursula LeGuin. There is something
about a language in which YOU COULD NOT LIE. It was the ancient tongue of
dragons. 


Now we see why the dragons are extinct...
They were incompatible with the Democracy, AND with Computing Technology... 

Jerzy Karczmarczuk 


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


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

2008-01-06 Thread apfelmus

Achim Schneider wrote:

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.


Have a look about dependently typed languages like Epigram:

  http://www.e-pig.org/


Regards,
apfelmus

___
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 Daniel Fischer
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.
___
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


[Haskell-cafe] Re: Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread apfelmus

Yitzchak Gale wrote:

I wrote:

...it was recently claimed on this list that tuples
are not products in that category.


I've not been convinced yet.


I'm going to try convince you :) The crucial problem of Haskell's 
product is that (_|_,_|_) ≠ _|_ but that the two projections


  fst :: (A,B) - A
  snd :: (A,B) - B

cannot distinguish between both values. But if (,) were a categorial 
product,  fst  and  snd  would completely determine it. We would have 
the universal property that for every


  f :: C - A
  g :: C - B

there is a _unique_ morphism

  f  g :: C - (A,B)

subject to

  f = fst . (f  g)
  g = snd . (f  g)

In other words, there is a unique function

  () :: forall c . (c - A) - (c - B) - (c - (A,B))
  f  g = \c - (f c, g c)

In the particular case of  C=(A,B), f=fst  and  g=snd , the identity 
function is such a morphism which means


  fst  snd = id

due to uniqueness. But

  id _|_  ≠  id (_|_,_|_)

while clearly

  (fst  snd) _|_  =  (fst  snd) (_|_,_|_)


Derek Elkins wrote:

 Also, there is a Haskell-specific problem at the very get-go.
The most obvious choice for the categorical composition operator
assuming the obvious choice for the arrows and objects does not work...
...This can
easily be fixed by making the categorical (.) strict in both arguments
and there is no formal problem with it being different from Haskell's
(.), but it certainly is not intuitively appealing.


Note that the problem with (.) is seq's fault (pun intended :) 
Otherwise, it would be impossible to distinguish  _|_  from its 
eta-expansion  \x._|_ .



Regards,
apfelmus

___
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 Derek Elkins
On Sun, 2008-01-06 at 16:19 +0100, Daniel Fischer 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.

What Goedel meant by arithmetic is a bit more than one usually
associates with the term.  One person mentioned Epigram.  Most theorem
provers and most? (of the few) dependently typed programming languages
would fit Achim's criterion depending on the range of usable and
usual.  Coq, for example, is likely to be capable of formalizing just
about anything you'd want.  Of course, there is one class of
programming problem that we can already say can't be handled; namely
implementing interpreters (for Turing complete languages).  We can
formalize analyses, make compilers, prove the compilers correct with
respect to a semantics, and even prove that a -description- of an
interpreter correctly implements the semantics, but we can't actually
-run- the interpreter.

___
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 gwern0
On 2008.01.06 15:54:00 +0100, Achim Schneider [EMAIL PROTECTED] scribbled 
0.6K characters:
 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.

Total functional programming, yay: http://lambda-the-ultimate.org/node/2003.

--
gwern
$ Majic shaped Grove infrastructure Spoke BOSS mercur SEIDM BX


pgpvu78AlgsIx.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Miguel Mitrofanov

Take the ordinary disjoint union, and then add a new _|_ element,
distinct from both existing copies of _|_ (which are still distinct
from each other).


Now why is that not the category-theoretic coproduct?
h . Left = f and h . Right = g both for _|_ and for finite
elements of the types. And it looks universal to me.


Yeah, but there could be more functions from Either X Y to Z than  
pairs of functions from X to Z and from Y to Z.


For example, if z :: Z, then you have two functions h1 and h2 such  
that h1 . Left = const z and h1 . Right = const z and the same holds  
for h2. Namely,


h1 = const z

h2 = either (const z) (const z)

This functions are different : h1 (_|_) = z while h2 (_|_) = (_|_).  
And if Either X Y was a category-theoretic coproduct, then the  
function from Either X Y to Z would be UNIQUELY determined by it's  
restrictions to X and Y.

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


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

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 3:02 AM, Derek Elkins wrote:


On Fri, 2007-12-28 at 17:54 -0600, Jonathan Cast wrote:


Programming languages are generally classified into three groups,
imperative, functional, and logical.  The difference is in the style
of programming encouraged (or mandated, for older languages) by the
language.


Usually the divide is imperative v. declarative with the four major
paradigms (procedural, OO and logic, FP respectively) being  
subgroups of

those divisions.


And your explanation of this classification is?

I find the term `declarative' to be almost completely meaningless.

jcc


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


Re: [Haskell-cafe] Re: Is there anyone out there who can translate C# generics into Haskell?

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 2:13 AM, Achim Schneider wrote:


Jonathan Cast [EMAIL PROTECTED] wrote:


On 4 Jan 2008, at 2:00 AM, Nicholls, Mark wrote:


You may be right...but learning is not an atomic thingwherever I
start I will get strange things happening.


The best place to start learning Haskell is with the simplest type
features, not the most complicated.  And it's the simplest features
that are most unlike OO.

Yes, Haskell will be `strange'.  But if you think you're `the
intersection' between Haskell and OO, you'll think things are
familiar, and you'll be surprised when they turn  out to be
different.  I'd concentrate on watching out for differences --- but
then I can't imagine how finding `familiar' ideas would help.


just a sec...

things like


C++ translated into Haskell


come to mind.

But then this has more to do with Monads than with classes. IO, in
particular, and GL and GLUT, which are state machines and
thus predestined for OOP.


Your example is very unintuitive and unidiomatic Haskell.  The  
reference to GL makes me think this is for a `low-level' binding to  
an imperative library, no?  Those are scarcely good places to learn  
Haskell.


jcc

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


Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 3:55 AM, Yitzchak Gale wrote:


I wrote:

What goes wrong with finite coproducts? The obvious thing to
do would be to take the disjoint union of the sets representing the
types, identifying the copies of _|_.


Jonathan Cast wrote:

This isn't a coproduct.  If we have f x = 1 and g y = 2, then there
should exist a function h such that h . Left = f and h . Right = g...
But by your rule, Left undefined = Right undefined...
Which is a contradiction...


OK, thanks.


Unless, of course,
your require your functions to be strict --- then both f and g above
become illegal, and repairing them removes the problem.


You don't have to make them illegal - just not part
of your notion of coproduct.


We're talking past each other --- what is the distinction you are  
making?


jcc

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


Re: [Haskell-cafe] Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 5:32 AM, Yitzchak Gale wrote:


(sorry, I hit the send button)


What is the lifted version you are referring to?



Take the ordinary disjoint union, and then add a new _|_ element,
distinct from both existing copies of _|_ (which are still distinct
from each other).


Now why is that not the category-theoretic coproduct?
h . Left = f and h . Right = g both for _|_ and for finite
elements of the types. And it looks universal to me.


Not quite.  The only requirement for h _|_ is that it be = f x for  
all x and = g y for all y.  If f x = 1 = g y for all x, y, then both  
h _|_ = _|_ and h _|_ = 1 are arrows of the category.  So the  
universal property still fails.



 Of course, Haskell makes things even worse by lifting the
product and exponential objects,



OK, what goes wrong there, and what is the lifting?


Again, in Haskell, (_|_, _|_) /= _|_.  The difference is in the  
function

f (x, y) = 1 which gives f undefined = undefined but
f (undefined, undefined) = 1.


I don't get that one. Given any f and g, we define h x = (f x, g x).
Why do we not have fst . h = f and snd . h = g, both in Hask
and StrictHask? fst and snd are strict.


Again, if f and g are both strict, we have a choice for h _|_ ---  
either h _|_ = _|_ or h _|_ = (_|_, _|_) will work (fst . h = f and  
snd . h = g), but again these are different morphisms.





 Unfortunately, this means that (alpha, beta) has an extra _|_
element  (_|_, _|_), so it's not the categorical product (which
would lack such an element for the same reason as above).


The reason you can't adjoin an extra element to (A,B) in, say,
Set, is that you would have nowhere to map it under fst
and snd. But here that is not a problem, _|_ goes to _|_
under both.

This is partly an implementation issue --- compiling pattern  
matching
without introducing such a lifting requires a parallel  
implementation


That's interesting. So given a future platform where parallelizing
is much cheaper than it is today, we could conceivably have
a totally lazy version of Haskell. I wonder what it would be like
to program in that environment, what new problems would arise
and what new techniques would solve them. Sounds like a nice
research topic. Who is working on it?

--- and partly a semantic issue --- data introduces a single  
level of

lifting, every time it is used, and every constructor is completely
lazy.


Unless you use bangs. So both options are available, and that
essentially is what defines Haskell as being a non-strict language.


(!alpha, !beta) isn't a categorical product, either.  snd (undefined,  
1) = undefined with this type.




Functions have the same issue --- in the presence of seq,  
undefined /

= const undefined.


Right. I am becoming increasingly convinced that the seq issue
is a red herring.


Care to give an explanation?




Extensionality is a key part of the definition of all of these
constructions.  The categorical rules are designed to require, in
concrete categories, that the range of the two injections into a
coproduct form a partition of the coproduct, the surjective pairing
law (fst x, snd x) = x holds, and the eta reduction law (\ x - f x)
= f holds.  Haskell flaunts all three; while some categories have  
few
enough morphisms to get away with this (at least some times),  
Hask is

not one of them.


That interpretation is not something that is essential in the notion
of category, only in certain specific examples of categories
that you know.


I understand category theory.  I also know that the definitions used  
are chosen to get Set `right', which means extensionality in that  
case, and are then extended uniformly across all categories.  This  
has the effect of requiring similar constructions to those in Set in  
other concrete categories.



Product and coproduct in any given category -
whether they exist, what they are like if they exist, and what  
alternative
constructions exist if they do not - reflect the nature of the  
structure

that the category is modeling.


I understand that.  I'm not sure you do.



I am interested in understanding the category Hask that represents
what Haskell really is like as a programming language.


Good luck.


Not
under some semantic mapping that includes non-computable
functions, and that forgets some of the interesting structure
that comes from laziness (though that is undoubtably also
very interesting).


Bear in mind in your quest, that at the end of it you'll most likely  
conclude, like everyone else, that good old equational reasoning is  
sound for the programs you actually right at least 90% of the time  
(with appropriate induction principles), and complete for at least  
90% of what you want to right, and go back to using it exclusively  
for real programming.


jcc


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


[Haskell-cafe] Newbie question related to list evaluation

2008-01-06 Thread Sai Hemanth K
Hi,

I am new to functional and lazy programming languages ( that's correct, my
life has been pretty pathetic so far) and am not able to understand GHC's
behaviour for a particular function. Can someone help me please?

I am trying to write a function which would compare two strings (from
reverse) and return the position of first mismatch. This is part of the
right-to-left scan of bayer-moore algorithm.. and it is essential for me to
do it from reverse.
Since my goal is to learn haskell, I am not using Data.ByteString.

My function is as follows:

matchReverse :: String - String -Int-(Bool,Int)
matchReverse [] [] pos = (True,pos)
matchReverse _ [] pos = (False,pos)
matchReverse [] _ pos = (False,pos)
matchReverse (x:xs) (y:ys) pos = let (matched,pos) = matchReverse xs ys (pos
+1)
  in if matched then
((x==y),pos)
 else (False,pos)



The behaviour I expected in four scenarios is as below:
1.matchReverse kapilash kapilash 0 --should return (True,0)
2.matchReverse kapilash kapilast 0 --should return (False,8)
3.matchReverse str1 str2 0  --should return (False,0)
4.matchReverse str1 str1 0  --should return (True,0)

where str1 and str2 are defined as below:
 str1 =  replicate 1000 'a'
 str2 =  'b':(replicate 999 'a')

what confounds me is that it is able to identify the first element of the
tuple in ALL the cases.
Invoking fst on the each of the four calls instantly returns the expected
value.(even for the cases 3 and 4 where, there are thousand elements)
But it seems to go into an infinite loop while calculating the 'snd' of the
tuple. Even for strings containing just one element each.
can someone throw some light on this please? Why does it go into an infinite
loop?

Many thanks
Kapilash


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


Re: [Haskell-cafe] Newbie question related to list evaluation

2008-01-06 Thread Rodrigo Queiro
You have used the name 'pos' twice, for both the parameter and the
returned value of the recursive call. The reason this results in an
infinite loop is that in code like

let x = x + 1

Haskell treats both xs to be references to the same thing, so evaluates:
x
= x + 1
= (x + 1) + 1
= ((x + 1) + 1) + 1
...

which results in the infinite loop.

On 06/01/2008, Sai Hemanth K [EMAIL PROTECTED] wrote:
 Hi,

 I am new to functional and lazy programming languages ( that's correct, my
 life has been pretty pathetic so far) and am not able to understand GHC's
 behaviour for a particular function. Can someone help me please?

 I am trying to write a function which would compare two strings (from
 reverse) and return the position of first mismatch. This is part of the
 right-to-left scan of bayer-moore algorithm.. and it is essential for me to
 do it from reverse.
 Since my goal is to learn haskell, I am not using Data.ByteString.

 My function is as follows:

 matchReverse :: String - String -Int-(Bool,Int)
 matchReverse [] [] pos = (True,pos)
 matchReverse _ [] pos = (False,pos)
 matchReverse [] _ pos = (False,pos)
 matchReverse (x:xs) (y:ys) pos = let (matched,pos) = matchReverse xs ys (pos
 +1)
   in if matched then
 ((x==y),pos)
  else (False,pos)



 The behaviour I expected in four scenarios is as below:
 1.matchReverse kapilash kapilash 0 --should return (True,0)
 2.matchReverse kapilash kapilast 0 --should return (False,8)
 3.matchReverse str1 str2 0  --should return (False,0)
 4.matchReverse str1 str1 0  --should return (True,0)

 where str1 and str2 are defined as below:
  str1 =  replicate 1000 'a'
  str2 =  'b':(replicate 999 'a')

 what confounds me is that it is able to identify the first element of the
 tuple in ALL the cases.
 Invoking fst on the each of the four calls instantly returns the expected
 value.(even for the cases 3 and 4 where, there are thousand elements)
 But it seems to go into an infinite loop while calculating the 'snd' of the
 tuple. Even for strings containing just one element each.
 can someone throw some light on this please? Why does it go into an infinite
 loop?

 Many thanks
 Kapilash


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


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


Re: [Haskell-cafe] Newbie question related to list evaluation

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 10:34 AM, Sai Hemanth K wrote:


Hi,

I am new to functional and lazy programming languages ( that's  
correct, my life has been pretty pathetic so far) and am not able  
to understand GHC's behaviour for a particular function. Can  
someone help me please?


I am trying to write a function which would compare two strings  
(from reverse) and return the position of first mismatch. This is  
part of the right-to-left scan of bayer-moore algorithm.. and it is  
essential for me to do it from reverse.

Since my goal is to learn haskell, I am not using Data.ByteString.

My function is as follows:

matchReverse :: String - String -Int-(Bool,Int)
matchReverse [] [] pos = (True,pos)
matchReverse _ [] pos = (False,pos)
matchReverse [] _ pos = (False,pos)
matchReverse (x:xs) (y:ys) pos = let (matched,pos) = matchReverse  
xs ys (pos +1)
  in if matched  
then ((x==y),pos)

 else (False,pos)


let is always recursive in Haskell, so this is a recursive definition  
of pos.  To break the recursion, use


matchReverse (x:xs) (y:ys) pos = let (matched, pos') = matchReverse  
xs ys (pos + 1)

 in if matched then ((x==y), pos')
   else (False, pos')






The behaviour I expected in four scenarios is as below:
1.matchReverse kapilash kapilash 0 --should return (True,0)
2.matchReverse kapilash kapilast 0 --should return (False,8)
3.matchReverse str1 str2 0  --should return  
(False,0)
4.matchReverse str1 str1 0  --should return  
(True,0)


where str1 and str2 are defined as below:
 str1 =  replicate 1000 'a'
 str2 =  'b':(replicate 999 'a')

what confounds me is that it is able to identify the first element  
of the tuple in ALL the cases.
Invoking fst on the each of the four calls instantly returns the  
expected value.(even for the cases 3 and 4 where, there are  
thousand elements)
But it seems to go into an infinite loop while calculating the  
'snd' of the tuple. Even for strings containing just one element each.
can someone throw some light on this please? Why does it go into an  
infinite loop?


Many thanks
Kapilash


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


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


Re: [Haskell-cafe] Newbie question related to list evaluation

2008-01-06 Thread Felipe Lessa
On Jan 6, 2008 4:40 PM, Jonathan Cast [EMAIL PROTECTED] wrote:
 let is always recursive in Haskell, so this is a recursive definition
 of pos.  To break the recursion, use


 matchReverse (x:xs) (y:ys) pos = let (matched, pos') = matchReverse
 xs ys (pos + 1)
   in if matched then ((x==y), pos')
else (False, pos')

Actually, I think he meant

matchReverse (x:xs) (y:ys) pos =
let (matched, pos') = matchReverse xs ys (pos + 1)
in if matched then ((x==y), pos) else (False, pos')

As as side note, GHC's flag -Wall would have warned about creating a
variable with a name already in scope.

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


Re: [Haskell-cafe] Newbie question related to list evaluation

2008-01-06 Thread Sai Hemanth K
AAh! Thanks a ton!

Hemanth K

On Jan 7, 2008 12:10 AM, Rodrigo Queiro [EMAIL PROTECTED] wrote:

 You have used the name 'pos' twice, for both the parameter and the
 returned value of the recursive call. The reason this results in an
 infinite loop is that in code like

 let x = x + 1

 Haskell treats both xs to be references to the same thing, so evaluates:
 x
 = x + 1
 = (x + 1) + 1
 = ((x + 1) + 1) + 1
 ...

 which results in the infinite loop.

 On 06/01/2008, Sai Hemanth K [EMAIL PROTECTED] wrote:
  Hi,
 
  I am new to functional and lazy programming languages ( that's correct,
 my
  life has been pretty pathetic so far) and am not able to understand
 GHC's
  behaviour for a particular function. Can someone help me please?
 
  I am trying to write a function which would compare two strings (from
  reverse) and return the position of first mismatch. This is part of the
  right-to-left scan of bayer-moore algorithm.. and it is essential for me
 to
  do it from reverse.
  Since my goal is to learn haskell, I am not using Data.ByteString.
 
  My function is as follows:
 
  matchReverse :: String - String -Int-(Bool,Int)
  matchReverse [] [] pos = (True,pos)
  matchReverse _ [] pos = (False,pos)
  matchReverse [] _ pos = (False,pos)
  matchReverse (x:xs) (y:ys) pos = let (matched,pos) = matchReverse xs ys
 (pos
  +1)
in if matched then
  ((x==y),pos)
   else (False,pos)
 
 
 
  The behaviour I expected in four scenarios is as below:
  1.matchReverse kapilash kapilash 0 --should return (True,0)
  2.matchReverse kapilash kapilast 0 --should return (False,8)
  3.matchReverse str1 str2 0  --should return
 (False,0)
  4.matchReverse str1 str1 0  --should return (True,0)
 
  where str1 and str2 are defined as below:
   str1 =  replicate 1000 'a'
   str2 =  'b':(replicate 999 'a')
 
  what confounds me is that it is able to identify the first element of
 the
  tuple in ALL the cases.
  Invoking fst on the each of the four calls instantly returns the
 expected
  value.(even for the cases 3 and 4 where, there are thousand elements)
  But it seems to go into an infinite loop while calculating the 'snd' of
 the
  tuple. Even for strings containing just one element each.
  can someone throw some light on this please? Why does it go into an
 infinite
  loop?
 
  Many thanks
  Kapilash
 
 
  --
  I drink I am thunk.
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 




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


[Haskell-cafe] Re: Is there anyone out there who can translate C# generics into Haskell?

2008-01-06 Thread Achim Schneider
Jonathan Cast [EMAIL PROTECTED] wrote:

 On 6 Jan 2008, at 2:13 AM, Achim Schneider wrote:
 
  Jonathan Cast [EMAIL PROTECTED] wrote:
 
  On 4 Jan 2008, at 2:00 AM, Nicholls, Mark wrote:
 
  You may be right...but learning is not an atomic
  thingwherever I start I will get strange things happening.
 
  The best place to start learning Haskell is with the simplest type
  features, not the most complicated.  And it's the simplest features
  that are most unlike OO.
 
  Yes, Haskell will be `strange'.  But if you think you're `the
  intersection' between Haskell and OO, you'll think things are
  familiar, and you'll be surprised when they turn  out to be
  different.  I'd concentrate on watching out for differences --- but
  then I can't imagine how finding `familiar' ideas would help.
 
  just a sec...
 
  things like
 
 C++ translated into Haskell
 
  come to mind.
 
  But then this has more to do with Monads than with classes. IO, in
  particular, and GL and GLUT, which are state machines and
  thus predestined for OOP.
 
 Your example is very unintuitive and unidiomatic Haskell.  The  
 reference to GL makes me think this is for a `low-level' binding to  
 an imperative library, no?  Those are scarcely good places to learn  
 Haskell.
 
Well, I learnt a lot, knowing GL quite well already and seeing how easy
everything fit together and how easy it was to abstract things away,
like stuffing a bunch of IO actions consisting of GL primitives into a
map, automatically generating and managing display-lists... 

I don't speak C++, btw, just C and Java.

You can't just take years of programming experience and then start
again with calculating Fibonacci numbers, just this time implemented
functionally... There's always this creepy feeling that you understand
everything, although you didn't understand a thing. 

Shivers run down my spine when I think about how 

let amb = 0.2
ambm = 0.2
spec = 0.7
preservingMatrix $ do
materialDiffuse FrontAndBack $= Color4 ambm ambm ambm 0.3
materialSpecular FrontAndBack $= Color4 spec spec spec 0.7
materialShininess FrontAndBack $= 50
border 30 40 (depth * 10) 0.01 True

looks like in C.

or, for that matter, what atrocious code gcc generates if you
parametrise calls to vertex3f with functions.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

___
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 Miguel Mitrofanov

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.


Well, I did something like that a few years ago - it was a sort of  
assembler language, allowing the programmer to, say, sort an array,  
but not to calculate Akkerman function.

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


Re: [Haskell-cafe] Newbie question related to list evaluation

2008-01-06 Thread Andrew Coppin

Felipe Lessa wrote:

As as side note, GHC's flag -Wall would have warned about creating a
variable with a name already in scope.
  


*makes a mental note*

I've created bugs like this far too many times...

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


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

2008-01-06 Thread Ketil Malde
Derek Elkins [EMAIL PROTECTED] writes:

 I don't understand your point. We know what swimming is: floating and
 moving autonomously. 

You're the first one I've heard who would use the term 'swimming' for
ships.  (And to be pedantic, wouldn't you say that fish swim, except
when they float?)

The point - stolen from Dennet, I think -- is that it is not terribly 
relevant wheter machines can think or just, you know, float and move
autonomously, forever voyaging through dark seas...

 For goodness sake, I have *REALLY* the impression that those guys who
 speak about computability of the Universe, 

Who is speaking about computability of the universe?  This looks like
a straw man to me.

 have the mentality of 18 century thinkers for whom the world was
 simple and mechanistic. Or even the mentality of people
 contemporary of Democritus, for whom everything reduced to some
 dance of atoms.

 Or a wave function for the Universe...

So - your counterclaim is that something complex and mystic and
incomprehensible cannot arise from the simple, tangible and
understood?  Perhaps my views are *so* 1980s, but not 18th century, I
think. 

Why is it that we cannot design roads so that we avoid traffic jams?
Don't we understand cars and asphalt?  Quantum effects in the
combustion engine, perhaps?

More seriously, perhaps quantum enters into the equation in how the
brain works, perhaps it is even necessary for thought.  However, I
get worried it's just another mystical mantra, a gratuitous factor
that, lacking any theory about how and what it does, adds nothing to
help understanding the issue.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Dominic Steinitz
Jonathan Cast jonathanccast at fastmail.fm writes:

 
 
  Extensionality is a key part of the definition of all of these
  constructions.  The categorical rules are designed to require, in
  concrete categories, that the range of the two injections into a
  coproduct form a partition of the coproduct, the surjective pairing
  law (fst x, snd x) = x holds, and the eta reduction law (\ x - f x)
  = f holds.  Haskell flaunts all three; while some categories have  
  few
  enough morphisms to get away with this (at least some times),  
  Hask is
  not one of them.
 
  That interpretation is not something that is essential in the notion
  of category, only in certain specific examples of categories
  that you know.
 
 I understand category theory.  I also know that the definitions used  
 are chosen to get Set `right', which means extensionality in that  
 case, and are then extended uniformly across all categories.  This  
 has the effect of requiring similar constructions to those in Set in  
 other concrete categories.
 

Referring to my copy of Sheaves in Geometry and Logic, Moerdijk and Mac Lane
state that in 1963 Lawvere embarked on the daring project of a purely
categorical foundation of all mathematics. Did he fail? I'm probably
misunderstanding what you are saying here but I didn't think you needed sets to
define categories; in fact Set is a topos which has far more structure than a
category. Can you be clearer what you mean by extensionality in this context?
And how it relates to Set?

On a broader note, I'm pleased that this discussion is taking place and I wish
someone would actually write a wiki page on why Haskell isn't a nicely behaved
category and what problems this causes / doesn't cause. I wish I had time.

Dominic.



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


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

2008-01-06 Thread Brandon S. Allbery KF8NH


On Jan 6, 2008, at 15:02 , Ketil Malde wrote:


More seriously, perhaps quantum enters into the equation in how the
brain works, perhaps it is even necessary for thought.  However, I
get worried it's just another mystical mantra, a gratuitous factor
that, lacking any theory about how and what it does, adds nothing to
help understanding the issue.


I should not get into these off-topic things... but the viewpoint  
that worries you is only espoused by people looking for excuses to  
apply their favorite mystical mantra.  Quantum effects are well  
defined, but nonintuitive (for example, particles tunneling through  
a barrier).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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


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

2008-01-06 Thread Ben Franksen
Miguel Mitrofanov wrote:
 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.
 
 Well, I did something like that a few years ago - it was a sort of
 assembler language, allowing the programmer to, say, sort an array,
 but not to calculate Akkerman function.

P. Wadler, in his famous paper Theorems for free!, writes on page
2: Indeed, every recursive function that can be proved total in second
order Peano arithmetic can be written as a term in the Girard/Reynolds
calculus [...]. This includes, for instancs, Ackerman's function [...], but
excludes interpreters for most languages (including the Girard/Reynolds
calculus itself). BTW, another name for the Girard/Reynolds calculus
is (pure) polymorphic lambda calculus; and yes, it is strongly
normalizing. (Wadler cites some papers to support the above claim.)

It seems there is quite a lot of interesting stuff that can be done in a
language where every expression is guaranteed to terminate.

Cheers
Ben

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


Re: [Haskell-cafe] Re: Basic question concerning the category Hask (was: concerning data constructors)

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 12:27 PM, Dominic Steinitz wrote:


Jonathan Cast jonathanccast at fastmail.fm writes:






Extensionality is a key part of the definition of all of these
constructions.  The categorical rules are designed to require, in
concrete categories, that the range of the two injections into a
coproduct form a partition of the coproduct, the surjective  
pairing
law (fst x, snd x) = x holds, and the eta reduction law (\ x -  
f x)

= f holds.  Haskell flaunts all three; while some categories have
few
enough morphisms to get away with this (at least some times),
Hask is
not one of them.


That interpretation is not something that is essential in the notion
of category, only in certain specific examples of categories
that you know.


I understand category theory.  I also know that the definitions used
are chosen to get Set `right', which means extensionality in that
case, and are then extended uniformly across all categories.  This
has the effect of requiring similar constructions to those in Set in
other concrete categories.



Referring to my copy of Sheaves in Geometry and Logic, Moerdijk  
and Mac Lane

state that in 1963 Lawvere embarked on the daring project of a purely
categorical foundation of all mathematics. Did he fail? I'm probably
misunderstanding what you are saying here but I didn't think you  
needed sets to

define categories;


Right.  But category theory is nevertheless `backward compatible'  
with set theory, in the sense that the category theoretic  
constructions in a category satisfying ZFC will be the same  
constructions we are familiar with already.  The category-theoretic  
definitions, when specialized to Set, are precise (up to natural  
isomorphism) definitions of the pre-existing concepts of cartesian  
products, functions, etc. in Set.  Or, to put it another way, the  
category-theoretic definitions are generalizations of those pre- 
existing concepts to other categories.  Hask has a structure that is  
Set-like enough that these concepts generalize very little when  
moving to Hask.



in fact Set is a topos which has far more structure than a
category. Can you be clearer what you mean by extensionality in  
this context?


By `extensionality' I mean the equalities which follow from using  
standard set-theoretic definitions for functions, products,  
coproducts, etc. --- surjective pairing, eta-contraction, etc.  My  
understanding is that, in fact, the category-theoretic definitions  
are designed to capture those equations in diagrams that can be used  
as definitions in arbitrary categories.  It's possible to view those  
definitions, then, as more fundamental descriptions of the concepts  
than what they generalize, but the fact that they are generalizations  
of the ideas from Set shows up in categories similar to Set (and Hask  
is certainly more similar to Set than, say, Vec).


jcc

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


[Haskell-cafe] Re: Concurrency questions

2008-01-06 Thread Ben Franksen
Andrew Coppin wrote:

 Felipe Lessa wrote:
 On Jan 6, 2008 9:30 AM, Andrew Coppin [EMAIL PROTECTED]
 wrote:
   
 2. I have a situation where I have a thread generating some data and
 putting it into a mutable array, and another thread trying to read that
 data. Is there a way I can make the reader thread block if it tries to
 read a cell that hasn't been computed yet, but not introduce too much
 overhead for cells that have been filled in?

I am fairly sure that this is not possible with an MVar that contains the
whole array.

You could, however, keep the information about which elements have already
been initialized in a separate data structure, for instance a set of
indices (using e.g. Data.IntSet)

 If your thread fills the array linearly, you could maintain a variable
 shared by those threads that say the last cell computed, and have the
 read thread check that before reading. I think this wouldn't create
 too much overhead, although it seems like there must be something
 cleverer somewhere.
   
 
 That's just it - it fills the array in a fairly random order. (The
 *scanning* is, however, in linear order.)
 
 It's not a big problem - I can wait for the entire array to be filled,
 and then scan it. But I'd like to do both in parallel if there's a
 reasonably easy way to do it.
 
 I suppose an array of MVars would do it, but
 
 1. How big is an MVar?
 
 2. You have to take the data out of an MVar to read it. In other words,
 only 1 thread can read an MVar at once [by design]. This isn't truly a
 problem in the current case, but it's irritating in principle that I
 can't make it so that once the cell is written, multiple threads can
 read it simultaneously...

I first thought that Control.Concurrent.SampleVar would be your solution but
nope, reading it still makes it empty.

Have you tried STM and TVar? (I mean, an array of TVars).

Cheers
Ben

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


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

2008-01-06 Thread Derek Elkins
On Sun, 2008-01-06 at 09:45 -0800, Jonathan Cast wrote:
 On 6 Jan 2008, at 3:02 AM, Derek Elkins wrote:
 
  On Fri, 2007-12-28 at 17:54 -0600, Jonathan Cast wrote:
 
  Programming languages are generally classified into three groups,
  imperative, functional, and logical.  The difference is in the style
  of programming encouraged (or mandated, for older languages) by the
  language.
 
  Usually the divide is imperative v. declarative with the four major
  paradigms (procedural, OO and logic, FP respectively) being  
  subgroups of
  those divisions.
 
 And your explanation of this classification is?
 
 I find the term `declarative' to be almost completely meaningless.

I was originally thinking of having the final sentence: There are no
clear, accepted meanings for any of these terms.

Many people find any, perhaps all, of the terms: functional, object
oriented, imperative to be almost completely meaningless.  Mostly the
terms have no prescriptive meaning, but rather are defined by example.

At any rate, I wasn't and didn't explain anything as that was not my
intention.  I was merely pointing out that your usage is against the
norms and in a way similar in its disconcertingness to saying,
American politics is classified into three groups, conservatives,
Democrats and libertarians.

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


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

2008-01-06 Thread jerzy . karczmarczuk
Derek Elkins writes: 


Jonathan Cast wrote:

I find the term `declarative' to be almost completely meaningless.


I was originally thinking of having the final sentence: There are no
clear, accepted meanings for any of these terms.


Clear, no.
Accepted, yes. 


Let Jonathan Cast repeat that statement to people who organise conferences
on Declarative Programming, or those who assembled: 


http://en.wikipedia.org/wiki/Declarative_programming
http://burks.brighton.ac.uk/burks/foldoc/90/29.htm
(or http://foldoc.org/foldoc.cgi?declarative+language) 

I can't see what is the purpose of all your argument... 

Jerzy Karczmarczuk 



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


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

2008-01-06 Thread ChrisK

Brandon S. Allbery KF8NH wrote:


On Jan 6, 2008, at 15:02 , Ketil Malde wrote:


More seriously, perhaps quantum enters into the equation in how the
brain works, perhaps it is even necessary for thought.  However, I
get worried it's just another mystical mantra, a gratuitous factor
that, lacking any theory about how and what it does, adds nothing to
help understanding the issue.


The brain, being real, is best modeled by a final theory that physicists have 
not yet (noticed) written down.


how the brain works appears to be though electro- and bio- chemistry, which 
are best modeled/described right now by quantum mechanics.


There are observable quantum correlations that cannot be described by a 
classical theory.


So long as the processes you care about (e.g. whatever the hell consciousness 
is) do not use these non-classical correlations then you can create a simplified 
model that avoids the complexity of quantum theory.




I should not get into these off-topic things... but the viewpoint that 
worries you is only espoused by people looking for excuses to apply 
their favorite mystical mantra.  Quantum effects are well defined, but 
nonintuitive (for example, particles tunneling through a barrier).




Right.  Even if there are some quantum correlations that are used in the brain, 
then you just use a more complicated mathematical model.  Nothing 
mystical/spooky/special about it.


Final note:  Quantum tunneling is only surprising if you insist on thinking 
about particles or photons meeting some kind of impenetrable wall (made of 
what?).  All real barriers are made of forces exerted by other particles.  So 
the whole idea of a barrier is flawed in this regime.


--
Chris

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


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

2008-01-06 Thread Derek Elkins
On Sun, 2008-01-06 at 22:31 +0100, [EMAIL PROTECTED]
wrote:
 Derek Elkins writes: 
 
  Jonathan Cast wrote:
  I find the term `declarative' to be almost completely meaningless.
  
  I was originally thinking of having the final sentence: There are no
  clear, accepted meanings for any of these terms.
 
 Clear, no.
 Accepted, yes. 

That was a conjunction: clear AND accepted.

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


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

2008-01-06 Thread Jonathan Cast


On 6 Jan 2008, at 1:31 PM, [EMAIL PROTECTED] wrote:


Derek Elkins writes:

Jonathan Cast wrote:

I find the term `declarative' to be almost completely meaningless.

I was originally thinking of having the final sentence: There are no
clear, accepted meanings for any of these terms.


Clear, no.
Accepted, yes.
Let Jonathan Cast repeat that statement to people who organise  
conferences

on Declarative Programming, or those who assembled:
http://en.wikipedia.org/wiki/Declarative_programming
http://burks.brighton.ac.uk/burks/foldoc/90/29.htm
(or http://foldoc.org/foldoc.cgi?declarative+language)


To quote your last citation:

 declarative language: Any relational language or functional language.

Yes, the term `declarative' means something in the sense that we can  
tell whether any given language is declarative or not, so I should  
have been more clear.  To wit, I do not believe the term  
`declarative' has any single referent, even in the sense that the  
term `functional' has any single referent.  I find the only  
similarity between Haskell and Prolog to be that neither is imperative.



I can't see what is the purpose of all your argument...


Granted.

jcc

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


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

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 12:13 PM, Derek Elkins wrote:


On Sun, 2008-01-06 at 09:45 -0800, Jonathan Cast wrote:

On 6 Jan 2008, at 3:02 AM, Derek Elkins wrote:


On Fri, 2007-12-28 at 17:54 -0600, Jonathan Cast wrote:


Programming languages are generally classified into three groups,
imperative, functional, and logical.


NB: I will stipulate that most people consider imperative vs.  
declarative to be a further hierarchy above this division.  I will  
even stipulate that most people consider the procedural vs. OO  
distinction other than a distraction :)  So I should have said:  
programming languages may be classified into three groups, ... ---  
where the groups themselves are generally agreed to exist, to be  
mutually exclusive, and to capture the vast majority of programming  
languages.



  The difference is in the style
of programming encouraged (or mandated, for older languages) by the
language.


Usually the divide is imperative v. declarative with the four major
paradigms (procedural, OO and logic, FP respectively) being
subgroups of
those divisions.


And your explanation of this classification is?

I find the term `declarative' to be almost completely meaningless.


I was originally thinking of having the final sentence: There are no
clear, accepted meanings for any of these terms.

Many people find any, perhaps all, of the terms: functional, object
oriented, imperative to be almost completely meaningless.   
Mostly the

terms have no prescriptive meaning, but rather are defined by example.


I was trying to work within this framework.  Most languages support  
both imperative and functional paradigms, these days; but there are  
patterns which are awkward in some languages and natural in others.   
That is what I consider the main distinction.


But, while there are patterns that are natural in all (at least  
structured) imperative languages and no or few non-imperative ones  
(like while loops), I don't know of any patterns that are natural in  
all declarative languages.




At any rate, I wasn't and didn't explain anything as that was not my
intention.  I was merely pointing out that your usage is against the
norms


As a statistical statement, this may be true.


and in a way similar in its disconcertingness to saying,
American politics is classified into three groups, conservatives,
Democrats and libertarians.


Or like saying American politics is classified into three groups,  
statists, Rothbardians, and Randians :)


jcc

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


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

2008-01-06 Thread Achim Schneider
ChrisK [EMAIL PROTECTED] wrote:

 how the brain works appears to be though electro- and bio-
 chemistry, which are best modeled/described right now by quantum
 mechanics.
 
Erm...

There is this story about some military (US afair) training a neural
net to detect tanks in images, I can't find the link right now.

It worked, with amazing 100% accuracy.

Then they threw another batch of images at the net.

It worked, with devastating 50% accuracy.

It turned out that in the first batch, all the pictures with tanks on
them were shot in sunny weather, all the pictures without tanks were
shot with cloudy sky.

It's kind of claiming to understand every single program that ever has
been written and ever will be written just because one understands
touring-complete language X in detail.
 
Or me claiming that I understand more than say 40% of what Jonathan
says, although I do understand English.

-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

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


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

2008-01-06 Thread Derek Elkins
On Sun, 2008-01-06 at 13:48 -0800, Jonathan Cast wrote:
 On 6 Jan 2008, at 1:31 PM, [EMAIL PROTECTED] wrote:
 
  Derek Elkins writes:
  Jonathan Cast wrote:
  I find the term `declarative' to be almost completely meaningless.
  I was originally thinking of having the final sentence: There are no
  clear, accepted meanings for any of these terms.
 
  Clear, no.
  Accepted, yes.
  Let Jonathan Cast repeat that statement to people who organise  
  conferences
  on Declarative Programming, or those who assembled:
  http://en.wikipedia.org/wiki/Declarative_programming
  http://burks.brighton.ac.uk/burks/foldoc/90/29.htm
  (or http://foldoc.org/foldoc.cgi?declarative+language)
 
 To quote your last citation:
 
   declarative language: Any relational language or functional language.
 
 Yes, the term `declarative' means something in the sense that we can  
 tell whether any given language is declarative or not, so I should  
 have been more clear.  To wit, I do not believe the term  
 `declarative' has any single referent, even in the sense that the  
 term `functional' has any single referent.  I find the only  
 similarity between Haskell and Prolog to be that neither is imperative.

Indeed, you've discovered it.  The definition of declarative is often
not imperative.  (Or vice versa, where, as I said earlier, these are
primarily defined by example rather than some predicate.)

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


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

2008-01-06 Thread jerzy . karczmarczuk
Derek Elkins writes: 


Jonathan Cast wrote:


I find the only  
similarity between Haskell and Prolog to be that neither is imperative.


Indeed, you've discovered it.  The definition of declarative is often
not imperative. 


I disagree. Practically. (I won't discuss doctrinal matter nor linguistic
hairsplitting). 


The relational syntax of Prolog is more universal than the functional
notation, since you have logic variables and logical-non-determinism, and
- thus - the possibility of making predicates where the roles of input and
output parameters are not pre-assigned, - 


- but there is a *strong* (meaning important) functional layer within,
and plenty of Prolog algorithms are expressed similarly in Lisp or in
Haskell. 


Many non-deterministic ones have natural translation into the List monad.
Some circular definitions using laziness are related to ones with
non-instantiated logical variables. 


If you don't want to see similarities, you won't.  But I assure you that
I have profited enormously from tha *affinities* between functional and
logic approaches, and you won't convince me that declarative is without
substance. 

Jerzy Karczmarczuk 



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


[Haskell-cafe] Implicit parameters and Arrows/Yampa?

2008-01-06 Thread Peter Verswyvelen
If I understand it correctly, implicit parameters in Haskell allow you to
pass values to functions with explicitly adding a parameter to each of the
functions being called (I appologize for my imperative terminology here.
How would I say this correctly? Being evaluated?)

 

The arrows always use tuples to group the input and output parameters, like:

 

foo :: SF (Int,Int,Int) (Int,Int)

foo = proc (x,y,z) - do

   p - cat - (x,y)

   q - dog - z

   returnA - (p,q)

 where

   cat = proc (x,y) - returnA - (x+y)

   dog = proc z - returnA - 10*z

 

Suppose I don't want to explicitly pass the x and y parameters to the cat
(and deeper) arrows, but make them implicit. I guess that would be
impossible? I mean, I can't use implicit parameters language extension to
make the arrow input parameters implicit?

 

Thanks,

Peter

 

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


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

2008-01-06 Thread Peter Verswyvelen
Jerzy wrote:
 The relational syntax of Prolog is more universal than the functional
 notation, since you have logic variables and logical-non-determinism, and

Isn't this just because mathematically, a function *is* a relation, but not 
vice versa? A relation being just a subset of a Cartesian product of sets, 
while a function being a special kind of relation for which each element in the 
domain has exactly one image? So relations are inherently much more universal 
than functions, but they are not that practical to work with (for a computer 
and/or human?).

Gee, I should not talk about math here, as you category theory guys know a 
thousand times more math than I do ;-)

Cheers,
Peter


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


[Haskell-cafe] GHC's dynamic linker and Windows

2008-01-06 Thread Peter Verswyvelen
I recently tried the latest version of HS-PLUGINS, and it gave an error on
Windows. After a bit of Googling it seemed Conal Elliot had the same
problem. I reported this problem to the author. This is also (one of) the
reason why I could not get YI running on Windows.

 

Now, according to the documentation, HS-PLUGINS seems to be mainly a handy
wrapper around GHC's dynamic linker and compiler. Suppose I would use GHC's
dynamic linker, interpreter and compiler directly (aha GHC as a library);
does this work on Windows, or are there known problems with these?

 

Thanks,

Peter

 

 

 

 

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


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

2008-01-06 Thread jerzy . karczmarczuk
Peter Verswyvelen writes: 


Jerzy wrote:

The relational syntax of Prolog is more universal than the functional
notation, since you have logic variables and logical-non-determinism, and


Isn't this just because mathematically, a function *is* a relation, but not 
vice versa? A relation being just a subset of a Cartesian product of sets, 
while a function being a special kind of relation for which each element in the 
domain has exactly one image? So relations are inherently much more universal 
than functions, but they are not that practical to work with (for a computer 
and/or human?).


You are right. Yes, functions are subsets of relations, and the affinity
between logical and functional programming is all but accidental. But
relations ARE PRACTICAL! Prolog, Mercury, etc. use them. Leda, Life ...
Combined paradigms are not so exotic. 


Gee, I should not talk about math here, as you category theory guys know a 
thousand times more math than I do ;-)


On the contrary, you should.
Tell what is interesting for you.
Don't let hairsplitters monopolize the discussion of mathematical side of
Haskell. I am sick seeing that 75% of true deep discussion turns around ...
sorry for the swearword - 

... bottom. 

Jerzy Karczmarczuk 


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


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

2008-01-06 Thread Derek Elkins
On Sun, 2008-01-06 at 23:28 +0100, [EMAIL PROTECTED]
wrote:
 Derek Elkins writes: 
 
  Jonathan Cast wrote:
 
  I find the only  
  similarity between Haskell and Prolog to be that neither is imperative.
  
  Indeed, you've discovered it.  The definition of declarative is often
  not imperative. 
 
 I disagree. Practically. (I won't discuss doctrinal matter nor linguistic
 hairsplitting). 

I wasn't being that serious there, though oftentimes declarative -is-
used in a way that is mostly meaningless or as a buzzword.  One thing I
will stand by, however, is that the consensus is that declarative and
imperative are meant to be exhaustive and ideally disjoint (though
where to draw the line is tricky), and thus in that sense, declarative
is not imperative (and, as I said originally though you elided it,
vice versa.)

 
 The relational syntax of Prolog is more universal than the functional
 notation, since you have logic variables and logical-non-determinism, and
  - thus - the possibility of making predicates where the roles of input and
 output parameters are not pre-assigned, - 
 
  - but there is a *strong* (meaning important) functional layer within,
 and plenty of Prolog algorithms are expressed similarly in Lisp or in
 Haskell. 
 
 Many non-deterministic ones have natural translation into the List monad.
 Some circular definitions using laziness are related to ones with
 non-instantiated logical variables. 
 
 If you don't want to see similarities, you won't.  But I assure you that
 I have profited enormously from tha *affinities* between functional and
 logic approaches, and you won't convince me that declarative is without
 substance. 

declarative is often used in a way where HTML, XML and such are
declarative languages.

At any rate, also in the elided part of my reply, was the statement that
imperative/declarative are often defined by example, and the above
is just such a case (unless you have a clear definition of functional
and logical).  This simply defines declarative to mean
functional+logical making declarative a pure name devoid of any
descriptive power.

To make this email constructive, however, I will propose a slightly less
fuzzy criterion: namely a declarative language is one that, via the
Curry-Howard correspondence(s), corresponds strongly with (a relatively
standard) logic.  This arguably can be used to give some oomph to the
usage of the term declarative rather than it being just a name, though
I'll not bother.  This recovers the fact that functional and logic
languages are declarative and gives a -specific- similarity.  It agrees
fairly well with the ordering more declarative than determined by
consensus.  Finally, it points the way to allowing other languages
rather than not (functional or logical) = not declarative.

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


Re: [Haskell-cafe] Implicit parameters and Arrows/Yampa?

2008-01-06 Thread Derek Elkins
On Sun, 2008-01-06 at 23:44 +0100, Peter Verswyvelen wrote:
 If I understand it correctly, implicit parameters in Haskell allow you
 to pass values to functions with explicitly adding a parameter to each
 of the functions being “called” (I appologize for my imperative
 terminology here. How would I say this correctly? Being “evaluated”?)

No one is going to get upset if you use call, but if you'd like, the
more technical term in this context is applied, instead of call f
passing x, we would say apply f to x.


 The arrows always use tuples to group the input and output parameters,
 like:
 
  
 
 foo :: SF (Int,Int,Int) (Int,Int)
 
 foo = proc (x,y,z) - do
 
p - cat - (x,y)
 
q - dog - z
 
returnA - (p,q)
 
  where
 
cat = proc (x,y) - returnA - (x+y)
 
dog = proc z - returnA - 10*z
 
  
 
 Suppose I don’t want to explicitly pass the x and y parameters to the
 cat (and deeper) arrows, but make them implicit. I guess that would be
 impossible? I mean, I can’t use implicit parameters language extension
 to make the arrow input parameters implicit?

Implicit parameters add an extra argument to a function conceptually.
What you need is to add an argument to SF which implicit parameters
don't know how to do since SF is just some data structure.  One way to
deal with this is the way you deal with the same problem in Haskell
without implicit parameters. (I never use implicit parameters).  In that
case you would use the Reader monad (transformer).  Similarly, you can
use an equivalent Reader/Environment arrow transformer.

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


[Haskell-cafe] ANN: A triple of new packages for talking to the outside world

2008-01-06 Thread Adam Langley
Over the Xmas break I made some headway on writing an RPC package
since many of the ideas that I want to play with involve such a thing
as a basic building block. However, some might find some of the
spin-off packages that I wrote along the way useful.

* binary-strict:

This is mostly a cut-n-paste job from the excellent binary package
which provides Data.Binary.Strict.Get - a monad which is a drop in
replacement for Get, but which parses strict ByteStrings and returns
an Either, thus one can parse binary data without triggering an
exception on failure.

* codec-libevent:

This parses the tagging IDL files introduced in libevent[1]
1.4.0-beta and later and can generate the Haskell code for them. These
are platform-independent structs (in the C sense) and libevent
provides the complementary C infrastructure for them. You should be
able to understand almost everything these is to know about them from
a quick example:

struct msg {
string from_name = 1;
string to_name = 2;
optional struct[kill] attack = 3;
array struct[run] run = 4;
}

[1] http://monkey.org/~provos/libevent/

* control-timeout:

This module provides simple timeouts - e.g. actions which occur after
a given number of seconds and which can be canceled. It does it in a
not-totally-stupid fashion so that you don't need to worry about
setting hundreds of them.


AGL

-- 
Adam Langley  [EMAIL PROTECTED]
http://www.imperialviolet.org   650-283-9641
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-01-06 Thread Aaron Denney
On 2008-01-06, Jonathan Cast [EMAIL PROTECTED] wrote:
 To wit, I do not believe the term `declarative' has any single
 referent, even in the sense that the term `functional' has any single
 referent.  I find the only similarity between Haskell and Prolog to be
 that neither is imperative.

Have you tried comparing Prolog to GHC's multiparameter type-classes?

-- 
Aaron Denney
--

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


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

2008-01-06 Thread Aaron Denney
On 2008-01-06, ChrisK [EMAIL PROTECTED] wrote:
 Brandon S. Allbery KF8NH wrote:
 
 On Jan 6, 2008, at 15:02 , Ketil Malde wrote:
 
 More seriously, perhaps quantum enters into the equation in how the
 brain works, perhaps it is even necessary for thought.  However, I
 get worried it's just another mystical mantra, a gratuitous factor
 that, lacking any theory about how and what it does, adds nothing to
 help understanding the issue.

 The brain, being real, is best modeled by a final theory that physicists have 
 not yet (noticed) written down.

 how the brain works appears to be though electro- and bio- chemistry, which 
 are best modeled/described right now by quantum mechanics.

Quantum mechanics models these, but for most domains it's a substrate
that is unnecessary -- modeling at the level of chemistry works.

 There are observable quantum correlations that cannot be described by a 
 classical theory.

Not in the brain.  It's *way* too warm and squishy.

 So long as the processes you care about (e.g. whatever the hell consciousness 
 is) do not use these non-classical correlations then you can create a 
 simplified 
 model that avoids the complexity of quantum theory.

Right.

-- 
Aaron Denney
--

___
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

2008-01-06 Thread Jonathan Cast

On 6 Jan 2008, at 4:00 PM, Aaron Denney wrote:


On 2008-01-06, Jonathan Cast [EMAIL PROTECTED] wrote:

To wit, I do not believe the term `declarative' has any single
referent, even in the sense that the term `functional' has any single
referent.  I find the only similarity between Haskell and Prolog  
to be

that neither is imperative.


Have you tried comparing Prolog to GHC's multiparameter type-classes?


Well, they both express relations, they both stand in opposition to  
more basically functional approaches, and they are interpreted at  
entirely different points in the program's lifetime.


So I guess you could find lots of points of comparison.  Similarity?   
I'm still not convinced.


jcc

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


Re: [Haskell-cafe] Software Tools in Haskell

2008-01-06 Thread gwern0
On 2007.12.12 12:51:58 -0600, Tommy M McGuire [EMAIL PROTECTED] scribbled 
2.7K characters:
 Gwern Branwen wrote:
 Some of those really look like they could be simpler, like 'copy' -
 couldn't that simply be 'main = interact (id)'?
 Have you seen http://haskell.org/haskellwiki/Simple_Unix_tools?
 For example, 'charcount' could be a lot simpler - 'charcount = showln
 . length' would work, wouldn't it, for the core logic, and the whole
 thing might look like:
 main = do (print . showln . length) = getContents
 Similarly wordcount could be a lot shorter, like 'wc_l = showln .
 length . lines'
 (showln is a convenience function: showln a = show a ++ \n)

 Yes, that's absolutely true, and I am adding a section showing
 implementations based on interact as soon as I send this message.  The
 reason I didn't do so before is that I was trying to (to an extent)
 preserve the structure of the original implementations, which means using
 an imperative style.

Yes, I'm looking at it now. Pretty nice.

 Strangely, I have considerably more confidence in the imperative-ish
 Haskell code than I do in the imperative Pascal code, in spite of the fact
 that they are essentially the same.  Probably this is due to the
 referential transparency that monadic IO preserves and that does not even
 enter into the picture in traditional Pascal.  For example, the
 pseudo-nroff implementation has a giant, horrible block of a record
 (containing the state taken directly from KP) that is threaded through the
 program, but I am tolerably happy with it because I know that is the *only*
 state going through the program.

 Further, while interact could probably handle all of the filter-style
 programs (and if I understand correctly, could also work for the main loop
 of the interactive editor)

If your editor is referentially transparent, I think. Something like ed or sed 
could be done, as long as you didn't implement any of the IO stuff (like ! for 
ed).

 and a similar function could handle the later
 file-reading programs, I do not see how to generalize that to the
 out-of-core sort program.

Well, for out-of-core sort, someone several many months back posted a very neat 
solution using ByteStrings which iirc had performance as competitive as GNU 
sort's out-of-core sort

[much searching later]

Ah! Here we go: [Haskell-cafe] External Sort and unsafeInterleaveIO 
http://www.haskell.org/pipermail/haskell-cafe/2007-July/029156.html. I at 
least found it interesting.

 (Plus, interact is scary. :-D )

It's not scary! It's neat!

 I... I want to provide a one-liner for 'detab', but it looks
 impressively monstrous and I'm not sure I understand it.

 If you think that's bad :-)

 detab is one of the programs I do not like.  I kept the direct
 translation approach up through that, but I think it really hides the
 simplicity there; detab copies its input to its output replacing tabs with
 1-8 spaces, based on where the tab occurs in a line.  The only interesting
 state dealt with is the count of characters on each line, but that gets
 hidden, not emphasized.

 On the other hand, I'm not looking for one-liners; I really want clarity as
 opposed to cleverness.

Well, one-liners generally can be expanded to 2 or 3 lines if you want to add 
descriptive variable names. Better to start with a short version and expand it 
where unclear than have a long unclear one in the first place, right?

 One final comment: as regards run-length encoding, there's a really
 neat way to do it. I wrote a little article on how to do it a while
 ago, so I guess I'll just paste it in here. :)

 That *is* neat.

 --
 Tommy M. McGuire

Thanks. It took a while to write, but I never really found any place to put it 
up for other people to read.

--
gwern
GSM Submarine E. 510 ddnp building y friends RDI JCET


pgpHvlS1RIXiQ.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] map/reduce example

2008-01-06 Thread Don Stewart
Just going back to this, the channel issue may be solved by the
strict-concurrency package (strict Chans and MVars), and the general
problem of distributing arrays seems to be solved more thoroughly
by the data parallel array library (map, fold, scanl, filter, zip et
al), not just map and reduce?

It takes care of the problem of forking gang threads, distributing work,
and does so with a pure interface.
 
-- Don

bulat.ziganshin:
 Hello Haskell-Cafe,
 
 i've written small program which demonstrates how map/reduce may be
 implemented in Haskell. it counts amount of words in file, splitting
 it into 64kb blocks processed by two threads. their results are
 combined by another two threads. how it may be made better? in
 particular, is it strict in values send over channels?
 
 {-# LANGUAGE BangPatterns #-}
 
 import Control.Concurrent
 import Control.Concurrent.Chan
 import Control.Monad
 import Data.IORef
 import Data.ByteString.Char8 as B hiding (length)
 import System.Environment
 import System.IO
 
 main = do
   (file:_) - getArgs
   h - openBinaryFile file ReadMode
 
   map- newChan
   reduce - newChan
   result - newChan
 
   replicateM_ 2 (forkIO$ mapThread map reduce)  
   replicateM_ 2 (forkIO$ reduceThread reduce result)
 
   jobs - new 0
   untilM (hIsEOF h) $ do
 str - B.hGet h 65536
 writeChan map str
 jobs += 1
 
   jobs' - val jobs
   writeChan reduce (0,-jobs')
 
   res - readChan result
   print res
 
   
 mapThread map reduce =
   forever $ do
 str - readChan map
 let !sum = length (B.words str)
 writeChan reduce (sum,1)
 
 reduceThread reduce result =
   forever $ do
 (sum1,n1) - readChan reduce
 (sum2,n2) - readChan reduce
 let (!sum,!n) = (sum1+sum2,n1+n2)
 case n of
   0 - writeChan result sum
   _ - writeChan reduce (sum,n)
 
 
 untilM cond action = do
   deny - cond
   unless deny $ do
 action
 untilM cond action
 
 forever action  =  action  forever action
 
 infixl 0 =:, +=
 new = newIORef
 val = readIORef
 a=:b = writeIORef a b
 a+=b = modifyIORef a (\a-a+b)
 
 
 -- 
 Best regards,
  Bulat  mailto:[EMAIL PROTECTED]
 
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] what does @ mean?.....

2008-01-06 Thread Derek Elkins
On Fri, 2007-12-28 at 09:51 -0700, Luke Palmer wrote:
 On Dec 28, 2007 9:35 AM, Jules Bean [EMAIL PROTECTED] wrote:
  In particular, adding sharing can stop something being GCed, which can
  convert an algorithm which runs in linear time and constant space to one
  which runs in linear space (and therefore, perhaps, quadratic time).
 
 I've heard of this before, but can you give an example?

I don't know why they were so modest.  Run the following two programs in
the Haskell implementation of your choice

1)

powerset [] = [[]]
powerset (x:xs) = powerset xs ++ map (x:) (powerset xs)

2)

powerset [] = [[]]
powerset (x:xs) = xss ++ map (x:) xss
where xss = powerset xs

Compare it on programs such as length (powerset [1..n]) for n in the
range of 20-30.

Make sure you aren't doing anything important when you use the second
version for larger inputs.  These two programs are an extreme case of
trading space for time, and an extreme case of why common subexpression
elimination can be a massive pessimization.  In this particular case,
there is an exponential increase in the size of the live-set.

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


[Haskell-cafe] reifying is-a

2008-01-06 Thread Jorge Marques Pelizzoni


Hi, all! I guess what I am about to ask is currently impossible, but as
you haskellers always manage to amaze me here it goes. Given two type
classes A t and B t, I'd like to derive (two) different A t instances
depending exactly on whether t is an instance of B. In other words, is it
possible to define a type-level function/class IsB t f such that:

IsB t HTrue = (B t) exists
IsB t HFalse = otherwise?

If not, is this wish intrisically pointless?

Thanks in advance. Cheers,

Jorge M. Pelizzoni
ICMC - Universidade de São Paulo

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


Re: [Haskell-cafe] PHP/code generation libraries?

2008-01-06 Thread Don Stewart
jgbailey:
 I'm working on a project which would generate a PHP data-access layer
 from a Haskell model. I'm wondering what libraries might be already be
 available for generating PHP or other types of code. The
 pretty-printing library is one option. Any other suggestions?
 

i only know of pretty printers/parsers for C. not php.

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


Re: [Haskell-cafe] ANN: A triple of new packages for talking to the outside world

2008-01-06 Thread Bryan O'Sullivan
Adam Langley wrote:

 This is mostly a cut-n-paste job from the excellent binary package
 which provides Data.Binary.Strict.Get - a monad which is a drop in
 replacement for Get, but which parses strict ByteStrings and returns
 an Either,

Ooh, nice.  We could really do with an incremental version, too, which
could be spoonfed chunks of bytes, and dole out values as
deserialisation completes.

Passing back a Left String is in some sense not much of an improvement
over calling error, as if I merely doesn't have enough bytes accumulated
yet, I can't restart parsing from the point the bytes ran out.  Any
chance you'd like to hand back a continuation instead?

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


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

2008-01-06 Thread Bryan O'Sullivan
Achim Schneider wrote:

 There is this story about some military (US afair) training a neural
 net to detect tanks in images, I can't find the link right now.
 
 It worked, with amazing 100% accuracy.
 
 Then they threw another batch of images at the net.
 
 It worked, with devastating 50% accuracy.

Indeed.  This is not the sort of thing you want to get wrong.

http://blog.wired.com/defense/2007/10/robot-cannon-ki.html

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