Haskell is an purely functional programming language, featuring static typing, lazy evaluation, and monadic effects. The primary implementation is GHC: a high-performance compiler with a runtime supporting many forms of parallelism and concurrency.
2
votes
2answers
76 views
Is this permutation applicative/monad implementation clear?
Below is a module that executes a sequence of actions in any possible order. LANGUAGE_DataKinds and LANGUAGE_DefaultSignatures are predefined cpp symbols. I am particularly concerned about the use ...
4
votes
1answer
108 views
Is this idiomatic Haskell?
I've been studying hard and asking a lot of questions - I finally came a cross an exercise in LYAH that looked like it was easy enough but a perfect candidate for practicing.
The below program has a ...
2
votes
2answers
96 views
Calling a Haskell MD5 hashing function from C, and returning the result back to C land
I'm starting to learn how to meld the worlds of C and Haskell. Looking for any feedback on this first function.
The function takes in a pointer to an array of unsigned chars and returns a pointer to ...
3
votes
2answers
75 views
Ordinary Data Processing Task in Haskell: Vague Misgivings
This is an ordinary data processing task: read a list of dates and amounts (for example, deposits and withdrawals from a bank account) and report the date on which the lowest balance was recorded and ...
3
votes
1answer
80 views
Help make nested folds look less terse
My Haskell set/map/list folds often become terse and difficult to read. I'm looking for tips on how to make my functional code easier to follow.
I'm working around a bug/feature in a plotting ...
6
votes
4answers
156 views
How to use Haskell as a scripting language for every day task?
In book Real World Haskell the author writes in the first line of every file that uses, for example the following: file: ch05/PrettyJSON. The chapter slash and the name of a module. I wanted to create ...
10
votes
4answers
1k views
How to shorten this terrible code?
I am trying to read a line ending in \r\n from a Handle. This is an HTTP header.
I’m fairly new to functional programming, so I tend to use a lot of case expressions and stuff. This makes the code ...
4
votes
3answers
161 views
Haskell: Nearest Neighbour classification algorithm
The following code is from a university assignment of mine to write a classification algorithm (using nearest neighbour) to classify whether or not a given feature set (each feature is the frequency ...
4
votes
2answers
123 views
Project Euler #9 in haskell
I am trying to teach myself haskell by means of project Euler
i sovled problem #9 by means of this code which is on the brute force side I was wondering if there is a more elegant/haskell/efficient ...
3
votes
1answer
58 views
mapM for both keys and values of Data.Map
I'm writing a monadic parser instance that transforms Data.Map.Map's:
instance (Ord a, FromEDN a, FromEDN b) => FromEDN (M.Map a b) where
parseEDNv (E.Map m) = mapMmap parseEDNv parseEDN m
...
6
votes
2answers
197 views
Review my small Haskell program please
I want an experienced Haskeller to critique my code and offer changes/suggestions (so I can learn the idioms of the language and culture around Haskell).
I've been using a Tabula Recta for my ...
4
votes
2answers
99 views
Writing an infinitely running( while(true) { } ) user input function in haskell
I'm trying to implement a lexer in Haskell. For easy console input and output, I've used an intermediate data type Transition Table.
type TransitionTable = [(Int, Transitions String Int)]
type ...
2
votes
1answer
88 views
Initating in haskell, am I following a good way?
I'm a bit concerned about fucntion usage. There are so many diferent libraries/possible ways to do something that I'm not sure if the way I'm working at the moment is reasonable, or what I could ...
1
vote
3answers
135 views
Haskell Poker Hand Kata
Similar to, but distinct from this. I'm working towards solving this kata. The below code doesn't print the result yet, and it reads hand strings rather than game strings.
Take 4:
import Data.String
...
2
votes
1answer
140 views
Optimize some Haskell code
I tried to solve the Unfriendly Number problem on InterviewStreet.
Statement:
There is one friendly number, K, and N unfriendly numbers. We want to find
how many numbers are there which exactly ...