[Haskell-cafe] FunctionalJ - a library for Functional Programming in Java

2006-01-11 Thread Graham Klyne
A colleague alerted me to this, which I thought might be of interest here:

  http://www.theserverside.com/news/thread.tss?thread_id=38430

(I have already found that my Haskell experiences have influenced my Python
programming;  maybe there's also hope for my Java?)

#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] FunctionalJ - a library for Functional Programming in Java

2006-01-11 Thread Bjorn Bringert

Graham Klyne wrote:

A colleague alerted me to this, which I thought might be of interest here:

  http://www.theserverside.com/news/thread.tss?thread_id=38430

(I have already found that my Haskell experiences have influenced my Python
programming;  maybe there's also hope for my Java?)


I've haven't seen this before, thanks!

I wrote a similar library, Higher-Order Java (HOJ), a few years ago:

http://www.cs.chalmers.se/~bringert/hoj/

My library is less polished but seems to have more static typing. It 
uses parametrized classes (as introduced in Java 1.5) to achieve this.


FunctionalJ seems to lack static typing, for example map has the type:

List map(Function p_function, List p_list)

In HOJ, it has this type:

A,B IteratorB map(FunA,B f, Iterator? extends A xs)


In the end, I never published anything about this, since it seems too 
cumbersome to use in practice. A simple lambda expressions requires a 
lot of typing overhead. This function from the Pizza paper [1]:


fun boolean(char c) {
  n++; return '0' = c  c  '0' + r;
}

becomes this in HOJ:

new FunCharacter,Boolean () {
 public Boolean apply (Character c) {
n++;
return '0' = c  c  '0' + r;
 }
  }

/Björn

[1] Pizza into Java: Translating Theory into Practice, M. Odersky and P. 
Wadler, 1997

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


Re: [Haskell-cafe] Re: Space usage problems

2006-01-11 Thread Ian Lynagh
On Wed, Jan 11, 2006 at 10:36:47AM +, Simon Marlow wrote:
 
 My suggestion: don't use the lazy state monad if you can help it.

But a strict state monad would force everything to be loaded into memory
at once, right?

What would you suggest I use instead?

Or do I just have to tread carefully to keep this optimisation happy
until the GCer is improved?


Thanks
Ian

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


[Haskell-cafe] Re: Space usage problems

2006-01-11 Thread Simon Marlow

Ian Lynagh wrote:

On Wed, Jan 11, 2006 at 10:36:47AM +, Simon Marlow wrote:


My suggestion: don't use the lazy state monad if you can help it.


But a strict state monad would force everything to be loaded into memory
at once, right?

What would you suggest I use instead?


I'm not sure - can you describe exactly what you want to do from a 
higher level?  It might help to re-think the problem from the top down.



Or do I just have to tread carefully to keep this optimisation happy
until the GCer is improved?


I can't see us fixing this in the short term, I'm afraid.

Cheers,
Simon

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


[Haskell-cafe] Re: Shootout favoring imperative code

2006-01-11 Thread Einar Karttunen
On 09.01 11:32, Simon Marlow wrote:
 Sebastian Sylvan wrote:
 
 It would be neat if the PackedString library contained functions such
 as hGetLine etc. It does have a function for reading from a buffer,
 but it won't stop at a newline...
 But yeah, fast string manipulation is difficult when using a
 linked-list representation...
 
 My version of the packed string library does have an hGetLine.  Don 
 Stewart was merging my version with his fps at some point, Don - any 
 news on that?

Getting a fast FastPackedString will solve the problems with many
benchmarks. A similar thing for arrays would be nice - although
this is more about inteface:

 module Data.Array.UnsafeOps where

 import Data.Array.Base hiding((!))

 {-# INLINE (!) #-}
 (!) :: MArray a e m = a Int e - Int - m e
 (!) = unsafeRead

 {-# INLINE set #-}
 set :: MArray a e m = a Int e - Int - e - m ()
 set = unsafeWrite

 {-# INLINE swap #-}
 swap :: MArray a e m = a Int e - Int - Int - m ()
 swap arr x y = do xv - arr ! x
   yv - arr ! y
   set arr x yv
   set arr y xv

 {-# INLINE combineTo #-}
 combineTo :: MArray a e m = a Int e - Int - (e - e - e) - a Int e - 
 Int - m ()
 combineTo a0 i0 f a1 i1 = do v0 - a0 ! i0
  v1 - a1 ! i1
  set a0 i0 $! f v0 v1

and so forth. Usually imperative solutions have something like
a[i] += b[i], which currently is quite tedious and ugly to
translate to MArrays. Now it would become combineTo a i (+) b i.

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


Re: [Haskell-cafe] I/O and utf8

2006-01-11 Thread Einar Karttunen
On 10.01 10:25, Bulat Ziganshin wrote:
 i have the question about this issue - i also want to provide
 autodetection mechanism, which relies on first bytes of text files to
 set proper encoding. what is the standard rules to encode utf8/utf16
 encoding used for text in file in these first bytes?

The BOM is used to mark the encoding
(http://en.wikipedia.org/wiki/Byte_Order_Mark), but most
UTF-8 streams lack it. I have not seen it used in UTF-8 files either.

Do you plan on supporting things like HTTP where the character set
is only known in the middle of the parsing?

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


Re: [Haskell-cafe] Re: Chameneos

2006-01-11 Thread Chris Kuklewicz
Aaron Denney wrote:
 On 2006-01-06, Chris Kuklewicz [EMAIL PROTECTED] wrote:
 
One could make an MVar version which did not use a meeting thread, and I
welcome someone to do that.  I have no proof that the current solution
is really the fastest architecture.
 
 
 I've done so -- on my machine it's comparable (within 1%) of the meeting
 thread version.  It's been posted on the wiki.  Comments and speed-up
 ideas welcome.
 

The old version with the meeting place thread has been disqualified
(along with Erlang submissions). I have Aaron's wiki posting and tweaked
it, posting it back to the wiki.

The speed is the same, or perhaps faster, than the old code.

I will submit this in a day or so assuming no other contribution.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Help compiling School of Expression graphics library?

2006-01-11 Thread Rakesh Malik
I'm trying to build the GraphicsLib code in Linux, Fedora. I have the
March '05 version of Hugs installed (and ghc, but that doesn't seem to
be relevant to this).

The first bit of puzzlement comes from the error messages I'm getting:
ffihugs +G +LX_stub_ffi.c X.hs
Warning: unknown toggle `G'; ignoring.
Warning: unknown toggle `L'; ignoring.
runhugs: Unable to initialise Hugs (Unrecognised option)

Hugs is on my path ($HOME/hugs/bin), and I edited the Makefile to point the
hugs_install home directory to $HOME/hugs. X_dir is correct, it has
lib/libX11.a and
include/X11/X.h.

My gc version is: gcc (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8)
(I don't know whether that's relevant, but just in case.)

Thanks for any help you can provide!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Help compiling School of Expression graphics library?

2006-01-11 Thread Jared Updike
Someone else had this problem, I think.

http://www.mail-archive.com/haskell-cafe@haskell.org/msg11358.html

  Jared.

On 1/11/06, Rakesh Malik [EMAIL PROTECTED] wrote:
 I'm trying to build the GraphicsLib code in Linux, Fedora. I have the
 March '05 version of Hugs installed (and ghc, but that doesn't seem to
 be relevant to this).

 The first bit of puzzlement comes from the error messages I'm getting:
 ffihugs +G +LX_stub_ffi.c X.hs
 Warning: unknown toggle `G'; ignoring.
 Warning: unknown toggle `L'; ignoring.
 runhugs: Unable to initialise Hugs (Unrecognised option)

 Hugs is on my path ($HOME/hugs/bin), and I edited the Makefile to point the
 hugs_install home directory to $HOME/hugs. X_dir is correct, it has
 lib/libX11.a and
 include/X11/X.h.

 My gc version is: gcc (GCC) 4.0.0 20050519 (Red Hat 4.0.0-8)
 (I don't know whether that's relevant, but just in case.)

 Thanks for any help you can provide!
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



--
[EMAIL PROTECTED]
http://www.updike.org/~jared/
reverse )-:
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Help compiling School of Expression graphics library?

2006-01-11 Thread Ross Paterson
On Wed, Jan 11, 2006 at 11:25:42AM -0500, Rakesh Malik wrote:
 I'm trying to build the GraphicsLib code in Linux, Fedora. I have the
 March '05 version of Hugs installed (and ghc, but that doesn't seem to
 be relevant to this).

The graphics library should be included with Hugs: the module is
called Graphics.SOE or SOEGraphics.

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


Re: [Haskell-cafe] Help compiling School of Expression graphics library?

2006-01-11 Thread Rakesh Malik
Indeed it is!

Thanks, both of you, for the quick responses.

On 1/11/06, Ross Paterson [EMAIL PROTECTED] wrote:
 On Wed, Jan 11, 2006 at 11:25:42AM -0500, Rakesh Malik wrote:
  I'm trying to build the GraphicsLib code in Linux, Fedora. I have the
  March '05 version of Hugs installed (and ghc, but that doesn't seem to
  be relevant to this).

 The graphics library should be included with Hugs: the module is
 called Graphics.SOE or SOEGraphics.


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


[Haskell-cafe] Re: Chameneos

2006-01-11 Thread Aaron Denney
On 2006-01-11, Chris Kuklewicz [EMAIL PROTECTED] wrote:
 Aaron Denney wrote:
 The old version with the meeting place thread has been disqualified
 (along with Erlang submissions).

Is this reasoning explained and clarified anywhere, or did they just
move both to the interesting alternatives?  The forums there seem to
be useless, and the mailing list does not appear to be used anymore.

-- 
Aaron Denney
--

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


Re: [Haskell-cafe] Re: Chameneos

2006-01-11 Thread Isaac Gouy


--- Aaron Denney [EMAIL PROTECTED] wrote:

 On 2006-01-11, Chris Kuklewicz
 [EMAIL PROTECTED] wrote:
  Aaron Denney wrote:
  The old version with the meeting place thread has
 been disqualified
  (along with Erlang submissions).
 
 Is this reasoning explained and clarified anywhere,
 or did they just
 move both to the interesting alternatives?  The
 forums there seem to
 be useless, and the mailing list does not appear to
 be used anymore.

The forums there seem to be useless because...?

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Chameneos

2006-01-11 Thread Aaron Denney
On 2006-01-11, Isaac Gouy [EMAIL PROTECTED] wrote:


 --- Aaron Denney [EMAIL PROTECTED] wrote:

 On 2006-01-11, Chris Kuklewicz
 [EMAIL PROTECTED] wrote:
  Aaron Denney wrote:
  The old version with the meeting place thread has
 been disqualified
  (along with Erlang submissions).
 
 Is this reasoning explained and clarified anywhere,
 or did they just
 move both to the interesting alternatives?  The
 forums there seem to
 be useless, and the mailing list does not appear to
 be used anymore.

 The forums there seem to be useless because...?

Because I can't find anything relevant (and I did look).  I can't even
tell where such an announcement would have been made.  It's mixed up in
a dozen different little areas, without a unified search function, and
the interface, as always with web forums, truely awful compared to newsgroups
and mailing lists.

The usual, in other words.

-- 
Aaron Denney
--

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


Re: [Haskell-cafe] Re: Chameneos

2006-01-11 Thread Isaac Gouy
--- Aaron Denney [EMAIL PROTECTED] wrote:
  The forums there seem to be useless because...?
 
 Because I can't find anything relevant (and I did
 look).  I can't even
 tell where such an announcement would have been
 made.  

Ah! Useful for finding an announcement - maybe not.
otoh the forums do allow QA without subscription.

In this case, there was no announcement - just a
notification to Einar Karttunen - but if you look at
the programs on the website you'll find this note:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneoslang=ghcid=2#about

And that was already commented on by folk on this
mailing-list.



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] multiline strings in haskell?

