haskell

Are there any MVC web frameworks for Haskell?

Are there any MVC web frameworks for Haskell? ...

Haskell tail-recursion performance question for Levenshtein distances

I'm playing around with calculating Levenshtein distances in Haskell, and am a little frustrated with the following performance problem. If you implement it most 'normal' way for Haskell, like below (dist), everything works just fine: dist :: (Ord a) => [a] -> [a] -> Int dist s1 s2 = ldist s1 s2 (L.length s1, L.length s2) ldist :: (Or...

Why am I getting this warning from GHCi?

I'm getting a curious warning when pattern matching, but only when OverloadedStrings is enabled... $ ghci -Wall GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> let f x = case...

Haskell : how to stop Data.Attoparsec.Char8.sepBy when input String is empty ?

hi i've wrote the following Haskell code import Data.Attoparsec (Parser) import qualified Data.Attoparsec.Char8 as A import qualified Data.ByteString.Char8 as B someWithSep sep p = A.sepBy p sep the code is suppose to work this way : main*> A.parse (someWithSep A.skipSpace A.decimal) $ B.pack "123 45 67 89" Done "" [123,45,67,89]...

"maybe"-like function for Bool and List?

Sometimes i find myself progamming the pattern "if the Bool is not false" or "if the list is not empty use it, otherwise use something else". I am looking for functions for Bool and List that are what the "maybe" function is to Maybe. Are there any? Update: I meant to use the Bool-case as a generalization of the List-case. For example ...

Conventions for Stability field of Cabal packages

Cabal allows for a freeform Stability field: stability: freeform The stability level of the package, e.g. alpha, experimental, provisional, stable. What are the community conventions about these stability values? What is considered experimental and what is provisional? I see only few packages are declared as stable. Wh...

haskell "invalid type signature error"

i defined the function NewLine NewLine :: String -> String NewLine (x:xs)=if (x=='\n') then xs else NewLine xs gives me invalid type signature error...and i don't see why? thanks... ...

is there a lazy way to write the minus function (remove items from a list)?

My function looks like this: minus :: (Eq a) => [a] -> [a] -> [a] minus [] xs = [] minus (y:ys) xs | y `notElem` xs = y : (minus ys xs) | otherwise = minus ys xs It can be used like this: [99,44,55,22,23423] `minus` [55,22] with output: [99,44,23423] I wrote this because I'm looking at Pro...

What is the Haskell response to Node.js?

I believe the Erlang community is not envious of Node.js as it does non-blocking I/O natively and has ways to scale deployments easily to more than one processor (something not even built-in in Node.js). More details at http://journal.dedasys.com/2010/04/29/erlang-vs-node-js and http://stackoverflow.com/questions/3011317/node-js-or-erla...

haskell regex substitution

Despite the ridiculously large number of regex matching engines for Haskell, the only one I can find that will substitute is Text.Regex, which, while decent, is missing a few thing I like from pcre. Are there any pcre-based packages which will do substitution, or am I stuck with this? ...

Advantages of subtyping over typeclasses

What are the advantages of OOP subtyping over typeclasses, if any? In other words, now that we have typeclasses, is there any reason to still use OOP subtyping? PS: I am a Scala programmer. ...

Is it possible to define new ADTs in GHCi

While commenting on new features in ghci I wished that ghci had the ability to declare type declaration and declaring new ADT types, someone informed that it was indeed possible, and after searching I found this page which told me I could do let numUniques' :: (Eq a) => [a] -> Int; numUniques' = length . nub Apparently that same sort...

Pattern Matching a Haskell list of variable size

EDIT: I shouldn't be coding when this tired. I was compiling a different copy of the program than I was running. Sorry for wasting your time. I have the following code to make a single argument optional in my program's startup. main = do args <- getArgs handleArgs args handleArgs :: [String] -> IO () handleArgs (server:nick:ch...

Unsafe coerce and more efficient Agda code (-ftrust-me-im-agda)

On the Agda mailing list, Conor McBride asked: is there any way to get hold of operations like a putative trustFromJust :: Maybe x -> x which doesn't actually check for Just and Goes Wrong (in Milner's sense) if fed Nothing? Agda might prove Maybe a == Just1 a, and the intermediate constructor for the sum type could b...

Sieve of Eratosthenes in Haskell

Hi, I'm solving some classic problems in Haskell to develop my functional skills and I have a problem to implement an optimization suggested at http://programmingpraxis.com/2009/02/19/sieve-of-eratosthenes/ I have three "solutions" to this problem and the third one is too slow compared to the second solution. Can someone suggest some...

null instead of ==

I have just started to learn Haskell out of interest. I follow learnyouahaskell.com. There I found this: null checks if a list is empty. If it is, it returns True, otherwise it returns False. Use this function instead of xs == [] (if you have a list called xs) Why is that? Why should we use null instead of == when both pro...

Using Haskell's SimpleHTTP with a Proxy?

I'm trying to figure out how make a basic GET request using Network.HTTP.simpleHTTP that will use a proxy. I have tried setting the http_proxy environment variable, and I think I understand how to make a Proxy using Network.HTTP.Proxy. But there seems to be nothing in the API on Hackage for how to set a simpleHTTP call or Request type ...

Real world use of GADT

Is there any good resource on real use of Generalized Abstract Data Type? The example given in the haskell wikibook is too short to give me an insight of the real possibilities of GADT. Thanks ...

Calling Haskell from C++ code

I'm currently writing an app in C++ and found that some of its functionality would be better written in Haskell. I've seen instructions on calling Haskell from C code, but is it possible to do the same with C++? EDIT: To clarify, what I'm looking for is a way to compile Haskell code into an external library that g++ can link with the ob...

Is it bad to use toList ?

Suppose 2 Maps import qualified Data.Map as M sparse1, sparse2 :: M.Map Int Float sparse1 = M.fromList [(1,2.0),(10,3),(12,5),(100,7),(102,11)] sparse2 = M.fromList [(2,13.0),(11,17),(12,19),(101,23),(102,29)] How do you define an elegant function combi :: M.Map Int Float -> M.Map Int Float -> Float such that combi sparse1 sparse2 ...