Haskell is a 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.

learn more… | top users | synonyms

0
votes
0answers
4 views

Is this idiomatic Haskell

This is the most Monadic code I have written to datem and I'd welcome comments. I'm also struck how much faster this mutable approach is than the immutable version I first wrote. It's slowness was ...
0
votes
0answers
20 views

Parsing Markdown with Parsec

Are there better ways to refactor the code? I would like to avoid try. What do you think of the type-annotation-block? ...
4
votes
0answers
36 views

Convert a number to text

This converts a "numerical number" to a text representation. Eg: convert 1234 --> "One Thousand, Two Hundred Thirty Four" I'd like general feedback on how it ...
0
votes
0answers
12 views

Filter by a transformed list, then untransform the result

Both exercises have a common pattern of "filter by a transformed list, then untransform the result". See skip and localMaxima. ...
0
votes
1answer
31 views

Finding Largest Integer Palindrome within a Set

I've "solved" Project Euler Question 4 and I was wondering if I could make my answer more efficient (I'm using Project Euler to help me learn Haskell). The problem reads: Find the largest ...
0
votes
1answer
30 views

Parsing log files in Haskell

I am working through the online materials for CIS 194, a upenn haskell class (not taking the class). This exercise is to parse an error log, and it gives a few function signatures to implement, ending ...
4
votes
1answer
36 views

Create `suffixes` Function on List

I wrote the following suffixes function. Given a list, it returns the list + all sub-lists. suffixes [1,2,3,4] == [[1,2,3,4], [2,3,4], [3,4], [4], []] Please ...
0
votes
0answers
9 views

A small chat server/client

This is my first attempt at a chat server/client setup. It's very simple, and doesn't use any logging, excryption, or validating handshakes. When the server is started, it displays a list of all of ...
2
votes
2answers
52 views

Implementing Function that Maps over Stream

