I'm trying to put a 'print out' function call in a haskell function.
(a simple debug message).
Below is my code and error message from the compiler (ghc 6.10).
I don't quite understand why it is lumping the putstr call and the empty array.
The empty array is the return value for that particular case (the print out message is actu...
Are there any good ways to make small haskell executables? With ghc6 a simple hello world program seems to come to about 370kB (523kB before strip). Hello world in C is about 4kB (9kB before strip).
...
Does anyone know of a quick-starting Haskell interpreter that would be suitable for use in writing shell scripts? Running 'hello world' using Hugs took 400ms on my old laptop and takes 300ms on my current Thinkpad X300. That's too slow for instantaneous response. Times with GHCi are similar.
Functional languages don't have to be slow...
Cabbage.hs:
module Cabbage where
class Cabbage a
where foo :: a -> String -- the parameter is only present for its type,
-- the parameter value will be ignored
bar :: String -> a
quux :: Cabbage a => String -> a
quux s = bar (s ++ foo (undefined :: a))
When I compile (with ghc) I get thi...
How is this code:
parfib :: Int -> Int
parfib 0 = 1
parfib 1 = 1
parfib n = nf2 `par` (nf1 `par` (nf1+nf2+1))
where nf1 = parfib (n-1)
nf2 = parfib (n-2)
Better than this:
parfib :: Int -> Int
parfib 0 = 1
parfib 1 = 1
parfib n = nf2 `par` (nf1 `seq` (nf1+nf2+1))
where nf1 = parfib (n-1)
...
On OS X I'm trying to install the zlib prerequisite for haskell's Cabal. I get this error:
$ sudo ./Setup build
Preprocessing library zlib-0.5.0.0…
ld: library not found for -lgmp
collect2: ld returned 1 exit status
linking dist/build/Codec/Compression/Zlib/Stream_hsc_make.o failed
command was: /usr/bin/gcc -lz -L/sw/lib/ghc-6.8.3/lib/...
Based on some advice I found on StackOverflow, I'm digging into Haskell. I was pleased to see that Haskell's parameterized types behave very much like C# generics. Both languages advise a single letter for the type parameter (usually), and both languages seem to follow a similiar process for substituting an actual type for the type param...
OK, I realy searched on this one, also in stackOverflow.
(E/TextMate is the closest I found in this topic, but it doesn't seem to be that big of deal)
I tried emacs, but I don't seem to find a Haskell Mode for windows..
VisualHaskell doesn't seem to follow the new VisualStudio updates...
I could try VIM, but does the Haskell Mode works...
I'm using project Euler to teach myself Haskell, and I'm having some trouble reasoning about how my code is being executed by haskell. The second problem has me computing the sum of all even Fibonacci numbers up to 4 million. My script looks like this:
fibs :: [Integer]
fibs = 1 : 2 : [ a+b | (a,b) <- zip fibs (tail fibs)]
evens :: I...
I've got a name clash between two different Haskell modules that want to use the same infix operator (<*>). The Haskell 98 report says that
modid.varsym
is permitted, but I can't get it to work. In their entirety here are Test.hs:
module Test
where
import qualified Test2 as T
three = T.<*>
and Test2.hs:
module Test2
where
(<*>...
It was hard for me to come up with a real-world example for a concurrency:
Imagine the above situation, where
there are many lanes, many junctions
and a great amount of cars. Besides,
there is a human factor.
The problem is a hard research area for traffic engineers. When I investigated it a some time ago, I noticed that man...
NOTE : i don't agree btw this is a double question. Please read carefully.
I want to know more than just production/studying. Maybe I should lay another accent then and rephrase it? One of my questions is :
for GUI
for diff. OS ? Windows?
for anything you can come up with: a general positioning of functional languages thus.
I know t...
What is an alternative to autotools in Haskell world? I want to be able to choose between different configurations of the same source code.
For example, there are at least two implementations of MD5 in Haskell: Data.Digest.OpenSSL.MD5 and Data.Digest.Pure.MD5. I'd like to write code in such a way that it can figure out which library is ...
Consider the following Haskell program. I am trying to program in a "stream style" where functions operate on streams (implemented here simply as lists). Things like normalStreamFunc work great with lazy lists. I can pass an infinite list to normalStreamFunc and effectively get out another infinite list, but with a function mapped ont...
How do I express {2n+3m+1|n,m∈N} in list comprehension form? N is the set of natural numbers, including 0.
...
I am doing some server side html processing in Haskell. Wondering if there is an equivalent of jquery type selector engine implemetation for haskell out there that i could use.
Google doesnt yield anything.
...
I have the following Template Haskell code in my module, which is part of a larger application.
$(derive makeFoldable ''JStatement)
I suspect that the generated instance of Foldable is not exactly what I originally had in mind, but I can't find a way to verify this. So, preferrably using only ghci, is it possible to view the generate...
What would the Foldable instance for this datatype look like?
data X t = X t [X t]
I tried this:
instance Foldable X where
foldMap f (X x xs) = f x `mappend` foldMap f xs
But got this error:
Occurs check: cannot construct the infinite type: a = X a
When generalising the type(s) for `foldMap'
In the instance declaration for `Fo...
I know a few programmers who keep talking about Haskell when they are among themselves, and here on SO everyone seems to love that language. Being good at Haskell seems somewhat like the hallmark of a genius programmer.
Can someone give a few Haskell examples that show why it is so elegant / superior?
...
I'm a C# developer who is working through "Real World Haskell" in order to truly understand functional programming, so that when I learn F#, I'll really grok it and not just "write C# code in F#", so to speak.
Well, today I came across an example which I thought I understood 3 different times, only to then see something I missed, update...