haskell

Will writing my Web appication in a functional programming language such as Haskell or Erlang make it more scalable than J2EE?

Hi I am writing a Facebook application that would use a Postgres DB along with Facebook APIs and run on Amazon EC2. (and I am hoping for heavy loads ) With Java, I know that DB would be my primary bottleneck and concurrency limitations of Tomcat would be the secondary bottleneck. I could alleviate DB issues with caching and concurren...

Haskell as a highly concurrent server

Let's say I want to write a server in Haskell. The kind that has high concurrency and simple processing. The kind that would be robust to failures and offer high availability. The kind that Erlang would be good for. What would be a good set of tools, whether a framework or a set of primitives, to start from? ...

Efficient recursion in functional programming vs. inefficient recursion in different paradigms

As far as I know recursion is very elegant but unefficient in OOP and procedural programming (see the wonderful "High Order perl", Mark Jason Dominus). I had some informations that in functional programming recursion is fast - keeping its elegance and simplicity. Could someone confirm and possibly amplify this? I am thinking in terms of...

Haskell linear algebra?

I am starting to test Haskell for linear algebra. Does anyone have any recommendations for the best package for this purpose? Any other good resources for doing basic matrix manipulation with Haskell? The haskell wiki lists several resources for this. My current focus in on hmatrix and bindings-gsl, both of which look promising. ...

What does the >> symbol mean in Haskell.

I was reading the Guestbook example for Happstack and noticed the >> symbol which I didn't see before in the textbooks I studied to learn Haskell (for instance see line 23). What is it? Example I could not find it in Google because it ignores the >> totally (Bing does not but comes up with tons of non-related results). Thanks! ...

haskell libmagic how to use it???

I'm trying to write a program that will check the file type of a certain file and I found a haskell library that should do the trick. The problem arises when I try to use it. I have no idea what I have to do, which function to call etc. The library is full of cryptic commands with no examples, no tutorial or a homepage. Please help. ...

Howto use mongoDB bindings for haskell.

Hello, I am pretty new to Haskell but I feel like I have a decent understanding over all. I'm currently trying to play with the unofficial mongoDB bindings for haskell. If you look at the code here: http://github.com/srp/mongoDB/blob/master/Database/MongoDB.hs connect :: HostName -> [ConnectOpt] -> IO Connection connect = flip conn...

Dynamically build list comprehension in Haskell

I am curious if it is possible to dynamically build a list comprehension in Haskell. As an example, if I have the following: all_pows (a,a') (b,b') = [ a^y * b^z | y <- take a' [0..], z <- take b' [0..] ] I get what I am after *Main> List.sort $ all_pows (2,3) (5,3) [1,2,4,5,10,20,25,50,100] However, what I'd really like is to ha...

Catching Control-C exception in GHC (Haskell)

I built a really simple read-eval-print-loop in Haskell that catches Control-C (UserInterrupt). However, whenever I compile and run this program, it always catches the first Control-C and always aborts on the second Control-C with exit code 130. It doesn't matter how many lines of input I give it before and between the two Control-Cs, ...

In Haskell, how can I use the built in sortBy function to sort a list of pairs(tuple)?

I am a beginner in Haskell so please bear with me. (Just started learning yesterday!) How can I sort a list of tuples primarily by their first components (highest to smallest) and secondarily by their second components (smallest to highest)? A sample input/output would be: [(1, "b"), (1, "a"), (2, "b"), (2, "a")] (input) [(1, "a"), (2,...

Why does GHC infer type of `IO b` for an application of `hSetBuffering`?

I am trying to use hSetBuffering in a Haskell program using GHC 6.10. When I try this very simple program: module Ctlc where import IO main :: () main = do hSetBuffering stdout NoBuffering return () I get a baffling error message: ctlc.hs:8:10: Couldn't match expected type `()' against inferred type `IO b' In a st...

In Haskell, is there (Num a) => infinity :: a ?

I'm trying to implement a data structure where if I had the use of infinity for numerical comparison purposes, it would simply things greatly. Note this isn't maxBound/minBound, because a value can be <= maxbound, but all values would be < infinity. No hope? ...

Why does Haskell give me a type error if I hardcode a return value?

I'm really at a loss to explain why this is a type error: foo :: (Eq a) => a -> a foo _ = 2 Can anyone explain? ...

Programatically firing an event in GTK (With Gtk2Hs).

I am using Gtk2Hs (EventM module) to handle GTK events within Haskell. Is it possible to manually (re-)fire an event? Upon detecting an event on one widget, I want to refire this event on another widget. I am using Gtk2Hs version 0.10.1 and GHC version 6.10.4. ...

Map applied to multiple arguments in Haskell

Is there a way to use Haskell's "map" or something similar with multiple arguments? i.e. to find the distance between a given point (defined as a tuple) and a list of other points: map distance (-3,-3) buildings Clearly, that doesn't work, because it tries to map "distance" to (-3,-3), where distance expects two tuples: let distance...

Haskell function composition question

If this works: Prelude Data.Char> map toUpper ("sdfsd" ++ "dfgfdg") "SDFSDDFGFDG" Then why this doesn't? Prelude Data.Char> map toUpper . (++) "sdfsd" "dfgfdg" <interactive>:1:14: Couldn't match expected type `a -> [Char]' against inferred type `[Char]' In the second argument of `(.)', namely `(++) "sdfsd" "dfgfdg...

How do you manage an object graph in Haskell?

I'm trying to re-learn systems analysis. I've got a lot of object-oriented thinking for which I'm not able to find equivalents in Haskell, yet. A fictional system consists of Ambulance Stations, Ambulances and Crew. (It's getting object-y already.) All this state can be wrapped up in a big SystemState type. SystemState [Stations] [A...

haskell vs python typing

I am looking for example where things in python would be easier to program just because it is dynamically typed? I want to compare it with Haskell type system because its static typing doesn't get in the way like c# or java. Can I program in Haskell as I can in python without static typing being a hindrance? PS: I am a python user an...

With Parsec, how do I parse zero or more foo1 terminated by foo2 and all separated by dot?

What I am trying to do seems pretty simple, but since I am a parsec Haskell newb, the solution is eluding me. I have two parsers, let's say foo1 and foo2 where foo1 can parse a intermedate term and foo2 parses an ending term. Terms are separated by a symbol, ".". Sentences that I need to parse are foo2 foo1.foo2 foo1.foo1.foo2 and ...

Haskell types frustrating a simple 'average' function

I'm playing around with beginner Haskell, and I wanted to write an average function. It seemed like the simplest thing in the world, right? Wrong. It seems like Haskell's type system forbids average from working on a generic numeric type - I can get it to work on a list of Integrals, or an list of Fractionals, but not both. I want: ...