[Haskell-cafe] RE: gtk2hs and ghc-6.10.4 on Windows (Vista)

2010-02-24 Thread gladstein
In correspondance with Alistair Bayley I learned that there is in fact a
gtk2hs installer for 6.10.4. One can find it by Googling "gtk2hs 6.10.4"
(which I did not think to do). The URL is in

http://www.mail-archive.com/gtk2hs-de...@lists.sourceforge.net/msg00340.html

The installer doesn't work if the Haskell Platform is installed in the
default location, which has spaces in the pathname. Reinstalling Haskell
in, say, c:\HaskellPlatform makes it all work.



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


Re: [Haskell-cafe] Linear programming in Haskell

2010-02-24 Thread Daniel Schüssler
Hello Alberto,

Thank you! I don't have a problem calling for LP at hand right now, but some 
time ago I was looking for such a package. Now I know where to look next time 
:)

Greetings, 
Daniel


On Wednesday 24 February 2010 11:07:08 Alberto Ruiz wrote:
> I have uploaded to hackage an interface to the simplex algorithm based
> on GLPK. It is a very early version, it will probably have lots of
> problems. In the future I would like to add support for integer
> variables (MIP). Any suggestion is welcome.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Testing and module export lists

2010-02-24 Thread Richard O'Keefe

For what it's worth, Erlang addresses this issue with an
-export_all directive, which can be passed as a compiler option.


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


Re: [Haskell-cafe] Testing and module export lists

2010-02-24 Thread Ivan Miljenovic
On 25 February 2010 11:24, Don Stewart  wrote:
> Seriously?? Doesn't that break the module system?

Maybe I misunderstood it; all I know is that Curt Sampson says he uses
this kind of stuff for testing purposes by not having to export
functions.

See the -fwarn-unused-binds section at
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-sanity.html
.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
Charles de Gaulle  - "The better I get to know men, the more I find
myself loving dogs." -
http://www.brainyquote.com/quotes/authors/c/charles_de_gaulle.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Some great results on fused code with the LLVM backend

2010-02-24 Thread Felipe Lessa
On Wed, Feb 24, 2010 at 01:28:56PM -0500, Edward Kmett wrote:
> > * GHC/LLVM bytecode with JIT-option?
>
> There is little preventing this one.

Oh, what a great idea!  C code being inlined into Haskell
functions! :D

If clang were used to compile the C code into LLVM IR, and
everything were linked by LLVM, bang!, the link-time optimizer
would take care of inlining cheap functions into Haskell code
that uses them.

Cheers, =)

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


Re: [Haskell-cafe] Testing and module export lists

2010-02-24 Thread Don Stewart
ivan.miljenovic:
> On 24 February 2010 20:17, Magnus Therning  wrote:
> > I often find that I do want an export list to reduce clutter in the
> > finished code, but for testing I'd like to expose everything in a
> > module.  Is there a nice way to deal with this (using the C
> > pre-processor would not qualify as "nice" ;-)?
> > Maybe there's a switch that causes GHC to simply ignore the export
> > list of a module and export everything?
> 
> If you start a function name with an underscore, it is "implicitly
> exported" by GHC (I can't find the actual documentation page at the
> moment however).  Whilst it may not appear in the export list, you are
> still able to call it from outside the module.

Seriously?? Doesn't that break the module system?

So this should work?

Z.hs
module Z () where
_secret = "10"

M.hs
import Z
main = print _secret

$ runhaskell M.hs
M.hs:3:14: Not in scope: `_secret'
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Testing and module export lists

2010-02-24 Thread Ivan Miljenovic
On 25 February 2010 10:21, Evan Laforge  wrote:
> On Wed, Feb 24, 2010 at 3:10 PM, Ivan Miljenovic
>  wrote:
>> If you start a function name with an underscore, it is "implicitly
>> exported" by GHC (I can't find the actual documentation page at the
>> moment however).  Whilst it may not appear in the export list, you are
>> still able to call it from outside the module.
>
> Wow, I'd never heard of that feature.

Neither had I, until Curt Sampson asked me to support it in
SourceGraph.  Anyway, I've tracked down the documentation page:
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-sanity.html
.  It's not listed explicitly anywhere; different items have different
documentation regarding it throughout the page.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
Samuel Goldwyn  - "I don't think anyone should write their
autobiography until after they're dead." -
http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Testing and module export lists

2010-02-24 Thread Evan Laforge
On Wed, Feb 24, 2010 at 3:10 PM, Ivan Miljenovic
 wrote:
> On 24 February 2010 20:17, Magnus Therning  wrote:
>> I often find that I do want an export list to reduce clutter in the
>> finished code, but for testing I'd like to expose everything in a
>> module.  Is there a nice way to deal with this (using the C
>> pre-processor would not qualify as "nice" ;-)?
>> Maybe there's a switch that causes GHC to simply ignore the export
>> list of a module and export everything?
>
> If you start a function name with an underscore, it is "implicitly
> exported" by GHC (I can't find the actual documentation page at the
> moment however).  Whilst it may not appear in the export list, you are
> still able to call it from outside the module.
>
> This will, however, result in "ugly" function names as well as
> possibly still have those items appear in the haddock documentation...

Wow, I'd never heard of that feature.

I currently export everything because under development it's too much
hassle to maintain export lists.  However when modules stabilize I
think export lists are a good idea because then GHC can warn about
unused functions and and hopefully eliminate internal bindings if they
are all inlined.

However, testing individual functions is much easier to understand and
leads to shorter and less brittle tests, with clearer failures.  So
when the time comes I'll probably use #ifdef.  That way I can run
presumably ghci with -DTESTING as well and bypass the other annoying
thing about export lists, which is that you have to get ghci to byte
compile to see the internal symbols.

It's not that much work to add #ifdef to each export list especially
compared to the work of writing it in the first place, but it would
still be nicer if there were a compiler flag that did this explicitly.
 The underscore thing seems sub-optimal to me because it doesn't help
you with unused functions or dead code elimination.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Testing and module export lists

2010-02-24 Thread Ivan Miljenovic
On 24 February 2010 20:17, Magnus Therning  wrote:
> I often find that I do want an export list to reduce clutter in the
> finished code, but for testing I'd like to expose everything in a
> module.  Is there a nice way to deal with this (using the C
> pre-processor would not qualify as "nice" ;-)?
> Maybe there's a switch that causes GHC to simply ignore the export
> list of a module and export everything?

If you start a function name with an underscore, it is "implicitly
exported" by GHC (I can't find the actual documentation page at the
moment however).  Whilst it may not appear in the export list, you are
still able to call it from outside the module.

This will, however, result in "ugly" function names as well as
possibly still have those items appear in the haddock documentation...

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
Joan Crawford  - "I, Joan Crawford, I believe in the dollar.
Everything I earn, I spend." -
http://www.brainyquote.com/quotes/authors/j/joan_crawford.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Lazy IO with recursive reads?

2010-02-24 Thread Brandon S. Allbery KF8NH

On Feb 24, 2010, at 16:17 , Fabian Roth wrote:

Using UnsafeIO, however, leaves a creepy unsafe feeling...
I don't fully understand though why it is unsafe. Doesn't  
hGetContents do the exact same thing (i.e. reading from IO returning  
a lazy string) but does not require UnsafeIO.


It does; it's just hidden *inside* hGetContents where you can't see it.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Function to detect duplicates

2010-02-24 Thread Casey Hawthorne
On Tue, 23 Feb 2010 08:30:18 -0300, you wrote:

>Hi folks,
>
>While solving a puzzle, I was posed the problem of finding if there was no
>duplicates on a list.

Must it be a list data structure(DS) or list ADT?

Mergesort can be parallelized.

>
>Best regards,
>
>Rafael


If space is at a premium you might want to look at a Bloom Filter.

http://en.wikipedia.org/wiki/Bloom_filter

The Bloom filter, conceived by Burton Howard Bloom in 1970,[1] is a
space-efficient probabilistic data structure that is used to test
whether an element is a member of a set. False positives are possible,
but false negatives are not. Elements can be added to the set, but not
removed (though this can be addressed with a counting filter). The
more elements that are added to the set, the larger the probability of
false positives.


The book "Real World Haskell" has an implementation.
--
Regards,
Casey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OpenSUSE 11.2

2010-02-24 Thread Daniel Fischer
Am Mittwoch 24 Februar 2010 23:17:46 schrieb Andrew Coppin:
> Erlend Hamberg wrote:
> > if you open the software manager and go to configuration →
> > repositories, you should be able to add new software sources. i use
> > the following repository:
> >
> > Server name: download.opensuse.org
> > Directory: /repositories/devel:/languages:/haskell/openSUSE_11.2/
> >
> > This repository contains GHC 6.12, alex, happy, etc.
>
> OK, I'll try that tomorrow and see where I get...

Or, go to http://software.opensuse.org/search/ , type ghc [alex, happy, 
...] in the search box, click the search button and 1-click-install.

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


Re: [Haskell-cafe] Function to detect duplicates

2010-02-24 Thread Casey Hawthorne
On Tue, 23 Feb 2010 08:30:18 -0300, you wrote:

>Hi folks,
>
>While solving a puzzle, I was posed the problem of finding if there was no
>duplicates on a list.

Must it be a list data structure(DS) or list ADT?

Mergesort can be parallelized.

>
>Best regards,
>
>Rafael

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


Re: [Haskell-cafe] OpenSUSE 11.2

2010-02-24 Thread Andrew Coppin

Erlend Hamberg wrote:
if you open the software manager and go to configuration → repositories, you 
should be able to add new software sources. i use the following repository:


Server name: download.opensuse.org
Directory: /repositories/devel:/languages:/haskell/openSUSE_11.2/

This repository contains GHC 6.12, alex, happy, etc.
  


OK, I'll try that tomorrow and see where I get...

Thanks,
Andrew.

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


Re: [Haskell-cafe] ANN: concurrent-extra-0.2

2010-02-24 Thread Bas van Dijk
Hello,

I discovered a bug in our: Control.Concurrent.Thread

In the documentation of 'forkIO' we specify that the forked thread
inherits the blocked state of its parent. However our implementation
did not ensure this.

The newly released concurrent-extra-0.3.1 fixes this.

This release also adds the following function:

-- |Like 'wait' but will rethrow the exception that was thrown in target thread.
unsafeWait ∷ ThreadId α → IO α
unsafeWait tid = wait tid >>= either (\(SomeException e) → throwIO e) return

Documentation: http://hackage.haskell.org/package/concurrent-extra-0.3.1

To install this latest release do:

cabal update
cabal install concurrent-extra

Or get the development sources using:

darcs get http://code.haskell.org/concurrent-extra

regards,

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


Re: [Haskell-cafe] Lazy IO with recursive reads?

2010-02-24 Thread Stephen Tetley
Hi Fabian

>From the source viewable in the Haddock docs supplied with GHC

- hGetContents calls lazyRead:

hGetContents :: Handle -> IO String
hGetContents handle =
   wantReadableHandle "hGetContents" handle $ \handle_ -> do
  xs <- lazyRead handle
  return (handle_{ haType=SemiClosedHandle}, xs )

- lazyRead :

lazyRead :: Handle -> IO String
lazyRead handle =
   unsafeInterleaveIO $
<>

hGetContents is using unsafeInterleaveIO already so you don't have to.

Best wishes

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


Re: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Edward Z. Yang
Excerpts from Don Stewart's message of Wed Feb 24 16:13:38 -0500 2010:
> These are exported from vector, though. 

Aha!  I was looking in Data.Vector for them; they're actually in
Data.Vector.Generic. Awesome.

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


Re: [Haskell-cafe] Lazy IO with recursive reads?

2010-02-24 Thread Fabian Roth
Hi Stephen

Thank you very much, this indeed does the trick!
Using UnsafeIO, however, leaves a creepy unsafe feeling...
I don't fully understand though why it is unsafe. Doesn't hGetContents do
the exact same thing (i.e. reading from IO returning a lazy string) but does
not require UnsafeIO.

Fabian

On Wed, Feb 24, 2010 at 4:38 PM, Stephen Tetley wrote:

> Hi Fabian
>
> You need to yield with unsafeInterleaveIO to allow some of the list to
> be be consumed.
>
> Something like this (which never terminates of course, but do produce
> output):
>
>
> import System.IO.Unsafe
> import Control.Monad
>
> main = do messages <- readLazy
>  mapM_ (\x -> putStr $ show x ++ "\n") $ messages
>  return ()
>  where
>readLazy :: IO [String]
> readLazy = unsafeInterleaveIO $ do
>  { c <- fancyIORead
> ; liftM2 (++) (return c) readLazy
> }
>fancyIORead :: IO [String]
>fancyIORead = return ["aa","bb"]
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Function to detect duplicates

2010-02-24 Thread Daniel Fischer
Am Mittwoch 24 Februar 2010 21:25:04 schrieb Gwern Branwen:
> 2010/2/23 Jonas Almström Duregård :
> > Hi Rafael,
> >
> > I assume you will perform this operation on some very large lists, or
> > performance would not be an issue. Have you tested if your optimized
> > version is better than your initial one?
> >
> > You should compare your implementation against something like this:
> >
> > import qualified Data.Set as Set
> > noneRepeated :: (Ord a) => [a] -> Bool
> > noneRepeated = accum Set.empty where
> >  accum _ [] = True
> >  accum s (x:xs)
> >    | Set.member x s = False
> >    | otherwise      = accum (Set.insert x s) xs
> >
> > Also there is some discussion about the nub function that relates to
> > this topic, e.g. http://buffered.io/2008/07/28/a-better-nub/.
> >
> > /Jonas
>
> Or better yet,
> http://www.haskell.org/pipermail/libraries/2008-October/010778.html Much
> more thorough and practical w/r/t to actually getting faster nubs in the
> libraries.

Umm,

using the nubOrd' code to nub a 1 million long list of pseudo random 
numbers takes (here) about 2.5 times the time and twice space as the Set-
based ordNub. It does slightly better for 100,000 elements, but still takes 
more than twice the time (and 1.6 x the space).

In my book, that's a compelling reason to go with the set-based 
implementation - unless we're talking about code to include directly in 
Data.List, but then I'd still _use_ the set-based one.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Don Stewart
ezyang:
> Excerpts from Bulat Ziganshin's message of Wed Feb 24 14:48:53 -0500 2010:
> > > I'd be really curious about techniques that permit mutation during
> > > the construction of functional datastructures; this seems like a cool
> > > way to get fast performance w/o giving up any of the benefits of
> > > immutability.  Unfortunately, my (admittedly short) experiments in
> > > this domain ran up against the difficulty that vector didn't let me
> > > unsafely freeze its mutable version. :-)
> > 
> > actually, this technique is already used in haskell. look into array
> > library sources, search for freeze
> 
> Yup, I'm aware of this.  In fact, vector has thaw/freeze functions for
> itself, although it doesn't export them.  I'd rather not have to reimplement
> vector just to get this unsafe mutation capability tough (and since the
> mutable array GC problem is not fixed for the version of GHC I'm on, I'd 
> likely
> see no benefit either).

These are exported from vector, though. 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Don Stewart
ezyang:
> Hey guys, an update!
> 
> It turns out, Clojure is using mutation under the hood during its
> initial data structure generation to make populating the hash-map
> blazingly fast.  When I force it to use the purely functional
> interface, the performance is much closer to Haskell's.
> 
> Haskell Clojure
> 128K0.56s   0.33s
> 256K1.20s   0.84s
> 512K2.62s   2.80s
> 
> There's a large amount of variance in the Java samples, as HotSpot
> kicks in; they appear to start off with identical performance and
> then the Clojure implementation steadily performs better as the JVM
> optimizes away.
> 
> I'd be really curious about techniques that permit mutation during
> the construction of functional datastructures; this seems like a cool
> way to get fast performance w/o giving up any of the benefits of
> immutability.  Unfortunately, my (admittedly short) experiments in
> this domain ran up against the difficulty that vector didn't let me
> unsafely freeze its mutable version. :-)

Almost all the vector library generators fill a vector destructively,
before doing an unsafeFreeze.

Here's an example of filling a buffer with randoms,

   random g n = do
v  <- GM.new n
fill v 0
G.unsafeFreeze v
  where
fill v i
| i < n = do
x <- R.random g
GM.unsafeWrite v i x
fill v (i+1)
| otherwise = return ()
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Edward Z. Yang
Excerpts from Bulat Ziganshin's message of Wed Feb 24 14:48:53 -0500 2010:
> > I'd be really curious about techniques that permit mutation during
> > the construction of functional datastructures; this seems like a cool
> > way to get fast performance w/o giving up any of the benefits of
> > immutability.  Unfortunately, my (admittedly short) experiments in
> > this domain ran up against the difficulty that vector didn't let me
> > unsafely freeze its mutable version. :-)
> 
> actually, this technique is already used in haskell. look into array
> library sources, search for freeze

Yup, I'm aware of this.  In fact, vector has thaw/freeze functions for
itself, although it doesn't export them.  I'd rather not have to reimplement
vector just to get this unsafe mutation capability tough (and since the
mutable array GC problem is not fixed for the version of GHC I'm on, I'd likely
see no benefit either).

What I thought was pretty neat about the Clojure approach was how easy they
made it for you to jump into mutation-land and back out again: just a
(transient) call and you're off to the races.  As far as I can tell, you have
to painstakingly write the specific operation you'd like to do via mutation
out using all sorts of unsafe calls.

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


Re: [Haskell-cafe] OpenSUSE 11.2

2010-02-24 Thread Erlend Hamberg
On Wednesday 24. February 2010 21.47.56 Andrew Coppin wrote:
> no ammount of prodding YaST will convince it that 
> it's possible to install anything remotely Haskell-related

if you open the software manager and go to configuration → repositories, you 
should be able to add new software sources. i use the following repository:

Server name: download.opensuse.org
Directory: /repositories/devel:/languages:/haskell/openSUSE_11.2/

This repository contains GHC 6.12, alex, happy, etc.

-- 
Erlend Hamberg
“Everything will be ok in the end. If its not ok, its not the end.”
GPG/PGP:  0xAD3BCF19
45C3 E2E7 86CA ADB7 8DAD 51E7 3A1A F085 AD3B CF19


signature.asc
Description: This is a digitally signed message part.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] OpenSUSE 11.2

2010-02-24 Thread Andrew Coppin
OK, I imagined to install OpenSUSE 11.2. However, I can't find a way to 
make it install either GHC or the Haskell Platform. A quick Google 
search turns up a folder on download.opensuse.org which is stuffed full 
of Haskell stuff, yet no ammount of prodding YaST will convince it that 
it's possible to install anything remotely Haskell-related. (Now I 
remember why I don't use Linux much...)


Does anybody know how to install this stuff on OpenSUSE?

Alternatively, does anybody know of an alternative Linux distribution 
where this kind of thing is likely to work better?


(I think I've got a Debian ISO somewhere - but IME everything on Debian 
is always 8 years old.)


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


Re: [Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles?

2010-02-24 Thread Christian Maeder
Ben Millwood schrieb:
> On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder
>  wrote:
>> 1. break the line after "do"
>> (to avoid a layout change when change name or arguments of float' or
>> rename the variable "e")
> 
> You can also break it immediately before do, which I think is
> sometimes more clear.

If not an extra space is added following "do" this leads to an "odd"
indentation of at least one line.

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


Re: [Haskell-cafe] Function to detect duplicates

2010-02-24 Thread Gwern Branwen
2010/2/23 Jonas Almström Duregård :
> Hi Rafael,
>
> I assume you will perform this operation on some very large lists, or
> performance would not be an issue. Have you tested if your optimized
> version is better than your initial one?
>
> You should compare your implementation against something like this:
>
> import qualified Data.Set as Set
> noneRepeated :: (Ord a) => [a] -> Bool
> noneRepeated = accum Set.empty where
>  accum _ [] = True
>  accum s (x:xs)
>    | Set.member x s = False
>    | otherwise      = accum (Set.insert x s) xs
>
> Also there is some discussion about the nub function that relates to
> this topic, e.g. http://buffered.io/2008/07/28/a-better-nub/.
>
> /Jonas

Or better yet, 
http://www.haskell.org/pipermail/libraries/2008-October/010778.html
Much more thorough and practical w/r/t to actually getting faster nubs
in the libraries.

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


[Haskell-cafe] ICFP 2010: Second call for papers

2010-02-24 Thread Wouter Swierstra
=

Second Call for Papers

   ICFP 2010: International Conference on Functional Programming

 Baltimore, Maryland, 27 -- 29 September 2010

http://www.icfpconference.org/icfp2010

=

Important Dates (at 14:00 UTC)
~

Submission:2 April 2010
Author response:  24 -- 25 May 2010
Notification:   7 June 2010
Final papers due:  12 July 2010

Scope
~

ICFP 2010 seeks original papers on the art and science of functional
programming. Submissions are invited on all topics from principles to
practice, from foundations to features, from abstraction to
application. The scope includes all languages that encourage
functional programming, including both purely applicative and
imperative languages, as well as languages with objects or
concurrency. Particular topics of interest include

* Language Design: type systems; concurrency and distribution;
 modules; components and composition; metaprogramming; relations to
 object-oriented or logic programming; interoperability

* Implementation: abstract machines; compilation; compile-time and
 run-time optimization; memory management; multi-threading;
 exploiting parallel hardware; interfaces to foreign functions,
 services, components or low-level machine resources

* Software-Development Techniques: algorithms and data structures;
 design patterns; specification; verification; validation; proof
 assistants; debugging; testing; tracing; profiling

* Foundations: formal semantics; lambda calculus; rewriting; type
 theory; monads; continuations; control; state; effects

* Transformation and Analysis: abstract interpretation; partial
 evaluation; program transformation; program calculation; program
 proof

* Applications and Domain-Specific Languages: symbolic computing;
 formal-methods tools; artificial intelligence; systems programming;
 distributed-systems and web programming; hardware design; databases;
 XML processing; scientific and numerical computing; graphical user
 interfaces; multimedia programming; scripting; system
 administration; security; education

* Functional Pearls: elegant, instructive, and fun essays on
 functional programming The conference also solicits Experience
 Reports, which are short papers that provide evidence that
 functional programming really works or describe obstacles that have
 kept it from working in a particular application.

Abbreviated instructions for authors

By 2 April 2010, 14:00 UTC, submit an abstract of at most 300 words
and a full paper of at most 12 pages (6 pages for an Experience
Report), including bibliography and figures. The deadline will be
strictly enforced and papers exceeding the page limits will be
summarily rejected.  Authors have the option to attach supplementary
material to a submission, on the understanding that reviewers may
choose not to look at it.

A submission will be evaluated according to its relevance,
correctness, significance, originality, and clarity. It should explain
its contributions in both general and technical terms, clearly
identifying what has been accomplished, explaining why it is
significant, and comparing it with previous work. The technical
content should be accessible to a broad audience. Functional Pearls
and Experience Reports are separate categories of papers that need not
report original research results and must be marked as such at the
time of submission. Detailed guidelines on both categories are on the
conference web site.

Each submission must adhere to SIGPLAN's republication policy, as
explained on the web at http://www.acm.org/sigplan/republicationpolicy.htm.

Proceedings will be published by ACM Press. Authors of accepted
submissions are expected to transfer the copyright to the
ACM. Presentations will be videotaped and released online if the
presenter consents by signing an additional permission form at the
time of the presentation.  Formatting: Submissions must be in PDF
format printable in black and white on US Letter sized paper and
interpretable by Ghostscript. If this requirement is a hardship, make
contact with the program chair at least one week before the
deadline. Papers must adhere to the standard ACM conference format:
two columns, nine-point font on a ten-point baseline, with columns
20pc (3.33in) wide and 54pc (9in) tall, with a column gutter of 2pc
(0.33in). A suitable document template for LATEX is available from
SIGPLAN at http://www.acm.org/sigs/sigplan/authorInformation.htm.

Submission: Submissions will be accepted electronically at a URL to be
named later. Improved versions of a paper may be submitted at any
point before the submission deadline using the same web interface.

Author response: Authors will have a 48-hour period, starting at 14:00
UTC on 24 May 2010, to read and respond to r

Re[2]: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Bulat Ziganshin
Hello Edward,

Wednesday, February 24, 2010, 10:32:59 PM, you wrote:

> I'd be really curious about techniques that permit mutation during
> the construction of functional datastructures; this seems like a cool
> way to get fast performance w/o giving up any of the benefits of
> immutability.  Unfortunately, my (admittedly short) experiments in
> this domain ran up against the difficulty that vector didn't let me
> unsafely freeze its mutable version. :-)

actually, this technique is already used in haskell. look into array
library sources, search for freeze


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-24 Thread Brandon S. Allbery KF8NH

On Feb 24, 2010, at 12:25 , Bardur Arantsson wrote:
It's a huge amount of data since it's streaming ~900Kb/s (or  
thereabouts). I don't think it's really practical to look through  
all that to try to figure out exactly when the problem occurs.


Given what we're looking for, I think you can ignore normal packets:

tcpdump 'host ps3 and tcp[tcpflags] & 0x27 != 0'

(substitute the hostname of your PS3; you may need to escape the !  
depending on your shell)


This (flags = SYN, FIN, RST; URG thrown in for the heck of it) should  
omit all data packets from the capture.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Optimizing hash array mapped tries

2010-02-24 Thread Edward Z. Yang
Hey guys, an update!

It turns out, Clojure is using mutation under the hood during its
initial data structure generation to make populating the hash-map
blazingly fast.  When I force it to use the purely functional
interface, the performance is much closer to Haskell's.

Haskell Clojure
128K0.56s   0.33s
256K1.20s   0.84s
512K2.62s   2.80s

There's a large amount of variance in the Java samples, as HotSpot
kicks in; they appear to start off with identical performance and
then the Clojure implementation steadily performs better as the JVM
optimizes away.

I'd be really curious about techniques that permit mutation during
the construction of functional datastructures; this seems like a cool
way to get fast performance w/o giving up any of the benefits of
immutability.  Unfortunately, my (admittedly short) experiments in
this domain ran up against the difficulty that vector didn't let me
unsafely freeze its mutable version. :-)

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


Re: [Haskell-cafe] Lazy IO with recursive reads?

2010-02-24 Thread Brandon S. Allbery KF8NH

On Feb 24, 2010, at 08:53 , Fabian Roth wrote:

main = do messages <- readLazy
  mapM_ (\x -> putStr $ show x ++ "\n") $ messages


Regardless of anything else going on, that second line will force  
everything to be read immediately.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] gtk2hs and ghc-6.10.4 on Windows (Vista)

2010-02-24 Thread Alistair Bayley
On 16 February 2010 17:57, Neil Mitchell  wrote:
> Hi Serguey,
>
> A GHC 6.10.4 version of Gtk2hs:
>
> http://www.mail-archive.com/gtk2hs-de...@lists.sourceforge.net/msg00340.html
>
> I used to recommend Gtk2hs over wxHaskell for GUI development as there
> was always a version that worked on Windows with the latest GHC
> release. I think I might have to switch back to recommending C# for
> GUI development...

Is there a trick to getting this installed? I have run the installer
in a Vista machine, both as user and admin, and the installation is
mostly successful, except that the packages are not registered with
ghc-6.10.4. Also, the first step of the install complains that "GHC
does not appear to be installed correctly, try reinstalling GHC
version 6.10.4. Setup found what appears to be a non-working
installation of GHC in ..."  What test does it apply to determine if
GHC is working or not?

It can run the gtk-demo, so it's not all bad, but I can't build
anything that uses it (like Yi).

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


Re: [Haskell-cafe] Re: Some great results on fused code with the LLVM backend

2010-02-24 Thread Edward Kmett
On Wed, Feb 24, 2010 at 10:11 AM, Johann Höchtl wrote:

>
> Will this eg mean
>
> * interoperability between LLVM assemblies for free
>
* plugable garbage collectors
>

Keep in mind the LLVM GHC backend still uses the separate Haskell stack and
uses a custom calling convention, so LLVM's garbage collection support isn't
used at all, it is still a rather strange duck as far as the rest of the
LLVM ecosystem is concerned.


> * GHC/LLVM bytecode with JIT-option?
>

There is little preventing this one.

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


[Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-24 Thread Heinrich Apfelmus
Günther Schmidt wrote:
> I've been thinking a lot lately about heterogeneous and extensible data
> structures for which HList certainly offers a solution.
> 
> While HList is implemented through type-level programming I wonder if I
> can achieve similar results through value-level programming alone.
> 
> This is where I was thinking of functional references.
> 
> I wonder if or rather how one could do this:
> 
> Let's say there was some clever monad ...
> 
> someMonad = do
> h1 <- add "twenty"
> h2 <- add False
> h3 <- add 16
> .   
> modify h2 True
> 
> and get a ("twenty",(True, 16)) back. And while *in* the monad some
> accessors available.
> 
> Now come to think of it I think I actually read about this somewhere so
> I doubt this is truly my idea.
> 
> Anybody got some thoughts on this?

Dropping the part involving modification, I think you want to write
something like this

val "twenty" `pair` (val False `pair` left)

where  left  is a "magic function" that returns the previous entry of
the pair, so that the whole expression yields

("twenty", (False, False))


The difficult part is to keep track of the types. But fortunately, there
is a neat trick by Oliver Danvy which does exactly that, see also

  Oliver Danvy. Functional unparsing.
  http://www.brics.dk/RS/98/12/BRICS-RS-98-12.pdf


Namely, let's assume we are already given a "magic" type constructor  |-
 (so magic that it's not even legal Haskell syntax) with the property that

A |- B

somehow denotes an expression of type  B  with free variables of type  A
. In other words, the result of type  B  is somehow allowed to depend on
values of type  A .

Given this type, we can now assign types to our functions:

   pair :: (a |- b) -> ((a,b) |- c) -> (a |- (b,c))
   left :: (a,b) |- b
   val  :: x -> (a |- x)

In other words, everything may depend on additional free variables of
some type  a .

But of course,  A |- B  is just the same as  A -> B , which readily
suggest the implementation

pair f g = \a -> let b = f a in (b, g (a,b))
left = \(a,b) -> b
val x= \a -> x

For instance, we get

example :: a -> (String, (Bool, Bool))
example = val "twenty" `pair` (val True `pair` left)

and

example undefined = ("twenty",(True,True))


While the functionality is a bit limited, I'm confident that this
approach can be extended considerably. Whether the result is useful is
another question, of course.


Regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com

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


Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)

2010-02-24 Thread Brandon S. Allbery KF8NH

On Feb 24, 2010, at 05:19 , Roman Cheplyaka wrote:

Well, this agrees with POSIX. So still I don't see the difference
between "$@" and ${1+"$@"}.



The difference is that Unix /bin/sh predates POSIX, and on systems  
that usefully support a notion of backward compatibility (nostly  
commercial, because (1) they have installed user bases that predate  
POSIX and (2) they actually think it's worthwhile to support said user  
bases) /bin/sh uses the traditional behavior that "$@" expands to ""  
if there are no arguments.  (This is "stupid" but consistent, another  
concept that seems to have been thrown to the wolves.)


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [offtopic] UNIX Shell (was: GHC RTS question)

2010-02-24 Thread Brandon S. Allbery KF8NH

On Feb 24, 2010, at 02:18 , Roman Cheplyaka wrote:

 #! /bin/sh
 ./prog --RTS ${1+"$@"}

The longer specification above should work with whatever /bin/sh is
around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux
bash, Debian/Ubuntu dash, etc.


Are you referring to some Solaris shell bug?

Under POSIX these constructs seem to be equivalent.
"If there are no positional parameters, the expansion of '@' shall
generate zero fields, even when '@' is double-quoted."



s/Solaris/most commercial Unixes/ because making /bin/sh POSIX would  
break too many things (unlike Linux/*BSD, they have to consider  
backward compatibility; a concept that Linux in particular seems not  
to comprehend).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-24 Thread Bardur Arantsson

On 2010-02-24 05:10, Brandon S. Allbery KF8NH wrote:

On Feb 21, 2010, at 20:17 , Jeremy Shaw wrote:

The PS3 does do something though. If we were doing a write *and* read
select on the socket, the read select would wakeup. So, it is trying
to notify us that something has happened, but we are not seeing it
because we are only looking at the write select().


Earlier the OP claimed this would happen within a few minutes if he
seeked in a movie. If it's that reproducible, it should be easy to
capture a tcpdump and attach it to an email (or pastebin it), allowing
us to determine what really happens.


It's a huge amount of data since it's streaming ~900Kb/s (or 
thereabouts). I don't think it's really practical to look through all 
that to try to figure out exactly when the problem occurs.


Anyone know of any programs which can highlight 'anomalous' tcp traffic 
in tcpdumps?


Still, I'd be happy to try a capture and upload it somewhere if anyone 
cares too have a look at it. It'll have to wait for the weekend, though.


Cheers,

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


Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)

2010-02-24 Thread Donn Cave
Quoth Roman Cheplyaka ,

...

> Well, this agrees with POSIX. So still I don't see the difference
> between "$@" and ${1+"$@"}.

Whatever the standards etc. may say, I believe "$@" is reliably the
same as ${1+"$@"}, for old Bourne shells and new.

Donn

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


Re: [Haskell-cafe] Re: Function to detect duplicates

2010-02-24 Thread Daniel Fischer
Am Mittwoch 24 Februar 2010 14:25:20 schrieb Ertugrul Soeylemez:
> Jonas Almström Duregård  wrote:
> > >>noneRepeated xs = xs == nub xs
> > >
> > > Not quite as bad, nub is O(n^2)
> >
> > You are correct of course. Still, it will probably be a bit less
> > inefficient if the length of the lists are compared (as opposed to the
> > elements):
> >
> > noneRepeated xs = length xs == length (nub xs)
> >
> > [...]
> >
> > > How can you nub in O(n*log n)? Remember, you only have Eq for nub.
>
> Again note that the big advantage of my method is laziness.  The
> comparison will end on the first duplicate found.

Yes, and the suggestions Jonas and I posted had the same property :)

> Using the following nub implementation the overall time complexity should
> be O(n * log n), but may be space-intensive, because it uses O(n) space.

Data.List.nub also uses O(n) space (but has a smaller constant factor).

> Also note that it has a different context (the type needs to be Ord
> instead of Eq):

Yeah, that's the catch, it has a more restricted type. If you have only Eq, 
I don't think you can do better than O(n^2). That's why I was irritated by

> > I think the nub-based solution is the best one in general, but it's
> > the base library implementation of nub, which is unfortunate.  In
> > fact, with a better nub implementation, this becomes an O(n * log n)
> > time

, for the type of nub, the library implementation is rather good (perhaps 
it can still be improved, but not much, I think).

>
>   import qualified Data.Set as S
>   import Data.List
>
>   myNub :: Ord a => [a] -> [a]
>   myNub = concat . snd . mapAccumL nubMap S.empty
> where nubMap s x
>
> | S.member x s = (s, [])
> | otherwise= (S.insert x s, [x])

I prefer

{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -O2 #-}
module OrdNub (ordNub, ordNubRare) where

import qualified Data.Set as Set

ordNub :: Ord a => [a] -> [a]
ordNub = go Set.empty
  where
go !st (x:xs)
| x `Set.member` st = go st xs
| otherwise = x : go (Set.insert x st) xs
go _ [] = []

, it's faster. If you know that duplicates are rare, 

ordNubRare :: Ord a => [a] -> [a]
ordNubRare = go 0 Set.empty
  where
go sz st (x:xs)
| sz1 == sz = go sz st xs
| otherwise = x : go sz1 st1 xs
  where
st1 = Set.insert x st
!sz1 = Set.size st1
go _ _ [] = []

is even faster because it omits the lookups (but it sucks when there are 
many duplicates, of course).

>
> Greets
> Ertugrul

Cheers,
Daniel

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


Re: [Haskell-cafe] Lazy IO with recursive reads?

2010-02-24 Thread Stephen Tetley
Hi Fabian

You need to yield with unsafeInterleaveIO to allow some of the list to
be be consumed.

Something like this (which never terminates of course, but do produce output):


import System.IO.Unsafe
import Control.Monad

main = do messages <- readLazy
  mapM_ (\x -> putStr $ show x ++ "\n") $ messages
  return ()
  where
readLazy :: IO [String]
readLazy = unsafeInterleaveIO $ do
 { c <- fancyIORead
 ; liftM2 (++) (return c) readLazy
 }
fancyIORead :: IO [String]
fancyIORead = return ["aa","bb"]
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Problems linking hsql-mysql

2010-02-24 Thread Maciej Podgurski

Hi,

no, it's absolutely not urgent. I'm just in early stage with building a 
Happstack webpage and testing via GHCi works fine.


The problem occurs on a Windows XP machine with hsql-1.7.1, 
hsql-mysql-1.7.1, GHC-6.10.4 and MySQL Server 5.1. Last year I posted an 
instruction on how I got hsql-mysql running (see 
http://www.mail-archive.com/haskell-cafe@haskell.org/msg61265.html), the 
changes for the new GHC version where exactly the same. To replicate the 
error, just do an import Database.HSQL.MySQL and build the file via ghc 
--make.


As far as I remember this worked with GHC-6.8.3, but I'm not quite sure. 
Let me know if you need additional informationen.



Thanks for help,

Maciej


Am 24.02.2010 01:07 schrieb Nick Rudnick:

Hi Maciej,

I will try to reproduce the error -- could you send me your both 
*.cabal files (for hsql & hsql-mysql), if you have changed anything, 
and your system configuration.


Is this extremely urgent? I ask this, as these days exactly the end 
phase of the projects of about 100 beginner Haskell students, which I 
am the one to look after. So I am in a little of slow motion regarding 
other things... ;-)


But in case you are in emergency, please let me know... At first 
sight, I would say it looks like a configuration problem... ;-)


Cheers,

   Nick

Maciej Podgurski wrote:

Hi,

I have problems linking a simple test program that imports 
Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs 
when importing this module of hsql-mysql-1.7.1. I pasted the building 
output here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 
(actually it was even longer but hpaste only takes 30k).


When I do ghc -e main Test.hs or starting it from GHCi, everything 
works fine and no errors occur. So I guess all needed .lib files are 
there but GHC can't find them when linking (adding the flag -L"path 
to mysql/lib/opt" doesn't help). Anyone an idea?



Best wishes,

Maciej
___
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] Lazy IO with recursive reads?

2010-02-24 Thread Ben Millwood
On Wed, Feb 24, 2010 at 1:53 PM, Fabian Roth  wrote:
> Hi all,
> I am trying to read structured data from a socket and return a lazy list of
> records. However, the socket reading operation seems to be strict and never
> returns (until stack overflow).
>

This is expected behaviour. Normal sequencing of IO actions is done in
such a way as to preserve their order, which is obviously pretty
important if you want to ask for a response to your message after
you've sent it, rather than before. Lazy IO operations violate that
order and as a result are pretty scary and usually to be avoided. In
general, laziness only works well with pure functions where the order
doesn't matter because there are no observable side-effects.

There are ways of making IO lazy, but there are pretty much invariably
other ways of doing the same thing which result in fewer headaches
later on. I am hoping that other people more educated than I am will
be able to tell you about Iteratees and so forth.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [wxhaskell-users] Building/installing OS X application bundles for GUIs - cabal-macosx

2010-02-24 Thread Eric Kow
On Wed, Feb 24, 2010 at 12:54:51 +, Andy Gimblett wrote:
> That raises the question: what is the right place?  It seems to me  
> that the defaults are not the right defaults for this case.  --global  
> should probably go to /Applications, and --user should perhaps go to ~/ 
> Applications (though I'm less sure about that).  Of course, end-users  
> can explicitly set this on a per-install basis, but it seems that for  
> bundles we'd want to override the default.

Just to give some background to this:

I won't claim this is the right place, but the GenI setup script
(distant/fond ancestor of cabal-macosx) copies the app bundle to
wherever Cabal normally wants to put binaries, and then dumps out a
shell script for people who still want a command line interface to their
GUI app.

So you get

  ~/.cabal/bin/geni.app # application bundle
  ~/.cabal/bin/geni # shell script that calls geni.app/Contents/MacOS/geni

Again, not sure if that's the right thing to do, but it works for setups
where you still expect cabal install GenI to work the same way as, say
cabal install darcs, would.

-- 
Eric Kow 
PGP Key ID: 08AC04F9


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


[Haskell-cafe] Re: Some great results on fused code with the LLVM backend

2010-02-24 Thread Johann Höchtl


On Feb 22, 2:57 am, Don Stewart  wrote:

> TheLLVMbackend looks very promising -- considering we've not even
> begun to explore the optimization pipeline at the level.
>
The mere numbers on this tiny snipets look definitely promising.

I also read through http://hackage.haskell.org/trac/ghc/wiki/LlvmBackend
but I wonder what componentes of the LLVM infrastructure will
eventually make it into GHC.

Will this eg mean

* interoperability between LLVM assemblies for free
* plugable garbage collectors
* GHC/LLVM bytecode with JIT-option?

> -- Don

Johann

> ___
> Haskell-Cafe mailing list
> haskell-c...@haskell.orghttp://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] Re: Proper round-trip HughesPJ/Parsec for Doubles?

2010-02-24 Thread Ben Millwood
On Wed, Feb 24, 2010 at 1:24 PM, Christian Maeder
 wrote:
> 1. break the line after "do"
> (to avoid a layout change when change name or arguments of float' or
> rename the variable "e")

You can also break it immediately before do, which I think is
sometimes more clear.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Lazy IO with recursive reads?

2010-02-24 Thread Fabian Roth
Hi all,

I am trying to read structured data from a socket and return a lazy list of
records. However, the socket reading operation seems to be strict and never
returns (until stack overflow). Here's some simplified code to reproduce the
problem:



import Control.Monad

main = do messages <- readLazy
  mapM_ (\x -> putStr $ show x ++ "\n") $ messages
  return ()
  where
readLazy :: IO [String]
readLazy = do c <- fancyIORead
  liftM2 (++) (return c) readLazy
fancyIORead :: IO [String]
fancyIORead = return ["aa","bb"]



In my implementation fancyIORead reads blocks from the socket and returns a
list of records.
But it seems readLazy doesn't ever return.

What could be the problem here?

Also, if anyone has a better solution to write this thing, pls let me know.

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


[Haskell-cafe] Re: Function to detect duplicates

2010-02-24 Thread Ertugrul Soeylemez
Jonas Almström Duregård  wrote:

> >>noneRepeated xs = xs == nub xs
>
> > Not quite as bad, nub is O(n^2)
>
> You are correct of course. Still, it will probably be a bit less
> inefficient if the length of the lists are compared (as opposed to the
> elements):
>
> noneRepeated xs = length xs == length (nub xs)
>
> [...]
>
> > How can you nub in O(n*log n)? Remember, you only have Eq for nub.

Again note that the big advantage of my method is laziness.  The
comparison will end on the first duplicate found.  Using the following
nub implementation the overall time complexity should be O(n * log n),
but may be space-intensive, because it uses O(n) space.  Also note that
it has a different context (the type needs to be Ord instead of Eq):

  import qualified Data.Set as S
  import Data.List

  myNub :: Ord a => [a] -> [a]
  myNub = concat . snd . mapAccumL nubMap S.empty
where nubMap s x
| S.member x s = (s, [])
| otherwise= (S.insert x s, [x])


Greets
Ertugrul


-- 
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/


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


[Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles?

2010-02-24 Thread Christian Maeder
Andy Gimblett schrieb:
> For the record, here's the final improved version:

Hi Andy,

I hope you don't mind if I make some style comments to your "final" version.

1. break the line after "do"
(to avoid a layout change when change name or arguments of float' or
rename the variable "e")

2. The "t :: TokenParser st" is only used for the white spaces.
This should be done separately (use "lexeme" from the TokenParser if you
really need to). Just using "spaces" is also an alternative.

3. "liftCtoS" is only applied to '-', so an "optSign" would suffice.
  optSign = option "" $ fmap (: []) (char '-')

(read also allows a capital 'E' and a '+' before the exponent, but no
initial '+' sign. The decimal point is optional. Also "NaN" and
"Infinity" can be read, both possibly preceded by a '-' sign followed by
spaces. But you may restrict yourself to the possible outputs of show,
which would include "NaN" and "Infinity", though.)

It may make sense to use something like readMaybe (which is missing in
the Prelude) instead of "read" to allow the parser to fail more nicely.

Btw I observed the following problem with read (that readMaybe would
also not solve).
http://hackage.haskell.org/trac/ghc/ticket/3897

Cheers Christian

> 
> float' :: TokenParser st -> GenParser Char st Double
> float' t = do n <- liftCtoS '-'
>   w <- many1 digit
>   char '.'
>   f <- many1 digit
>   e <- option "" $ do char 'e'
>   n' <- liftCtoS '-'
>   m <- many1 digit
>   return $ concat ["e", n', m]
>   whiteSpace t
>   return $ read $ concat [n, w, ".", f, e]
>   where liftCtoS a = option "" (char a >> return [a])
> 
> Thanks for all the help, again.
> 
> -Andy
> 
> -- 
> Andy Gimblett
> http://gimbo.org.uk/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Building/installing OS X application bundles for GUIs - cabal-macosx

2010-02-24 Thread Andy Gimblett

Hi all,

Last week I quietly released v0.1.0 of cabal-macosx, providing support  
for building OSX application bundles (e.g. and in particular for GUIs  
created using wxHaskell and gtk2hs - hence all the cross-posting):


http://hackage.haskell.org/package/cabal-macosx

I'm now soliciting input on how to handle the install stage, leading  
(I hope) to a loudly-announcable release soon. :-)


The current package provides a post-build hook which creates an  
application bundle at dist/build/foo.app (for example).  It seems to  
work well.  See the source repository for examples.


However, running "runghc Setup install" copies the bare executable at  
dist/build/foo/foo (rather than the foo.app bundle) to the install  
location, which is no good.  So I need to put in some install  
infrastructure to copy the .app, not the bare executable, to the right  
place.


That raises the question: what is the right place?  It seems to me  
that the defaults are not the right defaults for this case.  --global  
should probably go to /Applications, and --user should perhaps go to ~/ 
Applications (though I'm less sure about that).  Of course, end-users  
can explicitly set this on a per-install basis, but it seems that for  
bundles we'd want to override the default.


Thus I'm currently asking:

* What do people think about the default installation question?

* Can anyone advise me on the right way to handle this (installing  
the .app, and overriding the default locations) with Cabal?  I'm  
hoping I can just tweak part of the LocalBuildInfo and let the default  
machinery then handle the work, but at present it's not clear to me  
how to do that, and rather than spend ages trying to figure it out,  
perhaps someone who knows can help me out?  I'm hoping I'm not going  
to have to completely override the install machinery - that would feel  
somewhat self-defeating.


Many thanks,

-Andy

--
Andy Gimblett
http://gimbo.org.uk/

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


[Haskell-cafe] Re: Testing and module export lists

2010-02-24 Thread John Lato
> From: Magnus Therning 
>
> How do people who like unit testing / property testing deal with export lists?
>
> I often find that I do want an export list to reduce clutter in the
> finished code, but for testing I'd like to expose everything in a
> module.  Is there a nice way to deal with this (using the C
> pre-processor would not qualify as "nice" ;-)?
> Maybe there's a switch that causes GHC to simply ignore the export
> list of a module and export everything?

That would be a nice feature to deal with this problem.

The best solution I have is to separate functions that don't belong in
the public interface into separate modules that aren't exposed
(they're listed in the other-modules section of the .cabal file).  I
then add the test executable to the .cabal file, so when it's built it
can access the hidden modules (or I run the test from ghci).

Of course this only works if it makes sense to structure the code this way.

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


Re: [Haskell-cafe] Testing and module export lists

2010-02-24 Thread Magnus Therning
On Wed, Feb 24, 2010 at 10:41, Arnaud Bailly  wrote:
> Maybe you just want to test what's in your export list which
> represents the public interface of your code. And if you cannot write
> a test that exercise private implementation through the public
> interface, then maybe there is a design problem...

Possibly!

The specific case I have is a module for parsing a small language.
The module exports a single function, a function that takes a string
and returns a tree.  Of course the parser is built using parser
combinators.  I'd like to test each combinator I've built, but I don't
want to export them all.  The only way I see of achieving this is to
split each module in two, one public and one internal, where the
public one just re-exports the relevant pieces of the internal one.
That's workable, but hardly aesthetically pleasing ;-)

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)

2010-02-24 Thread Roman Cheplyaka
* Magnus Therning  [2010-02-24 09:11:54+]
> On Wed, Feb 24, 2010 at 07:18, Roman Cheplyaka  wrote:
> > * Brandon S. Allbery KF8NH  [2010-02-24 00:02:12-0500]
> >> On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote:
> >> >* Anthony Cowley  [2010-02-21 14:15:00-0500]
> >> >>#! /usr/bin/env bash
> >> >>./prog --RTS $*
> >> >
> >> > ./prog --RTS "$@"
> >> >
> >> >Otherwise it will work wrong if arguments contain quoted field
> >> >separators (e.g. spaces).
> >>
> >>
> >>   #! /bin/sh
> >>   ./prog --RTS ${1+"$@"}
> >>
> >> The longer specification above should work with whatever /bin/sh is
> >> around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux
> >> bash, Debian/Ubuntu dash, etc.
> >
> > Are you referring to some Solaris shell bug?
> >
> > Under POSIX these constructs seem to be equivalent.
> > "If there are no positional parameters, the expansion of '@' shall
> > generate zero fields, even when '@' is double-quoted."
> 
> I believe he's referring to the following bit (taken from bash's man page):
> 
> @ Expands to the positional parameters, starting from one.  When the expansion
>   occurs within double quotes, each parameter expands to a separate word.  
> That
>   is, "$@" is equivalent to "$1" "$2" ...  If the  double-quoted expansion
>   occurs  within a word, the expansion of the first parameter is joined with
>   the beginning part of the original word, and the expansion of the last
>   parameter is joined with the last part of the original word.  When there are
>   no positional parameters, "$@" and $@ expand to nothing (i.e., they are
>   removed).

Well, this agrees with POSIX. So still I don't see the difference
between "$@" and ${1+"$@"}.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC RTS question

2010-02-24 Thread Roman Cheplyaka
* Artyom Kazak  [2010-02-24 10:23:07+0200]
> 2010/2/24 Brandon S. Allbery KF8NH :
> > On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote:
> >>
> >> * Anthony Cowley  [2010-02-21 14:15:00-0500]
> >>>
> >>> #! /usr/bin/env bash
> >>> ./prog --RTS $*
> >>
> >>  ./prog --RTS "$@"
> >>
> >> Otherwise it will work wrong if arguments contain quoted field
> >> separators (e.g. spaces).
> >
> >
> >  #! /bin/sh
> >  ./prog --RTS ${1+"$@"}
> >
> > The longer specification above should work with whatever /bin/sh is around,
> > whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash,
> > Debian/Ubuntu dash, etc.
> >
> 
> And with Windows, of course :) Haskell is cross-platform, isn't it?

Haskell is a language, it does not have any notion of platform.

It has several implementations, which may or may not be cross-platform.
(OP asked specifically about ghc, which supports a number of
platforms, including Windows.)

Here we talk not about ghc itself, but about POSIX shell interpreter,
which is available on every POSIX-compliant operating system.
Windows (out of the box) lacks implementation of POSIX shell.

-- 
Roman I. Cheplyaka :: http://ro-che.info/
"Don't let school get in the way of your education." - Mark Twain
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Linear programming in Haskell

2010-02-24 Thread Alberto Ruiz
I have uploaded to hackage an interface to the simplex algorithm based 
on GLPK. It is a very early version, it will probably have lots of 
problems. In the future I would like to add support for integer 
variables (MIP). Any suggestion is welcome.


This is an example taken from "glpk-utils":

http://code.haskell.org/hmatrix/packages/glpk/examples/simplex3.hs

Documentation: http://perception.inf.um.es/~aruiz/hmatrix-glpk/

Installation:

$ sudo apt-get install libglpk-dev
$ cabal update
$ cabal install hmatrix-glpk

If hmatrix is not installed we also need

$ sudo apt-get install libgsl0-dev liblapack-dev

I hope it is useful,
Alberto



Erik de Castro Lopo wrote:

Alberto Ruiz wrote:

I think that GSL does not include linear programming solvers, but in the 
GSL home page there is a reference to the GLPK package:


http://www.gnu.org/software/glpk/glpk.html

I have not used it, but it would be very nice to have a simple Haskell 
interface to GLPK (or other similar library) in hmatrix or as a separate 
package. I will take a look at this.


I used GLPK many years ago and I found it excellent.

Erik


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


Re[2]: [Haskell-cafe] Linux ghci vs Windows ghci

2010-02-24 Thread Bulat Ziganshin
Hello Brandon,

Wednesday, February 24, 2010, 8:08:41 AM, you wrote:

>> I feel that ghci code executing speed in guest os is 1.5~2x faster
>> than host os

> My guess is that GHC (and the GHC RTS) on win32 is using a POSIX  
> emulation layer supplied by mingw32 for all system calls, introducing
> extra overhead.

1. yes, mingw is using POSIX emulation layer for file operations, but
i don't believe that it provides any serious overhead - even for i/o

2. this example was purely computational, no OS calls involved




-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


[Haskell-cafe] Testing and module export lists

2010-02-24 Thread Magnus Therning
How do people who like unit testing / property testing deal with export lists?

I often find that I do want an export list to reduce clutter in the
finished code, but for testing I'd like to expose everything in a
module.  Is there a nice way to deal with this (using the C
pre-processor would not qualify as "nice" ;-)?
Maybe there's a switch that causes GHC to simply ignore the export
list of a module and export everything?

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)

2010-02-24 Thread Magnus Therning
On Wed, Feb 24, 2010 at 07:18, Roman Cheplyaka  wrote:
> * Brandon S. Allbery KF8NH  [2010-02-24 00:02:12-0500]
>> On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote:
>> >* Anthony Cowley  [2010-02-21 14:15:00-0500]
>> >>#! /usr/bin/env bash
>> >>./prog --RTS $*
>> >
>> > ./prog --RTS "$@"
>> >
>> >Otherwise it will work wrong if arguments contain quoted field
>> >separators (e.g. spaces).
>>
>>
>>   #! /bin/sh
>>   ./prog --RTS ${1+"$@"}
>>
>> The longer specification above should work with whatever /bin/sh is
>> around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux
>> bash, Debian/Ubuntu dash, etc.
>
> Are you referring to some Solaris shell bug?
>
> Under POSIX these constructs seem to be equivalent.
> "If there are no positional parameters, the expansion of '@' shall
> generate zero fields, even when '@' is double-quoted."

I believe he's referring to the following bit (taken from bash's man page):

* Expands to the positional parameters, starting from one.  When the expansion
  occurs within double quotes, it expands to a single word with the value of
  each parameter separated by the first character of the  IFS  special
  variable.   That  is, "$*" is equivalent to "$1c$2c...", where c is the first
  character of the value of the IFS variable.  If IFS is unset, the parameters
  are separated by spaces.  If IFS is null, the parameters are joined without
  intervening separators.
@ Expands to the positional parameters, starting from one.  When the expansion
  occurs within double quotes, each parameter expands to a separate word.  That
  is, "$@" is equivalent to "$1" "$2" ...  If the  double-quoted expansion
  occurs  within a word, the expansion of the first parameter is joined with
  the beginning part of the original word, and the expansion of the last
  parameter is joined with the last part of the original word.  When there are
  no positional parameters, "$@" and $@ expand to nothing (i.e., they are
  removed).

/M

-- 
Magnus Therning(OpenPGP: 0xAB4DFBA4)
magnus@therning.org  Jabber: magnus@therning.org
http://therning.org/magnus identi.ca|twitter: magthe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] GHC RTS question

2010-02-24 Thread Artyom Kazak
2010/2/24 Brandon S. Allbery KF8NH :
> On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote:
>>
>> * Anthony Cowley  [2010-02-21 14:15:00-0500]
>>>
>>> #! /usr/bin/env bash
>>> ./prog --RTS $*
>>
>>  ./prog --RTS "$@"
>>
>> Otherwise it will work wrong if arguments contain quoted field
>> separators (e.g. spaces).
>
>
>  #! /bin/sh
>  ./prog --RTS ${1+"$@"}
>
> The longer specification above should work with whatever /bin/sh is around,
> whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash,
> Debian/Ubuntu dash, etc.
>

And with Windows, of course :) Haskell is cross-platform, isn't it?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe