Re: [Haskell-cafe] NumberTheory library

2005-05-11 Thread ajb
G'day all.

Quoting John Meacham <[EMAIL PROTECTED]>:

> Ack. I use the MTL quite extensivly in most of my projects. I hope it
> won't disapear from the standard libraries completely.

For the record, I have no information that the MTL will disappear any
time soon.  However, the proposed roadmap is to move stuff out of hslibs
and into cabal, and that may be the eventual fate of the MTL, especially
if someone proposes something better for future standardisation.

My real point in all this is that using a state monad for the purpose
proposed in the number theory library is (IMO) overkill, despite making
the code slightly prettier, and introduces dependencies which don't need
to be there.

My real real point is that the rules for libraries are slightly different
than the rules for programs.

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


Re: [Haskell-cafe] NumberTheory library

2005-05-11 Thread John Meacham
On Wed, May 11, 2005 at 01:57:58PM -0500, Brian Smith wrote:
> On 5/10/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > The MTL might be deprecated soon,
> > replaced by Iavor's library, for example.
> Is this just a rumor, or is this really the plan? Where is the best place to 
> get lavor's library?

Ack. I use the MTL quite extensivly in most of my projects. I hope it
won't disapear from the standard libraries completely. 
John


-- 
John Meacham - ârepetae.netâjohnâ 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Python?

2005-05-11 Thread Aaron Denney
On 2005-05-11, Michael Vanier <[EMAIL PROTECTED]> wrote:
> Here at Caltech we teach Scheme first (for programming concepts), then
> students can go in several different directions.

I remember the changeover from C first, and I think it was a mistake...

-- 
Aaron Denney
-><-

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Michael Vanier
> Date: Wed, 11 May 2005 13:06:51 +0200
> From: Jerzy Karczmarczuk <[EMAIL PROTECTED]>
> 
> Michael Vanier comments my defense of Matlab:
> 
> >>I used objects, and even a lot of functional
> >>constructs. I don't see any reason to call it a creeping horror.
> >>It is quite homogeneous and simple, and is decently interfaced.
> >>
> >>
> >>
> >
> >It's incredibly inconsistent.  To cite just one example, the syntax is
> >geared towards the notion that "everything is a two-dimensional matrices of
> >double-precision floating point numbers".  If you want to have a
> >three-dimensional array, you can do that, but the syntax is not going to be
> >nearly as elegant, because matlab's array syntax doesn't scale at all.  
> >
> Come on...
> Matlab has cells and the full object-oriented layer nowadays. There
> are short ints, strings, complex numbers, etc. The extensibility is
> good. The overall consistency is reasonable.
> 
> Syntax for 3D arrays?
> Give me one single language where this is natural and immediate.
> We are 2D readers/writers, our way of presenting information is
> 2D within a text editor, and similar problems hit everywhere. I used
> 3D matrices for the image synthesis, for colour  image processing,
> for simulations of physical systems. It wasn't worse, and even better
> than in many other languages.

Python:

# 2-d array:
print a[0][0]

# 3-d array:
print a[0][0][0]

This also applies to most languages, including C.

If you like matlab, go right ahead and use it.  The same goes for Visual
Basic.  I could care less what programming languages you use.  But if you
think matlab is an elegant language, we will have to agree to disagree.
And that is the last word I will say on this subject, since this is a
Haskell mailing list.

Mike

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


[Haskell-cafe] subRegex bug?

2005-05-11 Thread S. Alexander Jacobson
Am I misunderstanding the regex docs?
*MyMod> subRegex (mkRegex "\\." ) "foo.bar" "blah"
"foo*** Exception: Text.Regex.Posix.regcomp: error in pattern
-Alex-
__
S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Python?

2005-05-11 Thread Lemming
Daniel Carrera wrote:
This might be a strange question to ask on a Haskell list, but I do want 
to hear your opinions. What do you think of Python?
I learnt it some years ago to do some simple text processing. Eventually 
I used it for three small projects. I learnt to hate dynamic typing, I 
learnt to hate that a forgotten 'return' is interpreted as 'return 
None', I didn't like that some types were mutable and others not. The 
documentation is poor due to missing types. Maybe it is due to the 
documentation (indexing) or because of the module structure, but it is 
hard to find the functions you need. I found that regular expressions 
are not of that big help for parsing texts. I missed some support for 
processing data 'on the fly'. Haskell's laziness makes a great job in 
this respect. I'm now porting one of my Python projects to Haskell and 
it is really more fun.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Monad library (was: NumberTheory library)

2005-05-11 Thread Iavor Diatchki
Hi,
At some point this was the plan, but I am not sure what happened.
I haven't heard of any such plans at the moment, although if you are
interested in the library (which is in many ways quite simillar to
MTL) you can find it at:
http://www.cse.ogi.edu/~diatchki/monadLib

I have been using it for a while, so at least the basics work.  I have
done a little profiling, but probably not enough.  I don't consider it
to be stable in the sense that I am prepared to change it beyond
fixing bugs.  This may change if more people started using it, but as
far as I know I am currently the only user, which also has benfits :-)

Any and all feedback is welcome.
-Iavor


On 5/11/05, Brian Smith <[EMAIL PROTECTED]> wrote:
> On 5/10/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  > The MTL might be deprecated soon,
>  > replaced by Iavor's library, for example.
> 
>  Hi,
>  
>  Is this just a rumor, or is this really the plan? Where is the best place
> to get lavor's library?
>  
>  Thanks,
>  Brian Smith
>  
> ___
> 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] Python?

2005-05-11 Thread Jacques Carette
[EMAIL PROTECTED] wrote:
Jacques Carette writes: 
> Jerzy Karczmarczuk wrote:
>> Syntax for 3D arrays?
>> Give me one single language where this is natural and immediate.
> 
> I can think of 3: Mathematica, Maple and APL.

I can't see how Maple makes things more *natural and
immediate* than Matlab *in this context*.
I claim that Maple (and Mathematica) are as natural and immediate as Matlab in the context of 2D arrays and matrices, 
and that (at least) Maple is more natural for n-dimensional arrays.

Maple is rich, there are arrays, Arrays, Matrices (which are *not* multi-
dimensional, only two), etc., based on rtables. In which sense rtables
are more natural and immediate than multidim matrices in Matlab?
Indexing is similar (Maple has a full plethora of adjustable indexing
functions, but Matlab can achieve the same with the OO layer). 
You have put your finger on the reason: Maple's indexing into all objects that are an occurence of the family of 
"rectangular tables" (ie where the implementation data-structure is an rtable even though the abstract type might be 
Vector or Matrix or ...) is completely uniform, regardless of dimension.  In Matlab, you have no such abstract uniform 
interface - you have to build it yourself.

I have not looked too closely, but it appears that Mathematica offers something 
equivalent to Maple in this regard.
Matlab's weakness here is that the implementation (array) and the Abstract Data Type of a matrix are confounded into 
one.  In Maple, these are separate, with proper interfaces.  Of course, since it is Maple, users still have 100% 
access to the underlying implementation, for good or ill.

[Talk about initialization options]
Why this is better than in Matlab?
I should have been clearer: I only claim at least as good as Matlab, with definite sub-cases where it is better.
 
> Furthermore, for 'structured' matrices (including sparse), there are 
> simple examples where both Mathematica and Maple are arbitrarily faster 
> than Matlab on LU and QR decompositions, as well as Eigenvalue 
> computations.   
I would like to see some comparisons. Not that I don't believe you, but
Matlab made some progress as well 
I don't have the time to get into detailed comparisons - and much to my horror, the internal white papers where lots 
of the leg work of doing these comparisons were never made public!  Here is a benchmark to try:
[Creates a random 3 by 3 matrix mb but with a banded 30-30 structure, a random 10 vector v and solves mb*x 
= b.  Timing done on my slow Celeron laptop]
with(LinearAlgebra):
N:=3: (bl,bu):=30,30:
mb := RandomMatrix(N,outputoptions=[datatype=float,shape=band[bl,bu]]):
v := RandomVector(N,outputoptions=[datatype=float]):
infolevel[LinearAlgebra]:=2:
st:=time(): LinearSolve(mb,v): time()-st;
LinearSolve:   "using method"   LU
LinearSolve:   "calling external function"
LinearSolve:   "CLAPACK"   hw_dgbtrf_
LinearSolve:   "CLAPACK"   hw_dgbtrs_
1.062
[that is 1.062 seconds!]
Unless you have 6.8 Gigabytes of main memory on your computer, I would not 
attempt this in Matlab.

(although all this "progress" is
sometimes dubious, with the slowing-down of the interface, regression
bugs, etc.; no system is ideal, Maple neither). 
All the mathematical systems suffer greatly (Maple included) from such extremely dubious "progress".  I find the new 
Maple interface close to unusable [luckily for me, work on that started after I had left the company ;-) ].  

The point I am trying to make is that being able to use extremely complex 'types' (like a Matrix has a band structure) 
is what allows Maple to beat Matlab.  And the proper use of concepts like ADTs and interfaces makes it easy to write 
uniform code even if the underlying 'type' varies greatly [There are 13 different internal rtable representations in 
Maple, not counting indexing functions, orientation, type-representation, etc -- but this is invisible to the user].

The big pain with Maple is that it is dynamically typed (this is Haskell-cafe after all!).  On the other hand, things 
like 'this is a banded(30,30) 3x3 matrix' still seem to be out of reach of Haskell  [because the tricks I have 
seen to encode numbers into types all make encoding the number 3 completely unpalatable].

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread karczma
Tim Rowe writes: 

