Re: [Haskell-cafe] how can this code be less?

2008-04-25 Thread Ketil Malde
cetin tozkoparan [EMAIL PROTECTED] writes: sublist :: Eq a = [a] - [a] - Bool sublist [] _ = True sublist (_:_) [] = False This can be simplified a bit, I think (Reformatted to one line): sublist (x:xs) (y:ys) | x == y = if isEqual (x:xs) (y:ys) == False then sublist (x:xs) ys else

Re: [Haskell-cafe] Re: Stronger STM primitives needed? Or am I just doing it wrong?

2008-04-25 Thread Wouter Swierstra
On 24 Apr 2008, at 12:02, apfelmus wrote: Sounds good. But I wonder what obscure optimization comes next; can we have a toy-model of STM? I mean, it should be possible to express both the continuation-logging and read-only-fail optimization in terms of type STM a = Maybe a or similar?

RE: Re[2]: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-25 Thread Simon Peyton-Jones
| 1) Why is the Prelude mapM so slow? It seems like running 10x slower | than mapM_ when generating only 50,000 return values is a problem. All this does seem odd. I've submitted a ticket so we don't forget it http://hackage.haskell.org/trac/ghc/ticket/2236 It appears to be some bad (possibly

Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Hans Aberg
On 18 Apr 2008, at 20:04, Martin Sulzmann wrote: Let's consider our running example class D a b | a - b instance D a b = D [a] [b] which we can write in CHR notation D a b, D a c == b=c(FD) D [a] [b] = D a b (Inst) These rules overlap. I experimented with translations into GNU

[Haskell-cafe] Re: Help me refactor this type!