2006-01-11 Thread Michael Vanier
Is there any support for multi-line string literals in Haskell?  I've 
done a web search and come up empty.  I'm thinking of using Haskell to 
generate web pages and having multi-line strings would be very useful.


Mike

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


Re: [Haskell-cafe] multiline strings in haskell?

2006-01-11 Thread Michael Vanier

Yes, just like that ;-)  Thanks!

Now if somebody has a string interpolation library, I'd be a pretty 
happy camper ;-)


Mike



mvanier:
Is there any support for multi-line string literals in Haskell?  I've 
done a web search and come up empty.  I'm thinking of using Haskell to 
generate web pages and having multi-line strings would be very useful.


Do you mean like this:

string =  line one\n\
 \   line two is here\n\
 \   line three is this line\n


$ echo 'putStr string' | ghci A.hs
 line one
   line two is here
   line three is this line

-- Don

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


[Haskell-cafe] Re: Chameneos

2006-01-11 Thread Aaron Denney
On 2006-01-11, Isaac Gouy [EMAIL PROTECTED] wrote:
 Ah! Useful for finding an announcement - maybe not.
 otoh the forums do allow QA without subscription.

And requiring subscriptions is necessary to avoid spam.  Being able to
hash things out without checking yet another bulletin board regularly is
really nice.  (Though things did get out of hand, and rather heated on
the shootout list).

 In this case, there was no announcement

