Re: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell

2009-07-06 Thread Hector Guilarte
A few days ago I had to randomly choose and element of a list and continue execution, so here's what I did: I made a infinite list of Random numbers [Int] (Not IO [Int]) and I passed it around all the time in a Tuple and whenever I returned I also returned the list, so I would always have it avail

Re: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell

2009-07-06 Thread Antoine Latter
2009/7/6 Matthias Görgens : > A Las Vegas algorithm, like randomized quicksort, uses a source of > randomness to make certain decisions.  However its output is > unaffected by the randomness.  So a function > >> f :: RandomGen g => g -> a -> b > > implementing a Las-Vegas-Algorithm 'looks' like a p

Re: [Haskell-cafe] golf, predicate check function for MonadPlus (was Re: How to read safely?)

2009-07-06 Thread Antoine Latter
On Mon, Jul 6, 2009 at 8:49 PM, Dan Doel wrote: > > I've often noticed the need for a similar function in conjunction with > unfoldr: > >  -- This is overly general for unfoldr, but it lines up with check >  stopAt :: (MonadPlus m) => (a -> Bool) -> (a -> b) -> a -> m b >  stopAt p f x >    | p x  

Re: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell

2009-07-06 Thread Jason Dagit
2009/7/6 Matthias Görgens > A Las Vegas algorithm, like randomized quicksort, uses a source of > randomness to make certain decisions. However its output is > unaffected by the randomness. So a function > > > f :: RandomGen g => g -> a -> b > > implementing a Las-Vegas-Algorithm 'looks' like a

[Haskell-cafe] BostonHaskell: Next meeting - July 16th at MIT CSAIL Reading Room (32-G882)

2009-07-06 Thread Ravi Nanavati
I'm pleased to announce the July meeting of the Boston Area Haskell Users' Group. Based on the feedback from the June meeting and the constraints of our speakers, the July meeting has been scheduled for Thursday, July 16th from 6:30pm - 8:30pm. Like the June meeting, it will be held in the MIT CSA

Re: [Haskell-cafe] Implementing Las Vegas algorithms in Haskell

2009-07-06 Thread Luke Palmer
2009/7/6 Matthias Görgens > A Las Vegas algorithm, like randomized quicksort, uses a source of > randomness to make certain decisions. However its output is > unaffected by the randomness. So a function > > > f :: RandomGen g => g -> a -> b > > implementing a Las-Vegas-Algorithm 'looks' like a

Re: [Haskell-cafe] golf, predicate check function for MonadPlus (was Re: How to read safely?)

2009-07-06 Thread Dan Doel
On Thursday 02 July 2009 6:36:09 am Jon Fairbairn wrote: > check :: (MonadPlus m) => (a -> Bool) -> a -> m a > check p a > | p a = return a > | otherwise = mzero > > I tried Hoogling for a function like check, but couldn't find it. Surely > there's one in a library somewhere? It looks usefu

Re: [Haskell-cafe] Re: Could FFI support pass-by-value of structs?

2009-07-06 Thread John Meacham
On Thu, Jul 02, 2009 at 03:01:48AM +0400, Bulat Ziganshin wrote: > Hello Duncan, > > Thursday, July 2, 2009, 2:57:29 AM, you wrote: > > > You don't need it to be the same between Windows and Unix, it just has > > to be standard on each platform, which it is. There are really only two > > ABIs in

[Haskell-cafe] Re: what about moving the record system to an addendum?

2009-07-06 Thread John Meacham
Well, without a replacement, it seems odd to remove it. Also, Haskell currently doesn't _have_ a record syntax (I think it was always a misnomer to call it that) it has 'labeled fields'. None of the proposed record syntaxes fit the same niche as labeled fields so I don't see them going away even if

[Haskell-cafe] Implementing Las Vegas algorithms in Haskell

2009-07-06 Thread Matthias Görgens
A Las Vegas algorithm, like randomized quicksort, uses a source of randomness to make certain decisions. However its output is unaffected by the randomness. So a function > f :: RandomGen g => g -> a -> b implementing a Las-Vegas-Algorithm 'looks' like a pure function, ignoring its first argume

