haskell

Concurrent program languages for Chat and Twitter-like Apps.

I need to create a simple Chat system like facebook chat and a twitter-like app. What is the best concurrent program languages in this case ? Erlang, Haskell, Scala or anything else ? Thanks ^_^ ...

Type patterns and generic classes in Haskell

I'm trying to understand type patterns and generic classes in Haskell but can't seem to get it. Could someone explain it in laymen's terms? In [1] I've read that "To apply functions generically to all data types, we view data types in a uniform manner: except for basic predefined types such as Float, IO, and →, every Haskell data t...

Capturing audio input from microphone, with Haskell?

Is there a mature library that could enable audio input and output and work within Haskell? (A nice wrapper is fine, of course.) I'm looking for something that can easily capture microphone input and, perhaps, play various audio files as well. Thanks. ...

Deriving arbitrary functions in Haskell

When working with derived instances in Haskell, is it possible to derive functions for arbitrary types, or are we restricted to particular functions? ...

Invoke Haskell function with heterogeneous arguments?

I'm currently working on a Haskell project which automatically tests some functions based on an XML specification. The XML specification gives the arguments to each function and the expected result that the function will provide (the arguments are of many different types). I know how to extract the function arguments from the XML and par...

Examples of attoparsec in parsing binary file formats?

Previously attoparsec was suggested to me for parsing complex binary file formats. While I can find examples of attoparsec parsing HTTP, which is essentially text based, I cannot find an example parsing actual binary, for example, a TCP packet, or image file, or mp3. Can someone post some code or pointer to some code which does this usin...

How do Scala parser combinators compare to Haskell's Parsec?

I have read that Haskell parser combinators (in Parsec) can parse context sensitive grammars. Is this also true for Scala parser combinators? If so, is this what the "into" (aka ">>") function is for? What are some strengths/weaknesses of Scala's implementation of parser combinators, vs Haskell's? Do they accept the same class of gra...

pointers in haskell?

hi, do you know if are there pointers in haskell? -If yes, how do you use them? Are there any problems with them? And why aren't they popular? -If no, is there any reason for it? Please help us!! :) Thank you so much!! ...

Haskell: Constrain function on type Double to only work with Integers

Suppose I'm writing a function that takes a list of integers and returns only those integers in the list that are less than 5.2. I might do something like this: belowThreshold = filter (< 5.2) Easy enough, right? But now I want to constrain this function to only work with input lists of type [Int] for design reasons of my own. This se...

Haskell parsec parsing a string of items

I have a list that I need to parse where the all but the last element needs to be parsed by one parser, and the last element needs to be parsed by another parser. a = "p1 p1b ... p2" or a = "p2" Originally I tried parser = do parse1 <- many parser1 parse2 <- parser2 return AParse parse1 parse2 The problem is...

Finding the shortest path between two points on a grid, using Haskell.

This is a problem that I can easily enough solve in a non-functional manner. But solving it in Haskell is giving me big problems. Me being inexperienced when it comes to functional programming is surely a reason. The problem: I have a 2D field divided into rectangles of equal size. A simple grid. Some rectangles are empty space (and c...

Evaluation of Haskell Statements/Expressions using GHC API

For a tool I'm writing ( http://hackage.haskell.org/package/explore ) I need a way to read haskell function definitions at run-time, apply them to values from my tool and retrieve the results of their application. Can anyone give me a very basic example using GHC (6.10.4 or 6.12.1) API? example function definition to be read from a fil...

What causes "Error C stack overflow" in haskell usually

What are the usual causes of "Error C stack overflow" in the Hugs Haskell implementation. ...

Point-free in Haskell

I have this code that I want to make point-free; (\k t -> chr $ a + flip mod 26 (ord k + ord t -2*a)) How do I do that? Also are there some general rules for point free style other than "think about this amd come up with something"? ...

Why won't the following haskell code compile?

I'm in the process of writing a small lisp interpreter in haskell. In the process i defined this datatype, to get a less typed number; data Number = _Int Integer | _Rational Rational | _Float Double deriving(Eq,Show) Compiling this fails with the following error: ERROR "types.hs":16 - Syntax error in da...

Writing a function List to a tuple

how to write a function from list to a tuple i have taken the string to a tuple. but i need to send it to a tuple. can someone help me ...

How to zip multiple lists in Haskell?

In python zip function accepts arbitrary number of lists and zips them together. >>> l1 = [1,2,3] >>> l2 = [5,6,7] >>> l3 = [7,4,8] >>> zip(l1,l2,l3) [(1, 5, 7), (2, 6, 4), (3, 7, 8)] >>> How can I zip together multiple lists in haskell? ...

How to Convert Type in Tuples

how to convert a String type to a Int i have a tuple and i want to convert it to a tuple which has different types tupletotuple :: (String,String,String) ->(String,Int,Int) tupletotuple (a,b,c) = (a,read(b),read(c)) i get this Error Msg Project> tupletotuple ("cha",4,3) ERROR - Cannot infer instance *** Instance : Num [Char] *** E...

Whats the difference between IO String and normal String in Haskell

is there a difference like that from IO String to String i want to take some String values from a IO. can anyone tell me about this issue. im clueless ...

string formatting in Haskell

What is haskell equivalent of string str = string.Format("{0} {1}",10,20); // C# ...