Okay.

 http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneoslang=ghcid=2#about

Yeah, I found that, eventually.  The thing is, it'd be nice to have
clarifications to the benchmark spec caused by such creative attempts on
the benchmark page somewhere.  A seperate benchmark clarifications
forum might also work, but be less convenient.

Also, even though I brought up the concern, that the manager thread
might not be considered acceptable, I personally think the seperate
threads should be accepted.

I see the manager thread as just an implementation technique for
symmetrically synchronizing the other threads.  It's not a primitive,
like a built in barrier n function would be.  Of course, neither is the
lock this and see what else is there technique, which I see as being
at the same level.

I guess this goes to my dissatisfaction with the same *exact* way
evolution of the shootout, which is now a lost battle.  Is the task
synchronize these four threads, two at a time, or synchronize these
four threads, two at a time using the most primitive facilities
available in your language that most closely resemble the orthodox
parallelism paradigm.  I don't, for example, see a good way to do this
synchronization in Occam without using a manager thread.

In fact, the linked paper describes the meeting place as being a
server which has the connotation to me of being at least another
thread, though none of the example programs use a seperate thread.

Anyways, your shootout, your hard work, your rules, but having rulings
on what's acceptable be easier to find would be nice.

 And that was already commented on by folk on this mailing-list.

Right, but no pointer to it, and it wasn't immediately obvious to me.