2008-04-25 Thread apfelmus
Ryan Ingram wrote: More FRP stuff: a new type for Future that came to me in an inspiration this morning. But it's ugly and I need someone with better theoretical underpinnings than me to tell me what I've really built :) data Future t a = Known t a | Unknown (t - IO (STM (Maybe (Future t

[Haskell-cafe] Re: how can this code be less?

2008-04-25 Thread Christian Maeder
You may want to study the code form Data.List first: isInfixOf :: (Eq a) = [a] - [a] - Bool isInfixOf needle haystack = any (isPrefixOf needle) (tails haystack) cetin tozkoparan wrote: I wrote this code and Can it be less? [2,4,5] list is sub list of [3,7,*2,4,5*,9] list and

[Haskell-cafe] Re: how can this code be less?

2008-04-25 Thread Christian Maeder
Christian Maeder wrote: isEqual :: Eq a = [a] - [a] - Bool isEqual [] _ = True isEqual (_:_) [] = False isEqual (x:xs) (y:ys) | x==y = isEqual xs ys | otherwise= False isEqual is not needed, because Eq provides == over lists, too. Ah, isEqual isn't ==, but isPrefixOf. C.

Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Tom Schrijvers
On Fri, 25 Apr 2008, Hans Aberg wrote: On 18 Apr 2008, at 20:04, Martin Sulzmann wrote: Let's consider our running example class D a b | a - b instance D a b = D [a] [b] which we can write in CHR notation D a b, D a c == b=c(FD) D [a] [b] = D a b (Inst) These rules overlap. I

[Haskell-cafe] Higher order randomness and the fat tails

2008-04-25 Thread Steve Lihn
Hi, Haskellers, This email is only remotely connected to this list. Recently I am doing some research on the fat tails (in fact, I simply bumped into it) on the stock market. I came up with an equation which I think solves the fat tails -- which is really the Levy stable distribution. During the

Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Hans Aberg
On 25 Apr 2008, at 14:20, Tom Schrijvers wrote: Prolog works under the assumption of a closed world. That's contrary to the open world view of regular type classes. So these aren't the intended semantics. By which I gather you mean the interpretation of :- as logical connective = rather

Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Tom Schrijvers
On Fri, 25 Apr 2008, Hans Aberg wrote: On 25 Apr 2008, at 14:20, Tom Schrijvers wrote: Prolog works under the assumption of a closed world. That's contrary to the open world view of regular type classes. So these aren't the intended semantics. By which I gather you mean the interpretation

Re: [Haskell-cafe] lookup tables style guidelines

2008-04-25 Thread Jan-Willem Maessen
On Apr 24, 2008, at 11:33 AM, Adrian Hey wrote: Also, if you're likely to be using union/intersection a lot you should know that Data.Map/Set are very slow for this because they use the not efficient hedge algorithm :-) OK, I'm going to bite here: What's the efficient algorithm for union

[Haskell-cafe] Haskell Web server

2008-04-25 Thread Cetin Sert
Hi, What is the fastest way to set up a web server that can redirect requests to a haskell application and serve results returned by it? I need to demonstrate a simple visualization tool I have written for analytic tableaux on Monday and need something easy and simple. Best Regards, Cetin Sert

Re: [Haskell-cafe] looking for examples of non-full Functional Dependencies

2008-04-25 Thread Hans Aberg
On 25 Apr 2008, at 15:38, Tom Schrijvers wrote: Prolog works under the assumption of a closed world. That's contrary to the open world view of regular type classes. So these aren't the intended semantics. By which I gather you mean the interpretation of :- as logical connective = rather

Re: [Haskell-cafe] Haskell Web server

2008-04-25 Thread Don Stewart
cetin.sert: Hi, What is the fastest way to set up a web server that can redirect requests to a haskell application and serve results returned by it? I need to demonstrate a simple visualization tool I have written for analytic tableaux on Monday and need something easy and

[Haskell-cafe] Why doesn't GHC use the Hugs definition of splitAt to avoid traversing the first part of the list twice?

2008-04-25 Thread Richard Kelsall
I've just been investigating a performance oddity in using splitAt on a long stream of random numbers. I don't understand why GHC appears to want to traverse the first part of the list twice. GHC seems to implement the splitAt function something like splitAt n xs = (take n xs, drop n xs)

[Haskell-cafe] n00b circular dep question

2008-04-25 Thread Jennifer Miller
Hi all, This is my first post, and I'm a n00b, so go easy if I breach protocol. :-) I have a graph where the nodes contain a number of fields of various types. The values for one of those fields -- call it Mass -- need to reside in a separate file from the main graph definition (this is for

Re: [Haskell-cafe] functional update

2008-04-25 Thread Evan Laforge
Thanks everyone, this is all good stuff. I did look at Clean and it looks like it has somewhat nicer record syntax... but it doesn't look like anything haskell couldn't do better if it one day got a real record system. As for the rest of Clean, I'm afraid that spending too much time with it will

Re: [Haskell-cafe] n00b circular dep question

2008-04-25 Thread Jake Mcarthur
On Apr 25, 2008, at 11:54 AM, Jennifer Miller wrote: I have a circular dependency in my modules that I don't know how to resolve in Haskell. I'm pretty sure that GHC will sort out those dependencies for you as long as you are exporting the correct things from each module. - Jake

Re: [Haskell-cafe] n00b circular dep question

2008-04-25 Thread Aaron Tomb
On Apr 25, 2008, at 9:54 AM, Jennifer Miller wrote: So, I have a circular dependency in my modules that I don't know how to resolve in Haskell. I went looking for the equivalent of #include which is how I would have solved this in C++. I'm sure there is a simple answer to this and I'm

Re: [Haskell-cafe] n00b circular dep question

2008-04-25 Thread Bulat Ziganshin
Hello Jennifer, Friday, April 25, 2008, 8:54:42 PM, you wrote: So, I have a circular dependency in my modules that I don't know how to resolve in Haskell. 1. haskell standard allows circular deps between modules 2. ghc supports this part of standard in a rather awkward way - you need to

[Haskell-cafe] My try for a CoroutineT monad tranformer

2008-04-25 Thread Joachim Breitner
Hi, (for those who follow planet.haskell.org this is old news, but I thought I’d tell the others) In http://www.joachim-breitner.de/blog/archives/291-Pausable-IO-actions-for-better-GUI-responsiveness.html I describe how I wrote a monad transformer that allows me to pause a computation from

Re: [Haskell-cafe] My try for a CoroutineT monad tranformer

2008-04-25 Thread Dan Weston
I guess like minds think alike! See the very recent e-mail thread started by Ryan Ingram: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/39155/focus=39159 Take a look at the code referenced in Luke Palmer's reply:

Re: [Haskell-cafe] My try for a CoroutineT monad tranformer

2008-04-25 Thread Joachim Breitner
Hi, Am Freitag, den 25.04.2008, 11:49 -0700 schrieb Dan Weston: I guess like minds think alike! See the very recent e-mail thread started by Ryan Ingram: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/39155/focus=39159 Take a look at the code referenced in Luke Palmer's reply:

Re: [Haskell-cafe] My try for a CoroutineT monad tranformer

2008-04-25 Thread Dan Weston
Is there a Haskell Wiki page (or blog) on Monad Suspension? This looks like a nice paradigm that apfelmus points out can be used to considerably shorten your code, but only if the rest of us learn how! If not, maybe someone can be persuaded to write one? Dan Joachim Breitner wrote: Hi, Am

Re: Re[2]: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-25 Thread Chaddaï Fouché
2008/4/25, Niklas Broberg [EMAIL PROTECTED]: Wow. A 10x slowdown for a very commonly used function that in 99.8% of all use cases has no need for the extra laziness at all. No wonder some people say Haskell is a toy language... A toy language that is still much faster than many currently

[Haskell-cafe] Re: I hate Haskell's typeclasses

2008-04-25 Thread Ben Franksen
Jonathan Cast wrote: Type case is easy: genericShow :: Typeable a = a - String genericShow x = fromJust $ do s - cast x :: Maybe String return s `mplus` do n -

Re: Re[2]: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-25 Thread Niklas Broberg
Wow. A 10x slowdown for a very commonly used function that in 99.8% of all use cases has no need for the extra laziness at all. No wonder some people say Haskell is a toy language... A toy language that is still much faster than many currently popular languages so... Is

Re: [Haskell-cafe] n00b circular dep question

2008-04-25 Thread Henning Thielemann
On Fri, 25 Apr 2008, Jennifer Miller wrote: I have a graph where the nodes contain a number of fields of various types. The values for one of those fields -- call it Mass -- need to reside in a separate file from the main graph definition (this is for workflow reasons and is given to me as

Re: [Haskell-cafe] My try for a CoroutineT monad tranformer

2008-04-25 Thread David Menendez
On Fri, Apr 25, 2008 at 3:45 PM, Dan Weston [EMAIL PROTECTED] wrote: Is there a Haskell Wiki page (or blog) on Monad Suspension? This looks like a nice paradigm that apfelmus points out can be used to considerably shorten your code, but only if the rest of us learn how! There are a few papers

[Haskell-cafe] Trying to build a stand-alone executable GLUT app with ghc, Windows XP

2008-04-25 Thread Peter Schmitz
Problem summary Trying to build a stand-alone executable GLUT app with ghc, Windows XP Problem description I compile and link (without errors) a simple GLUT application under Windows XP. When I run it, XP pops an error window saying the app cannot start due to a missing glut32.dll. I want to

Re: [Haskell-cafe] Trying to build a stand-alone executable GLUT app with ghc, Windows XP

2008-04-25 Thread Austin Seipp
Perhaps try: $ ghc --make -static -optl-static -lpath to libHSGLUT.a here x.hs The -optl-static passes the '-static' argument to ld so it will link statically; you may also need a copy of a compatable GLUT library in .a format on your windows machine which should be linked in with -l as well

Re: [Haskell-cafe] Trying to build a stand-alone executable GLUT app with ghc, Windows XP

2008-04-25 Thread Jefferson Heard
Google download glut32.dll and pull that file down and put it in the directory with your executable. I'd attach it myself, but gmail won't let me. I use that all the time, though. 2008/4/25 Peter Schmitz [EMAIL PROTECTED]: Problem summary Trying to build a stand-alone executable GLUT app

Re: [Haskell-cafe] n00b circular dep question

2008-04-25 Thread Jennifer Miller
Thanks for the suggestions. The #include worked but I will look for ways to remove the circular dependency altogether. Jennifer On Friday, April 25, 2008, at 02:48PM, Henning Thielemann [EMAIL PROTECTED] wrote: On Fri, 25 Apr 2008, Jennifer Miller wrote: I have a graph where the nodes