I implemented the following function: the ruler function 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, . . . where the nth element in the stream (assuming the first element ...
2
votes
1answer
302 views

O(n) Fibonacci?

I attempted to write an \$O(N)\$ Fibonacci. ...
2
votes
1answer
54 views

Perfect elimination ordering and high memory usage

The following code calculates a perfect elimination ordering in a special case in Haskell. I am less worried about its correctness than its high use of memory. The following code runs out of memory ...
2
votes
3answers
60 views
3
votes
1answer
61 views

FoldLeft in Terms of FoldRight

I [believe that I] wrote foldl in terms of foldr: ...
2
votes
1answer
25 views

A small module that allows threads to return their result

I have the following that works similar to forkIO, but returns a blocking "channel" that lets you receive the result of a forked IO computation. My main concern is ...
3
votes
2answers
54 views

Project Euler Problem 57 in Haskell

I'm very new to Haskell, and I would like some feedback on my coding style. Is there anything here that could be made more elegant or concise? This is my solution to Project Euler Problem 57. It ...
5
votes
1answer
105 views

Palindrome check in Haskell

I am learning Haskell and I am doing 99 Haskell problems. There is a problem to check if a list if a palindrome. It's obvious solution is ...
3
votes
2answers
42 views

Haskell monad- and error-handling-style

As an answer to excersise 2.3 in Chris Okasaki's book, Purely Functional Data Structures, Inserting an existing element into a binary search tree copies the entire search path even though the ...
2
votes
1answer
30 views

Create Binary, Balanced Tree Attempt #2

Previously, I posted an incorrect implementation of making a binary, balanced tree from a list of a's. Here's my second implementation: ...
0
votes
1answer
27 views

Get Height of Tree

Given the following Abstact Data Type: ...
1
vote
0answers
17 views

Small Map library written in Haskell

I wrote the following Map "library", and would like general feedback. It's my first major use of Binary Trees, so if I'm doing anything dangerous, I'd like to know. Specifically, I "brute-forced" the ...
2
votes
1answer
35 views

Calculate and use a linear equation based on sets of x and y values

The following asks for 2 sets of data (with corresponding x and y values), calculates a linear equation that matches the data as closely as possible, then allows you to "play around" with the equation ...
2
votes
1answer
71 views

Create Binary, Balanced Tree

I wrote a function, which takes a list of Integers, and then makes a balanced binary tree. Please critique it. I'd like to know know how to make it more concise and idiomatic. ...
2
votes
0answers
23 views

Mini Binary Tree “library”

This is my first attempt at learning binary trees. I'm looking for general feedback on how it could be made cleaner, more idiomatic, or more efficient. ...
2
votes
1answer
57 views

Square root calculation with Newton's method

I am currently learning Haskell in parallel of following the Scala course proposed by Coursera. To practice Haskell I try to implement exercices and/or course example from this course. So there is a ...
5
votes
1answer
70 views

Hailstones and the Collatz Conjecture

The Collatz Conjecture is related to a type of problem called a Hailstone problem; because hailstones circulate up and down through a cloud around a planet until they eventually fall. The Collatz ...
1
vote
1answer
34 views

doSkip Function

I wrote a function, doSkip. For an N-sized list, an element at index 0 consists of the entire input. Index 1 consists of every other element, i.e. the odd ...
12
votes
1answer
200 views

Finding Local Maxima

The following function finds all local maxima. A local maxima is an element of a list such that it's greater than either of its neighbor elements. An element with 1 neighbor is not a local maximum. ...
2
votes
0answers
12 views

Is this a design pattern for a Haskell main function? [migrated]

After developing several Haskell applications I've found myself rigorously segregating impure code and failable (partial) functions from their pure & total counterparts. These efforts have ...
4
votes
3answers
235 views

Solution to Hackerrank challenge “Sherlock and Queries”

First, here is the full challenge description: Watson gives to Sherlock an array: \$A_1, A_2, ..., A_N\$. He also gives to Sherlock two other arrays: \$B_1, B_2, ..., B_M\$ and \$C_1, C_2, ..., ...
6
votes
1answer
45 views

Implementing `split`

I implemented the split function in Haskell: ...
3
votes
2answers
67 views

Write a function to extract a given number of randomly selected elements from a list

I'm going through the 99 Haskell problems and I have a few question about the solution I implemented for Problem 23. It asks: Extract a given number of randomly selected elements from a list. ...
5
votes
1answer
150 views

A simple version of Conway's Game of Life using ASCII art

I'd like a general review of my version of Conway's Game of Life. Right now, it's very simple, and doesn't lead to anything interesting yet, as the "seed" generation is randomly generated and small; ...
2
votes
0answers
47 views

Existential Types and IO

In my attempts to grasp Existential Types in Haskell I decided to implement an integer-based fixed-length vector data type. I'm using ghc 7.8.3. Specifically I wanted to write a program which asks ...
0
votes
0answers
32 views

Readability of a point-free applicative parser

I am writing an applicative parser, which you can think of as a minimal Parsec, just to educate myself. I got started with the excellent tutorial from this StackOverflow answer. Here is the relevant ...
1
vote
1answer
18 views

splitWith function for splitting a list doesn't seem optimal

As an exercise from RWH, I needed to write a function that splits a list every time the predicate is false (words == ...
1
vote
1answer
22 views

Find Element in Tree Given a List of Directions

Looking at Learn You a Haskell, I implemented a function that, given a binary tree, i.e. left and right branches, give a list of Directions and give the element at ...
3
votes
0answers
28 views

Splitting and Joining Machines

A small program I use as my "hello world" of streaming libraries is the following: For each line of stdin Interpret the line as a file-name If the file ...
4
votes
1answer
45 views

Simulating the martingale betting system with roulette

I wrote a program that simulates many instances of trying the martingale betting system with roulette in Haskell. At the answerer's suggestion I opted to leave the ...
3
votes
1answer
44 views

Count frequency of characters in a file

Some patterns are emerging ("fmap (b->a) . fmap (c->b) . .. . (IO z)"). Also infix zip is kind-of a hack. What is: Best practice in point-free style? Best ...
2
votes
0answers
26 views

Abstract Key Value Store

I'm attempting to define an abstract interface for a key value store. Some requirements: Once a key has been written it should never be overwritten (although it may be deleted Transactions with ...
4
votes
2answers
43 views

First multi-line Haskell program, extensive use of Maybe type

I'm reading through Write Yourself a Scheme after finishing going through Learn You a Haskell. I attempted one of the early exercises: writing a program to get an operator and two numbers and do a ...
3
votes
1answer
21 views

Update only specific field of specific item (data) in List from YAML

I don't like the logic to update [Repository] list here because I need to map whole list to change only specific field of specific node, I especially don't like ...
4
votes
1answer
55 views

Writing a faster mutable trie

I am implementing a mutable trie. I tested and it produces correct results. However, it is very slow. I benchmark it against plain old Data.Map, which is more than ...
4
votes
1answer
43 views

Safe Reverse Polish Notation

I implemented the following (what I believe to be) safe Reverse Polish Calculator. Now I'm using foldM to take advantage of the power of Monads. Previously, I was ...
2
votes
2answers
41 views

Safely getting the next element of a list

I'm looking for general review and improvements on this code that safely gets the next element of a list (and wraps to the first element if you exceed the list). It just seems a little excessive for ...
3
votes
1answer
37 views

Implementing “Pierre the Tight-rope” Walker from LYAH

Learn You a Haskell presents an excellent introduction to >>= with an example. Basically, Pierre is a tight-rope walker ...
3
votes
1answer
50 views

How can I make this Euler/RK4 implementation more elegant?

One of the things that I'm doing to teach myself is converting some numerical methods from existing Python code (they seem to me to lend themselves to functional programming quite well). I'd like to ...
4
votes
1answer
58 views

A simple database

After failing miserably to get SQL to work with Haskell, I decided to try making my own system. It's fairly simple, but works well for simple jobs (I made it to handle highscores for a number guessing ...
3
votes
1answer
93 views

Random Schedule Generator

In an attempt to try something new, and possibly help out at work, I tried creating a random schedule generator that generates schedules based on 3 inputs (Rotation length, Staff list, and Shift ...
4
votes
1answer
52 views

Using quickCheck for “99 Haskell problems” - problem 1

I'm working on learning Haskell, and I've implemented a solution to the first of the 99 Haskell problems. Here is my code: ...