Re: [Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Matthias Görgens
The "sorted array of bags of unsorted input" is a nice idea. However, you have to use the data structure in a single-threaded [1] fashion to obtain the claimed bounds. Here's a pure solution that uses amortization and laziness. > import qualified Data.Sequence as S > import Data.Sequence ((><))

Re: [Haskell-cafe] Catering for similar operations with and without state

2009-07-06 Thread phil
Well, the simplest solution I can think of is below. The OtherNormalStateT doesn't actually have any state at all, but still gets state from the StateT 'below' it and returns a result. This is still a bit ugly, but it compiles - and although I haven't tested it properly yet, simply impleme

Re: [Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Andrew Hunter
On Mon, Jul 6, 2009 at 4:32 PM, Matthias Görgens wrote: >> It seems to me, that you just need a selection algorithm which works in >> O(n * k) time for k arbitrary elements. If you combine O(n*k) selection >> algorithm with any O(n * lg n) sort, you furfil your time constrain. > > I guess, we also

Re: [Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Lanny Ripple
Off the top of my head state is important when getting from A to B depends on the path you took. As such a common scenario I find myself in all the time is not having a good CLI craps game. (And which I resolve by rewriting in every language I learn.) Stake, current bet, bets outstanding, point.

Re: [Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Matthias Görgens
> It seems to me, that you just need a selection algorithm which works in > O(n * k) time for k arbitrary elements. If you combine O(n*k) selection > algorithm with any O(n * lg n) sort, you furfil your time constrain. I guess, we also want the list to be sorted in O(1) after having selected every

[Haskell-cafe] LINQ, SQL and hs-dotnet

2009-07-06 Thread Günther Schmidt
Hi all, is there anyone who has already tried using LINQ2SQL with hs-dotnet and would care to share the experience? I'm trying to figure out what exactly it would take to access an SQL database via LINQ / hs-dotnet. Ie. whether or not it's necessary to create Entity classes, or if one can

Re: [Haskell-cafe] Haskell Platform on Ubuntu

2009-07-06 Thread Stefan Roggensack
Hello, I have uploaded the ghc package to my ppa: https://launchpad.net/~someone561/+archive/ppa But I don't work on it. I simple backport the debian sid packages. Also there are not the haskell libraries as debs. Maybe this helps you. Stefan Rafael Gustavo da Cunha Pereira Pinto wrote: > Thanks

Re: [Haskell-cafe] Haskell Platform on Ubuntu

2009-07-06 Thread Rafael Gustavo da Cunha Pereira Pinto
Thanks. I may even be the one to step up, if nothing happens till 9.10... I really miss up-to-date ghc in Ubuntu. 2009/7/6 Don Stewart > RafaelGCPP.Linux: > > > > Is there anyone working on a Haskell Platform package for Ubuntu? > > > > GHC in Ubuntu is a pain! > > The Debian team is working

Re: [Haskell-cafe] Haskell Platform on Ubuntu

2009-07-06 Thread Erik de Castro Lopo
Rafael Gustavo da Cunha Pereira Pinto wrote: > Is there anyone working on a Haskell Platform package for Ubuntu? For Haskell on Ubuntu, the vast majority of all the work is done by the Debian Haskell maintainers. Ubuntu simply takes that work and rolls packages for Ubuntu. > GHC in Ubuntu is a p

Re: [Haskell-cafe] Haskell Platform on Ubuntu

2009-07-06 Thread Don Stewart
RafaelGCPP.Linux: > > Is there anyone working on a Haskell Platform package for Ubuntu? > > GHC in Ubuntu is a pain! The Debian team is working on packaging, but until then (or if someone on Ubuntu steps up), you'll need to use the Unix tarball: http://hackage.haskell.org/platform/2009.2.0

Re: [Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Mads Lindstrøm
Hi Petr, Maybe this will give inspiration http://en.wikipedia.org/wiki/Selection_algorithm It seems to me, that you just need a selection algorithm which works in O(n * k) time for k arbitrary elements. If you combine O(n*k) selection algorithm with any O(n * lg n) sort, you furfil your time cons

Re: [Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Matthias Görgens
> If someone can translate my algorithm into a non-side-effecting one, > I'd appreciate it, but I think that like disjoint set/union, this is > probably inherently side-effecting.  Yes, yes, we could use functional > arrays, but short of that I don't see a way to avoid side effects to > take care o

Re: [Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Andrew Hunter
On Mon, Jul 6, 2009 at 12:26 PM, Petr Pudlak wrote: > More precisely: The result of sorting an n-element list or array should be a > structure that allows to ask i-th element of the result (for example, a lazy > array). Asking k arbitrary elements should take no more than >  O(min(n * log n, k * n)

[Haskell-cafe] Haskell Platform on Ubuntu

2009-07-06 Thread Rafael Gustavo da Cunha Pereira Pinto
Is there anyone working on a Haskell Platform package for Ubuntu? GHC in Ubuntu is a pain! Regards Rafael Gustavo da Cunha Pereira Pinto ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Matthias Görgens
Interesting problem. I have been toying with the same problem for some time. To solve the problem in theory, I'd concentrate on getting the number of comparisons into the required O(n) resp. O(n log n) ranges. Afterwards we can think about building the infrastructure to keep the number of all ope

[Haskell-cafe] excercise - a completely lazy sorting algorithm

2009-07-06 Thread Petr Pudlak
Hi all, about a month ago, we were discussing sorting in Haskell with a friend. We realized a nice property of lazy merge-sort (which is AFAIK the implementation of Data.List.sort): Getting the first element of the sorted list actually requires O(n) time, not O(n * log n) as in imperative language

Re: [Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Matthias Görgens
> Can someone give some simple common scenarios where the state monad is > useful, besides labeling trees? Emulating the VM given in this years ICFP programming contest was also a good application of the state monad. Of course you interprate much simpler language imperative languages, too. (Howe

Re: [Haskell-cafe] ANN: bloxorz clone

2009-07-06 Thread Patai Gergely
> Will the darcs (or.. ) repository for the code be made public? > I'm sure there are people in the community who'd like to contribute new > levels, etc. I don't think there is a repository at all, and I'm not even sure if Viktor wants to maintain it. I'll ask and direct him to the list. Gergely

Re: [Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Thomas ten Cate
I used the State monad to implement a Brainfuck [1] interpreter a few months ago. It stored the program counter, pointer and the memory of the machine. There might have been a different (better?) way, but as I was trying to learn more about monads, it was an obvious choice. Thomas [1] http://www

Re: [Haskell-cafe] Re: Haskell Platform 2009.2.0.1 and GLUT32.DLL on Windows: which version?

2009-07-06 Thread Peter Verswyvelen
Okay, thanks for this feedback. I tried [2] but that failed. Since it works on your system I'll double check again tomorrow, it must be picking an incorrect GLUT32.dll I guess On Mon, Jul 6, 2009 at 5:11 PM, Mikhail Glushenkov < the.dead.shall.r...@gmail.com> wrote: > Hi Peter, > > Peter Verswyve

Re: [Haskell-cafe] ANN: bloxorz clone

2009-07-06 Thread Don Stewart
patai_gergely: > > Here's a video of bloxorz at work, very cool! > > > > > > http://archhaskell.wordpress.com/2009/07/04/bloxorz-an-opengl-logic-game-written-in-haskell/ > I see it wasn't rehearsed in advance. ;) Will the darcs (or.. ) repository for the code be made public? I'm sure there a

[Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Thomas Hartman
Can someone give some simple common scenarios where the state monad is useful, besides labeling trees? References to puzzles like those in project Euler or similar would be nice. Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.

Re: [Haskell-cafe] ANN: bloxorz clone

2009-07-06 Thread Daniel van den Eijkel
Very nice! Just to give feedback: It installs and works perfectly on windows. kind regards, daniel Patai Gergely schrieb: Hello all, This post is not about my own creation, it's just a little fun program written by a student of mine. You can install the bloxorz package to try it out, and read

[Haskell-cafe] Re: Haskell Platform 2009.2.0.1 and GLUT32.DLL on Windows: which version?

2009-07-06 Thread Mikhail Glushenkov
Hi Peter, Peter Verswyvelen gmail.com> writes: > I know GLUT32.DLL is not bundled with the Haskell Platform > installer, but which GLUT32.DLL should I use? I compiled a basic example [1] successfully using the DLL downloaded from [2]. But since that's the first hit in Google, you've probably a

Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-07-06 Thread Ketil Malde
Mattias Bengtsson writes: >> (?) is also undefined in Prelude. > Which i think is a good thing. > I think it's quite nice to use (?) as an operator in higher order > functions. Also, it clashes with the implicit parameters extension, and combining the extension with a user-defined (?) operato

Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-07-06 Thread Mattias Bengtsson
On Sun, 2009-07-05 at 22:30 +0200, Henning Thielemann wrote: > > (?) is also undefined in Prelude. Which i think is a good thing. I think it's quite nice to use (?) as an operator in higher order functions. Eg. foldr _ z [] = z foldr (?) z (x:xs) = x ? foldr (?) z xs ___

[Haskell-cafe] Re: Documentation design

2009-07-06 Thread Peter Hercek
I like your proposal. Few notes below. On Sun, 05 Jul 2009 23:45:31 -0400, Isaac Dupree wrote: > My dream situation: both haddock-pages and hscolour-pages would be > super-hyperlinked and super-readable. For example, haddock would list > all a module's definitions, not just its exports. In HsCol

[Haskell-cafe] Haskell Platform 2009.2.0.1 and GLUT32.DLL on Windows: which version?

2009-07-06 Thread Peter Verswyvelen
I know GLUT32.DLL is not bundled with the Haskell Platform installer, but which GLUT32.DLL should I use? Every DLL I tried (even building FreeGLUT myself) gives the error: *"The procedure entry point glutAddMenuEntry cou