-- 
Aaron Denney
--

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


Re: [Haskell-cafe] multiline strings in haskell?

2006-01-11 Thread Donald Bruce Stewart
Oh, like this (by Stefan Wehr):

http://www.cse.unsw.edu.au/~dons/code/icfp05/tests/unit-tests/VariableExpansion.hs


$ ghci -fth VariableExpansion.hs
*VariableExpansion let x = 7 in $( expand ${x} )
7
*VariableExpansion let url = http://www.google.com;
*VariableExpansion $( expand Here is my url: ${url}. Do you like it? )
Here is my url: \http://www.google.com\;. Do you like it?

Cheers,
  Don

mvanier:
 Yes, just like that ;-)  Thanks!
 
 Now if somebody has a string interpolation library, I'd be a pretty 
 happy camper ;-)
 
 Mike
 
 
 mvanier:
 Is there any support for multi-line string literals in Haskell?  I've 
 done a web search and come up empty.  I'm thinking of using Haskell to 
 generate web pages and having multi-line strings would be very useful.
 
 Do you mean like this:
 
 string =  line one\n\
  \   line two is here\n\
  \   line three is this line\n
 
 
 $ echo 'putStr string' | ghci A.hs
  line one
line two is here
line three is this line
 
 -- Don
 ___
 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] multiline strings in haskell?

2006-01-11 Thread Michael Vanier

Excellent! Thanks.

Mike

Donald Bruce Stewart wrote:

Oh, like this (by Stefan Wehr):
http://www.cse.unsw.edu.au/~dons/code/icfp05/tests/unit-tests/VariableExpansion.hs


$ ghci -fth VariableExpansion.hs
*VariableExpansion let x = 7 in $( expand ${x} )
7
*VariableExpansion let url = http://www.google.com;
*VariableExpansion $( expand Here is my url: ${url}. Do you like it? )
Here is my url: \http://www.google.com\;. Do you like it?

Cheers,
  Don

mvanier:

Yes, just like that ;-)  Thanks!

Now if somebody has a string interpolation library, I'd be a pretty 
happy camper ;-)


Mike



mvanier:
Is there any support for multi-line string literals in Haskell?  I've 
done a web search and come up empty.  I'm thinking of using Haskell to 
generate web pages and having multi-line strings would be very useful.

Do you mean like this:

   string =  line one\n\
\   line two is here\n\
\   line three is this line\n


$ echo 'putStr string' | ghci A.hs
line one
  line two is here
  line three is this line

-- Don

___
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


[Haskell-cafe] Haskell DB bindings

2006-01-11 Thread oleg

Krasimir Angelov wrote:
 There are three active database libraries: HDBC, HSQL and Takusen.
 It is quite disappointing from my point of view. Recently there was
 the same situation with the GUI libraires. 

I think the dichotomy between lower-level Haskell libraries (whose API
is closer/faithful to the underlying library) and higher-level, more
idiomatic libraries will always exist, because there is need for
both. Regarding GUI libraries, the bulk of wxHaskell is close to
wxWindows. However, there are also more higher-level, more idiomatic
interfaces built on the top of it. Takusen has its own lower-level
layer -- which can be replaced with other suitable lower-level layer,
for example, HSQL. By suitable I mean the layer should not improve the
underlying database API too much, e.g., add finalizers to database and
session handlers, because avoiding such finalizers was one of the main
reason for the design of Takusen.

It may be an interesting experiment to see if Takusen proper can be
moved to use HSQL, for example, as the lower-level layer. Also, perhaps
HSQL may find something useful to borrow from Takusen's lower-level
layer.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe