If I got the line
> { -# OPTIONS_GHC -fglasgow-exts -XTemplateHaskell #- }
in the documentation-part (description) of the .cabal-file I'll get the error message
haddock: parsing haddock prologue failed
when running
$ cabal haddock
but if I get rid of the { and } everything works fine. Is there some way to escape {} so they can b...
How would one implement a list of prime numbers in Haskell so that they could be retrieved lazily?
I am new to Haskell, and would like to learn about practical uses of the lazy evaluation functionality.
...
Quick question I've encountered while getting my feet under me in Haskell related to this quick test:
module Main where
main :: IO()
main = putStrLn (show (inc 3))
inc :: (Num a) => a -> a
inc x = x+1
Is there a better way to output the value of the inc function? I could not get output without using nested parens to force evaluation ...
hi, how can I pass a Data.Map mapping Int to [Char] in haskell? How do the function header looks like? Let's assume that the function will return an int
import qualified Data.Map as M
someFunction :: <insert your answer here> -> Int
...
I'm learning haskell. Currently working through 99 questions, a little bit stuck on #7:
Problem 7
(**) Flatten a nested list structure.
Transform a list, possibly holding lists as elements into a `flat' list by replacing each list with its elements (recursively).
Example in Haskell:
*Main> flatten (Elem 5)
[5]
*Main> fla...
I have to develop a fast heuristic-like algorithm for a hard combinatorial problem. Therefore I think, it would be the best to learn a more expressive language than C++ first for tackling the problem, because I think a lot of different algorithm attempts are needed to solve my assignment.
Some personal views about some languages which a...
The Towers of Hanoi problem is a classic problem for recursion. You are given 3 pegs with disks on one of them, and you must move all the disks from one peg to another, by following the given rules. You must also do this with the minimum number of moves.
Here's a recursive algorithm that solves the problem:
void Hanoi3(int nDisks, char...
Hi all . Look at this , i am try
appendFile "out" $ show 'д'
'д' is character from Russian alphabet.
After that "out" file contains:
'\1076'
How i understand is the unicode numeric code of character 'д'. Why is it happens ? And How i can to get the normal representation of my character ?
For additional information it is works...
Yes, I know these kinds of questions have been asked a million times, but it just seems no matter how much research I do, there are great arguments for every side you can think of. I know the standard/best practice would be to just 'try them all, and see which one you like', but I really would rather have a better idea before I dedicate ...
The followng snippet contains a solution for exercise 3 on page 69 (write a function mean to calculate the mean of a list).
While writing some QuickCheck tests to verify whether the its results are more or less sane, I found that on my system (ghc 6.12.3, Haskell Platform 2010.2.0.0 on 32-but Ubuntu 10.4) the tests work for Integer inpu...
I'm reading Learn You a Haskell and I'm wondering why so many things are acting like a list, and nothing in the Prelude is using the native facility of type classes to set this up:
"The bytestring version of : is called cons It takes a byte and a bytestring and puts the byte at the beginning. It's lazy though, so it will make a new c...
I'm trying to write a function that takes a predicate f and a list and returns a list consisting of all items that satisfy f with preserved order. The trick is to do this using only higher order functions (HoF), no recursion, no comprehensions, and of course no filter.
...
I have high hopes of the Haskell Platform. It would great if it could lift Haskell on the same out-of-the-box experience level as Java, Python and Ruby etc.
But even though there is a release planned for November 1st 2010, even after digging around on the Haskell wiki, the HP Trac and the mailing list, i am unable to find out what will ...
Suppose I have a state monad such as:
data Registers = Reg {...}
data ST = ST {registers :: Registers,
memory :: Array Int Int}
newtype Op a = Op {runOp :: ST -> (ST, a)}
instance Monad Op where
return a = Op $ \st -> (st, a)
(>>=) stf f = Op $ \st -> let (st1, a1) = runOp stf st
(...
I'm trying to write a small script which parses and executes Brainfuck code, to understand the GHC options of optimization, I'm trying to optimize the code in order to be a bit faster and to understand what's going on there.
On of the parts is the internal represantation of BF-code, I use a special datatype for this. Here's the sourceco...
[Disclaimer] I am very new to Haskell (and any FPL for that matter), just started learning today by reading YAHT. So my code might look "funny". Any help to improve the coding style would be appreciated as well.
I was trying to write a function in Haskell that generates a list with series 1 to n for a given value of n, starting with +1 ...
Can anybody explain why exceptions may be thrown outside the IO monad, but may only be caught inside it?
...
I'm trying to utilize the Maybe type in Haskell. I have a lookup for key, value tuples that returns a Maybe. How do I access the data that was wrapped by Maybe? For example I want to add the integer contained by Maybe with another integer.
...
Link to truncated version of example document
I'm trying to extract the large chunk of text in the last "pre", process it, and output it.
For the purposes of argument, let's say I want to apply
concatMap (unwords . take 62 . drop 11) . lines
to the text and output it.
This takes over 400M of space on a 4M html document when I do it....
I install wxWidgets with macports then ran the command: sudo cabal install wx which output included:
/bin/sh: wxdirect: command not found
/bin/sh: wxdirect: command not found
/bin/sh: wxdirect: command not found
/bin/sh: wxdirect: command not found
Configuring wxcore-0.12.1.6...
setup: Missing dependency on a foreign library:
* Missing ...