On 5/11/05, Jerzy Karczmarczuk <[EMAIL PROTECTED]> wrote: 

Give me one single language where [3-d arrays are] natural and immediate.
I don't know how Matlab does it, but I find the C++ standard library
vector > >
entirely intuitive (apart, perhaps, for the need for those two spaces)!
Let's precise what I consider to be important in order to call it natural
and immediate. And, in general, useful. 

1. The definition of a concrete object, not just its type, but, say,
 the initialization with constants. Or/and, global initialization with
 zeros. 

2. Easy synthesis of multi-dim matrices out of "planes", of submatrices
 of lesser dimensions;
 it can be an 'overlay', like, say, making  a colour image out of three
 R/G/B planes, or making a 3D surfaces, or aking tensors through
 external products. 

3. Easy indexing, and not only A[i][j][k], etc., but slicing, the extraction
 of sub-dimensional matrices, e.g., one column vector out of a 2D matrix
 in Matlab:  A(3,:). Also, extracting parts (e.g. sub-images). 

 Also, in mathematical context, "intelligent" indexing, e.g. treating
 a matrix as implicitly anti-symmetric. Here the CAS systems as Maple
 or Mathematica provide the adequate tools. C++ of course doesn't,
 unless you overload [] yourself. 

4. Readable iterators, perhaps something more compact than insipid do-loops. 

5. If those matrices are used as mathematical objects: tensors, etc.,
 I want to have some simple notation for inner multiplications/
 contractions, etc. This is not just the syntax problem, but the
 existence of good libraries as well... 

6. Reshaping of those arrays. I thought that Matlab 'reshape' (or something
 similar in Numeric Python) is a baroque, rarely used construction. Now
 I use it quite often... 

So, plenty of things. That's why this is not so trivial... 

Jerzy Karczmarczuk 

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


RE: [Haskell-cafe] Tables in Haskell (data model /business app pr ototyping)

2005-05-11 Thread Bayley, Alistair
> From: Rene de Visser [mailto:[EMAIL PROTECTED] 
> 
> >What do you mean by "external" database? If you just mean "on another
> 
> I would like to write my views and constraints in Haskell, 
> and not in a 
> seperate database language.
> 
> i.e. I want to use Haskell also as declarative active 
> database language to 
> define the business logic and rules.  This would seem to me 
> to be a lot 
> easier when the database is written in Haskell itself and 
> part of the same 
> program.
> 
> Rene.


Well, in that case, HaskellDB is probably about as good as it's gonna get.
Were you looking for something similar to an existing system that you're
familiar with? (Datalog? Kliesli?)

Alistair.

-
*
Confidentiality Note: The information contained in this   message, and any
attachments, may contain confidential   and/or privileged material. It is
intended solely for the   person(s) or entity to which it is addressed. Any
review,   retransmission, dissemination, or taking of any action in
reliance upon this information by persons or entities other   than the
intended recipient(s) is prohibited. If you received  this in error, please
contact the sender and delete the   material from any computer.
*

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread karczma
Samuel Bronson writes about Matlab: 

I had to use it a bit for a class and it was *PURE PAIN* beyond 
the simplest of things.
With my full respect, this is your problem. My students, with some
guidance, managed to implement a small automatic differentiation
package in it, and they are still alive and happy. Another team
worked on physical models of musical instruments, and they finished
the project without trying to murder anybody. 

Syntax for 3D arrays?
Give me one single language where this is natural and immediate.
Numerical Python! Yes, the syntax is Python's, but the syntax doesn't
really do much of anything unless you use it with Numeric. Anyway, the
syntax is quite uniform and general. You can use it for any number of
dimensions (including 0!).
I used NumPy quite recently (with PIL, for image processing; actually
this was a pedagogical attempt to reimplement my old Clean package
Clastic using a vector language, not a functional one. This worked,
moreover NumPy is free.) So I second your good opinion of Numerical Python,
although the story of two not-so compatible implementations, the old
NumPy (or Numeric) and NumArray is a bit annoying. 

But why we have used it?
BECAUSE it is similar to Matlab, in fact cloned somehow *after it...*,
the whole idea of Ufuncs is based on Matlab. So, please, let me keep
my previous opinion that it is not easy to find something explicitly
better than Matlab or its clones in the discussed context. It is
obviously my personal impression, I won't convert anybody, but I will
defend my standpoint. 

Jerzy Karczmarczuk 

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


Re: [Haskell-cafe] NumberTheory library

2005-05-11 Thread Brian Smith
On 5/10/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> The MTL might be deprecated soon,
> replaced by Iavor's library, for example.
Hi,

Is this just a rumor, or is this really the plan? Where is the best place to get lavor's library?

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


Re: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 21, Issue 27

2005-05-11 Thread Samuel Bronson
On 11/05/05, Stijn De Saeger <[EMAIL PROTECTED]> wrote:
> Quinn Dunkan <[EMAIL PROTECTED]> wrote :
> 
> > ... It is very natural to
> > write in a somewhat functional style, especially in regards to
> > sequence processing: higher order functions and listcomps provide the
> > processing and its built in generators and iterator protocol provide
> > some of the benefits of laziness.  Its elementary pattern matching
> > encourages you to return as many values from a function as you need
> > and use zip() (another haskell steal) to iterate over parallel
> > sequences (all pattern matches are irrefutable, though).
> 
> I'm confused... Python has pattern matching ?

Well, we usually call it unpacking. You can only do it on sequences
(maybe just tuples?), it looks like this:

(x, y) = (1, 2)

or this:

x, y = 1, 2

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Samuel Bronson
On 11/05/05, Jerzy Karczmarczuk <[EMAIL PROTECTED]> wrote:
> Michael Vanier comments my defense of Matlab:
> 
> >>I used objects, and even a lot of functional
> >>constructs. I don't see any reason to call it a creeping horror.
> >>It is quite homogeneous and simple, and is decently interfaced.
> >>
> >>
> >>
> >
> >It's incredibly inconsistent.  To cite just one example, the syntax is
> >geared towards the notion that "everything is a two-dimensional matrices of
> >double-precision floating point numbers".  If you want to have a
> >three-dimensional array, you can do that, but the syntax is not going to be
> >nearly as elegant, because matlab's array syntax doesn't scale at all.
> >
> Come on...
> Matlab has cells and the full object-oriented layer nowadays. There
> are short ints, strings, complex numbers, etc. The extensibility is
> good. The overall consistency is reasonable.

I had to use it a bit for a class and it was *PURE PAIN* beyond the
simplest of things.

> Syntax for 3D arrays?
> Give me one single language where this is natural and immediate.

Numerical Python! Yes, the syntax is Python's, but the syntax doesn't
really do much of anything unless you use it with Numeric. Anyway, the
syntax is quite uniform and general. You can use it for any number of
dimensions (including 0!).

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Donn Cave
On Wed, 11 May 2005, Jerzy Karczmarczuk wrote:
> Pierre Barbier de Reuille wrote about Python and lambdas:
>> Well, I would not recommand using lambda functions ! The main reason 
>> is they are limited in that they only accept expressions (ie. not 
>> statements) and you can end up with very ugly things (mainly because 
>> of the lack of if-expressions).
> 
> Oh! You would *like to have imperative statements within LAMBDA*?
> 
> Friend, you are in state of mortal sin!
> 
> I suppose that if somebody decides to use lambdas, he wants to do some
> functional programming, no?

Debatable.

> True, there are no conditional expressions. But there are because of the
> laziness of boolean combinators. This works:
> 
> (x > y) or 'allez en enfer'

Yes, and hallelujah, there are other options too -- suppose we
define a helper function (because "exec" is also a statement)
to execute a compiled code object:

def ex(st, env):
exec(compile(st, '', 'single'), env)

Now we can use this function to compile and execute anything we
like from inside the lambda!

five = lambda x: ex('if x == 5:\n\tprint "five"\nelse:\n\tprint "not 
five"', locals())


Donn

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread karczma
Jacques Carette writes: 

Jerzy Karczmarczuk wrote:
Syntax for 3D arrays?
Give me one single language where this is natural and immediate.
I can think of 3: Mathematica, Maple and APL.
Well, you are the village specialist on Maple here,so I won't argue too
long, but kill me, I can't see how Maple makes things more *natural and
immediate* than Matlab *in this context*.
Maple is rich, there are arrays, Arrays, Matrices (which are *not* multi-
dimensional, only two), etc., based on rtables. In which sense rtables
are more natural and immediate than multidim matrices in Matlab?
Indexing is similar (Maple has a full plethora of adjustable indexing
functions, but Matlab can achieve the same with the OO layer). 

Initialization, hmmm, in Maple there are nested lists, in Matlab it is
a bit awkward, but with 'cat' along any dimension this is not so bad. 

What else? Maple is more rich and more complicated, so it has more
potential 'power', but that wasn't my point. 

Mathematica,... well it has nested lists called Array, or Table, or Matrix
(which doesn't seem to be more than 2-dim either). Why this is better than
in Matlab? 

-- ... from a "normal" user perspective if possible. For such a user APL
doesn't seem to be a popular option, so let's forget it, although it is
a respectable part of history of programming languages. 

== 

Furthermore, for 'structured' matrices (including sparse), there are 
simple examples where both Mathematica and Maple are arbitrarily faster 
than Matlab on LU and QR decompositions, as well as Eigenvalue 
computations.   

While Mathematica and Maple used to be pathetic at numeric computations, 
that has changed a lot in the last 5 years.
I would like to see some comparisons. Not that I don't believe you, but
Matlab made some progress as well (although all this "progress" is
sometimes dubious, with the slowing-down of the interface, regression
bugs, etc.; no system is ideal, Maple neither). 

Jerzy Karczmarczuk 

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Pierre Barbier de Reuille

Jerzy Karczmarczuk a écrit :
Pierre Barbier de Reuille wrote about Python and lambdas:
Well, I would not recommand using lambda functions ! The main reason 
is they are limited in that they only accept expressions (ie. not 
statements) and you can end up with very ugly things (mainly because 
of the lack of if-expressions).

Oh! You would *like to have imperative statements within LAMBDA*?
Friend, you are in state of mortal sin!
I suppose that if somebody decides to use lambdas, he wants to do some
functional programming, no?
True, there are no conditional expressions. But there are because of the
laziness of boolean combinators. This works:
(x > y) or 'allez en enfer'

That's not my point ! I'm only saying there is no if-expression ... so 
you _need_ statements. And if you really want to use lazy boolean 
operators, you'll end up having very ugly code replacing tests ...

Pierre
Jerzy Karczmarczuk
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
--
Pierre Barbier de Reuille
INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France
tel   : (33) 4 67 61 65 77fax   : (33) 4 67 61 56 68
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] and what about AliceML?

2005-05-11 Thread Daniel Carrera
fred wrote:
As long as this group seems to tolerate "What about Haskell and language X?"
As an aside...
This group has been extremely tolerant of my newbie questions. I do want 
to say thank-you to everyone who has been explaining things to me. I've 
learned quite a bit about programming languages the last couple of 
weeks. Just as importantly, I understand better why Haskell rocks, and 
when it is appropriate to use.


has anyone had any experience with AliceML? My initial impression is that it
might be a nice tool for teaching fundamental concepts.
I'd be interested to know too.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] and what about AliceML?

2005-05-11 Thread fred
Hi,

As long as this group seems to tolerate "What about Haskell and language X?"
has anyone had any experience with AliceML? My initial impression is that it
might be a nice tool for teaching fundamental concepts.

---fred

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


Re: [Haskell-cafe] Re: Type classes and definite types

2005-05-11 Thread Krasimir Angelov
Hi Bryn Keller,

The solution for your problem is very simple. You just have to fetch
all values as strings. In this way the library will do all required
conversions for you.

printRow stmt = do
  id <- getFieldValue stmt "ID"
  code <- getFieldValue stmt "Code"
  name <- getFieldValue stmt "Name"
 putStrLn (unwords [id, code, name])


Cheers,
  Krasimir


On 5/6/05, Bryn Keller <[EMAIL PROTECTED]> wrote:
> Max Vasin wrote:
> 
> >Bryn Keller <[EMAIL PROTECTED]> writes:
> >
> >
> >
> >>Hi Max,
> >>
> >>
> >Hello Bryn,
> >
> >
> >
> >>Thanks for pointing this out. It's odd that I don't see that anywhere
> >>in the docs at the HToolkit site:
> >>http://htoolkit.sourceforge.net/doc/hsql/Database.HSQL.html but GHC
> >>certainly believes it exists. However, this doesn't actually solve the
> >>problem. Substituting toSqlValue for show in printRow' gives the same
> >>compile error:
> >>
> >>Main.hs:22:18:
> >>Ambiguous type variable `a' in the constraint:
> >>  `SqlBind a' arising from use of `getFieldValue' at Main.hs:22:18-30
> >>Probable fix: add a type signature that fixes these type variable(s)
> >>
> >>So, like with (show (read s)), we still can't use the function until
> >>we've established a definite type for the value, not just a type
> >>class.
> >>
> >>
> >Yeah...
> >Some more RTFSing shows that we have the
> >
> >getFieldValueType :: Statement -> String -> (SqlType, Bool)
> >
> >which allows us to write
> >
> >printRow stmt = do (id :: Int) <- getFieldValue stmt "ID"
> >   let (codeType, _) = getFieldValueType stmt "Code"
> >   codestr <- case codeType of
> >   SqlChar _ -> do (c :: String) <- 
> > getFieldValue stmt "Code"
> >   return (toSqlValue c)
> >   SqlInteger -> do (i :: Int) <- 
> > getFieldValue stmt "Code"
> >return (toSqlValue i)
> >   -- etc for all SqlType data constructors
> >   putStrLn (unwords [show id, codestr])
> >
> >At least it compiles. But it's ugly :-(
> >
> >
> Ah, good point! Ugly it may be, but at least it works. Thanks for the idea!
> 
> Bryn
> ___
> 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[2]: [Haskell-cafe] Python?

2005-05-11 Thread Bulat Ziganshin
Hello Jerzy,

Wednesday, May 11, 2005, 3:40:51 PM, you wrote:
JK> I suppose that if somebody decides to use lambdas, he wants to do some
JK> functional programming, no?

well, i am use this all the way :)  simplified example of one usage:

(allocate, shrink) <- memoryAllocator buf size
(buf,size) <- allocate 65536
...
shrink buf realsize


another example:

compress read_f write_f = do
  buf <- malloc 65536
  let go =   len <- read_f buf 65536
 when (len>0) $ do
   ...
   write_f outbuf outlen
   go
  go

and i find this feature very convenient

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



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


RE: [Haskell-cafe] Tables in Haskell (data model /business app prototyping)

2005-05-11 Thread Rene de Visser
From: "Bayley, Alistair" <[EMAIL PROTECTED]>
> From: Rene de Visser [mailto:[EMAIL PROTECTED]
>
> I would rather use Haskell also for the persistency, global
> constraint
> maintanence, etc... rather than using an external database.
What do you mean by "external" database? If you just mean "on another
I would like to write my views and constraints in Haskell, and not in a 
seperate database language.

i.e. I want to use Haskell also as declarative active database language to 
define the business logic and rules.  This would seem to me to be a lot 
easier when the database is written in Haskell itself and part of the same 
program.

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Jacques Carette
Jerzy Karczmarczuk <[EMAIL PROTECTED]> wrote:
Syntax for 3D arrays?
Give me one single language where this is natural and immediate.
I can think of 3: Mathematica, Maple and APL.
But I hope you don't
try to convince us that Mathematica is good at number crunching...
For linear algebra, Maple, Mathematica and Matlab all use ATLAS and hardware BLAS (when available).  For IVP ODEs, the 
author of the underlying numerical solver for Matlab and Maple are lead by the same person (Larry Shampine); he has 
publicly stated that he thinks the one for Maple representes the state-of-the-art [mostly because of access to 
symbolic differentiation], with the one in Matlab being just a bit behind.

Furthermore, for 'structured' matrices (including sparse), there are simple examples where both Mathematica and Maple 
are arbitrarily faster than Matlab on LU and QR decompositions, as well as Eigenvalue computations.  

While Mathematica and Maple used to be pathetic at numeric computations, that 
has changed a lot in the last 5 years.
Jacques
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Python?

2005-05-11 Thread Marcin 'Qrczak' Kowalczyk
Quinn Dunkan <[EMAIL PROTECTED]> writes:

> Python has first class functions and lexical scoping, and encourages
> higher-order functions, though to a much lesser degree than a real
> functional language.

It's lexical scoping is limited:

- The syntax can be heavy, as you can't embed a function containing
  statements inside an expression.

- Because of implicit variable definitions (and lack of other syntax
  which could change that) you can't modify variables introduced by
  outer functions.

- Class definitions don't use lexical scoping (definitions introduced
  in a class body are not visible as unqualified names by their bodies).

-- 
   __("< Marcin Kowalczyk
   \__/   [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Tables in Haskell (data model /business app pr ototyping)

2005-05-11 Thread Bayley, Alistair
> From: Rene de Visser [mailto:[EMAIL PROTECTED] 
> 
> I would rather use Haskell also for the persistency, global 
> constraint 
> maintanence, etc... rather than using an external database.
> 
> The only thing I have found so far is HApps, but I haven't 
> figure out how 
> that works.
> 
> Is there anything else?


What do you mean by "external" database? If you just mean "on another
server, accessed via a separately installed library or API" then you should
consider Sqlite as a persistence storage solution. It's a doddle to install
on common platforms, and consists of a single library which links to your
program i.e. it runs in the same process-space.

Both HSQL (and therefore HaskellDB, as it uses HSQL) and Takusen support
Sqlite.

  http://haskelldb.sf.net/
  http://cvs.sf.net/viewcvs.py/haskell-libs/libs/takusen/

Alistair.

-
*
Confidentiality Note: The information contained in this   message, and any
attachments, may contain confidential   and/or privileged material. It is
intended solely for the   person(s) or entity to which it is addressed. Any
review,   retransmission, dissemination, or taking of any action in
reliance upon this information by persons or entities other   than the
intended recipient(s) is prohibited. If you received  this in error, please
contact the sender and delete the   material from any computer.
*

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


[Haskell-cafe] Tables in Haskell (data model /business app prototyping)

2005-05-11 Thread Rene de Visser
Hello,
I have been thinking about using Haskell for prototyping of business apps.
I would rather use Haskell also for the persistency, global constraint 
maintanence, etc... rather than using an external database.

The only thing I have found so far is HApps, but I haven't figure out how 
that works.

Is there anything else?
I guess I could just use lists for the relations, and the state monad.
I would extend the record types witha  deleted flag and a transaction number 
(i.e. simple multi version control).

Then updates would just consist of pushing a new record onto the front of 
the list, and rollbacks and commits come for free.

The only disadvantage I see that I always need to scan through the whole 
list all the time, which will get long, and might even be too slow for 
prototyping.

The lists might also get too large memory wise.
Any suggestions? Any libraries? Any experiences with HApps or prototyping 
business apps with haskell in general?

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Daniel Carrera
Erik de Castro Lopo wrote:
Its good for small scripting tasks. Its good for string processing.
I find the dynamic typing a pain.
What's dynamic typing?
I have a lady friend who wants to learn how to program. I just decided 
to teach her Python for practical reasons:
Its a great first language for people who aren't interested in
making a career of programming.
But I do hesitate. I would like to teach her Haskell because I think 
it's a better language.
Its a better language for people who either have a computer science
background or intend to study computer science. I would not inflict
a language like Haskell on someone who just wants to get the job
done with as little fuss as possible.

Thank you for the info, I really appreciate it. I feel better about 
Python now.


Given my circunstances, do you think that's a reasonable approach for 
teaching her how to program?
Teach her Python. If you try and teach her Haskell she will end up
programming in visual basic :-).
Heh.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Python?

2005-05-11 Thread Jerzy Karczmarczuk
Pierre Barbier de Reuille wrote about Python and lambdas:
Well, I would not recommand using lambda functions ! The main reason 
is they are limited in that they only accept expressions (ie. not 
statements) and you can end up with very ugly things (mainly because 
of the lack of if-expressions).
Oh! You would *like to have imperative statements within LAMBDA*?
Friend, you are in state of mortal sin!
I suppose that if somebody decides to use lambdas, he wants to do some
functional programming, no?
True, there are no conditional expressions. But there are because of the
laziness of boolean combinators. This works:
(x > y) or 'allez en enfer'
Jerzy Karczmarczuk
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Python?

2005-05-11 Thread Jerzy Karczmarczuk
Michael Vanier comments my defense of Matlab:
I used objects, and even a lot of functional
constructs. I don't see any reason to call it a creeping horror.
It is quite homogeneous and simple, and is decently interfaced.
   

It's incredibly inconsistent.  To cite just one example, the syntax is
geared towards the notion that "everything is a two-dimensional matrices of
double-precision floating point numbers".  If you want to have a
three-dimensional array, you can do that, but the syntax is not going to be
nearly as elegant, because matlab's array syntax doesn't scale at all.  

Come on...
Matlab has cells and the full object-oriented layer nowadays. There
are short ints, strings, complex numbers, etc. The extensibility is
good. The overall consistency is reasonable.
Syntax for 3D arrays?
Give me one single language where this is natural and immediate.
We are 2D readers/writers, our way of presenting information is
2D within a text editor, and similar problems hit everywhere. I used
3D matrices for the image synthesis, for colour  image processing,
for simulations of physical systems. It wasn't worse, and even better
than in many other languages.
I
haven't used matlab seriously for a few years (thankfully), but I vaguely
recall several other instances of the same problem.  Basically, matlab
makes programming very easy within a very restricted domain, but if you
want to go outside that domain, you will have to endure a lot of pain.
 

Since you vaguely remember something you are thankfully away
from, I believe I can continue to "endure my pain" and I can assure
all the other readers of this text from the perspective of somebody
who uses Matlab *NOW*, that this "pain" is supportable. Optional
smiley.
The vectorized "comprehension" expressions are really neat.
In contrast, Mathematica has a pretty consistent and elegant language.
 

Since I respect others' religions I won't argue. But I hope you don't
try to convince us that Mathematica is good at number crunching...
Jerzy Karczmarczuk
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Python?

2005-05-11 Thread Graham Klyne
At 19:02 10/05/05 -0400, Daniel Carrera wrote:
Hello,
This might be a strange question to ask on a Haskell list, but I do want 
to hear your opinions. What do you think of Python?
I think it's benefits are neatly summed up by this comment from Tim 
Berners-Lee, "Python is a language you can get into on one battery":
[[
By the way... Python is cool.

I had lamented that it ws a long time since I had a practial hacking 
environment, and Dan Connolly suggested Python as something you could start 
quickly but which would scale to a large system. One day, 15 minutes before 
I had to leave for the airport, I got my laptop back out of my bag, and 
sucked off the web the python 1.6 system and the python tutorial, and a 
copy of a small notation3 parser Dan had hacked together. I was happy to 
find that Python is a language you can get into on one battery! I have been 
happily hacking ever since.

I remember Guido trying to persuade me to use python as I was trying to 
persuade him to write web software!
]]
-- http://dev.w3.org/cvsweb/2000/10/swap/Overview.html?rev=1.20

I was using Python for much of my work before I came to Haskell.  It took 
me a long time to learn to use Haskell anything like effectively (partly, 
but not entirely, because I'd been corrupted by years of imperative 
programming).  I now choose Haskell for my work because its greater 
formality appeals to me for my desired applications, but I still use Python 
and would probably choose it for the kind of use you propose.

To be a "starter language", I think there needs to be some delineation 
between the simple, obvious concepts of functional programming and the more 
advanced notions that are needed to build programming frameworks.  (cf. my 
recent posting referring to a comment by Alan Kay and Smalltalk -- 
http://www.haskell.org//pipermail/haskell-cafe/2005-May/010020.html).

I do think that there's a strong role for functional programming for 
"non-professional" programmers, but I'm not sure that "raw" Haskell is 
it.  I think the Vital project (http://www.cs.kent.ac.uk/projects/vital/) 
is an interesting take (at the level of function rather than specifically 
the visual aspects) but (last time I looked) lacks IO capability.)

#g

Graham Klyne
For email:
http://www.ninebynine.org/#Contact
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] NumberTheory library

2005-05-11 Thread Bo Herlin
Hi
[EMAIL PROTECTED] wrote:
G'day all.
Quoting Bo Herlin <[EMAIL PROTECTED]>:
Great! I like this a LOT.
...
I don't know if I count as a guru or not, but by all means.  Want to
discuss this on-list or off-list?
The code kinda big already, 700 lines + an util-file, so i'll put it 
on-line at http://www.gcab.net/haskell-cafe-table so that we can diskuss 
it on-list.

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Pierre Barbier de Reuille

Daniel Carrera a écrit :
Quinn Dunkan wrote:
Python has first class functions and lexical scoping, and encourages
higher-order functions, though to a much lesser degree than a real
functional language.

I was surprised to hear about first class functions and higher order 
functions. So I googled for a bit, and I found something neat:

--
# Python implementation of Common Lisp's remove_if
def remove_if(predicate, lst):
return [elem for elem in lst if not predicate(elem)]
print remove_if(lambda x:x % 2, [1,2,3,4,5,6,7,8])
--
This is so cool. So there we have a higher order function, passing a 
funtion as an argument, and even lambda notation. Neat.
Well, I would not recommand using lambda functions ! The main reason is 
they are limited in that they only accept expressions (ie. not 
statements) and you can end up with very ugly things (mainly because of 
the lack of if-expressions).

Better use local functions for the same goal ! So your example becomes:
>>> def is_even(x):
...   return x%2
>>> print remove_if(is_even, [1,2,3,4,5,6,7,8])
Or even better:
>>> def is_even(x):
...   return x%2
>>> print remove_if(is_even, xrange(1,9))
And as local functions have lexical closure this is very interesting 
(much more than lambda).


It is very natural to
write in a somewhat functional style, especially in regards to
sequence processing: higher order functions and listcomps provide the
processing and its built in generators and iterator protocol provide
some of the benefits of laziness.

Hhhmmm.. I guess the above is also an example of that.
[snip: lots of very interesting info I didn't know about]
Thank you for all the information. I learned a lot today. I had no idea 
that Python had these features.

Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
--
Pierre Barbier de Reuille
INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France
tel   : (33) 4 67 61 65 77fax   : (33) 4 67 61 56 68
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Python?

2005-05-11 Thread Michael Vanier
> Date: Wed, 11 May 2005 07:49:38 +0200
> From: Jerzy Karczmarczuk <[EMAIL PROTECTED]>
> 
> Michael Vanier wrote:
> 
> >I have enough problems convincing people to learn Scheme.  I've
> >even had people beg me to teach them Matlab as a first programming
> >language, because that is the only language that they needed to get their
> >work done.  Telling them that Matlab's programming language is a creeping
> >horror doesn't sway them at all.
> >  
> >
> Now, why so?
> I won't defend the Matlab language too strongly, but I used it
> for teaching scientific computations, I exploited the vectorized
> expressions, I used objects, and even a lot of functional
> constructs. I don't see any reason to call it a creeping horror.
> It is quite homogeneous and simple, and is decently interfaced.
> 
> Jerzy Karczmarczuk
> 

It's incredibly inconsistent.  To cite just one example, the syntax is
geared towards the notion that "everything is a two-dimensional matrices of
double-precision floating point numbers".  If you want to have a
three-dimensional array, you can do that, but the syntax is not going to be
nearly as elegant, because matlab's array syntax doesn't scale at all.  I
haven't used matlab seriously for a few years (thankfully), but I vaguely
recall several other instances of the same problem.  Basically, matlab
makes programming very easy within a very restricted domain, but if you
want to go outside that domain, you will have to endure a lot of pain.
That is not good language design.

In contrast, Mathematica has a pretty consistent and elegant language.

Mike


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