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

1
vote
0answers
8 views

Shell prompt colorizer with Git support

My type system here feels clunky, and I suspect this may be a problem with the overall architecture. The gist of the software is that it stylizes the shell prompt (in the example, just Zsh, but could ...
5
votes
1answer
84 views

Brainfuck interpreter in Haskell

Okay, so I just started learning Haskell around a week ago and this is my first real program that I worked on all of yesterday with a lot of help from IRC. I know that using indicies and arrays is not ...
2
votes
1answer
29 views

How many guards/patterns is too many?

I'm working one of the recommended tutorials -- actually, the UPenn online course CS194 -- for learning Haskell, and I have a working solution to the final "challenge exercise" for HW 2. But it seems ...
2
votes
2answers
195 views

Gather first letter from each string in a list of strings

I'm learning Haskell on my own, and I'm wondering if this is idiomatic Haskell. In particular: is it a common pattern to "wrap" the result in a list in order to make a function total? (that's what I ...
1
vote
1answer
26 views

insertBST exercise

I'm just learning Haskell on my own, and did an exercise to implement insertBST. Is this idiomatic Haskell? ...
0
votes
0answers
14 views

Haskell Pure Fixed Length Queue

I am modeling an infectious disease with an fixed incubation period. I choose a queue to keep track of when people will become symptomatic. I imagined using some operations like so: ...
3
votes
0answers
18 views

Random numbers, IO monad, and pure code

To get used to Haskell, I wrote a little program using the Diagrams package which generates 100 random dots (larger dots are more likely to be in the center). ...
1
vote
2answers
40 views

Formatting a list of strings as a comma-separated string

I'm learning Haskell on my own and I'm following the material of a course. I would like to know if this is idiomatic Haskell. ...
1
vote
1answer
18 views

Assorted Date Parser

I've written a date parser that parses different types of dates using Parsec. Credit for the original problem goes to here. The following formats are as such: ...
1
vote
0answers
23 views

Expressing computations on values as State

I was writing an application with a few Monads in a transformer stack. The top level application state resides in a TVar, and various components of the application ...
0
votes
0answers
24 views

Implementing Functor Instance for `ITree`

Looking at this Typeclassopedia exercise, I typed out foldTree on the following type: ...
-2
votes
1answer
52 views

Creating new types that facilitate safety, flexibility, and DRY-ness [on hold]

Disclaimer: I realize that a lot of my trouble has to do with how I'm grounded in the OO way of thinking. If you can point out exactly how I'm trying to force OO thought on Haskell, I would be very ...
3
votes
1answer
38 views

Function to get NGrams fast in Haskell

Is this a good way to get all sublists of a sequence/list that have a given length? An inefficient way to do it would be something like ...
2
votes
1answer
34 views

Folding over a Rose Tree : Tree a -> [a]

I posted this question on StackOverflow. Given this algebraic data type: data Tree a = Node { rootLabel :: a, subForest :: [Tree a] } deriving (Show) ...
1
vote
0answers
16 views

Implementing `concat` using `foldTree` on Rose Tree

I attempted (incorrectly) to implement foldTree here. Recently, I updated it per Petr's help: ...
4
votes
1answer
46 views

Implement `fold` on a “Rose Tree”

Given the following algebraic data type, a Rose Tree: data Tree a = Node { rootLabel :: a, subForest :: [Tree a] } I attempted a ...
0
votes
0answers
13 views

Implementing `dropJ` on JoinList Attempt #2

Initially, I implemented dropJ in this post. However, abuzittin-gillifirca found a bug in my program. So, I re-implemented it in the following way: ...
2
votes
1answer
28 views

Optimize calculation of string self-similarly with its suffixes

I am trying to solve a Hacker Rank problem about string suffixes: For two strings A and B, we define the similarity of the strings to be the length of the longest prefix common to both strings. ...
2
votes
0answers
13 views

URL fetcher and parser for XML feeds

Here is a program that will parse and print XML feed URLs. I want to reuse most of it to add post date to each link. This adds a new concern of CLI and output formatting on top of parsing and (poor) ...
2
votes
0answers
46 views

Haskell program to turn off computer

This a program I wrote to execute various power-related function on my computer. It accepts one command-line argument that describes what action to take and then performs that action. Usage looks like ...
5
votes
1answer
55 views

Simple evaluator of Scheme-like expressions in Haskell

This is my first nontrivial Haskell program: ...
10
votes
1answer
80 views

DFA and NFA in Haskell

I've written a determinstic & non-deterministic finite state machine. I've scrubbed the code quite a bit but I wonder if it could perhaps be scrubbed even more. Suggestions for code clarity, ...
2
votes
0answers
19 views

Implementing `dropJ` to Drop `JoinList` Elements

In the same vein as the (+++) function on JoinList and indexJ on JoinList, I implemented dropJ to drop elements from a JoinList. Here's my attempt: ...
3
votes
0answers
14 views

Searching a Join List for an index Attempt #2

Originally I posted this incorrect attempt - Searching a Join List for an index. Given a JoinList: ...
3
votes
0answers
47 views

Novice implementation of TicTacToe in Haskell

I want to learn Haskell and figured the best way to do it is to write a simple TicTacToe implementation. However the result feels very inelegant and I think it might be the best playground for your ...
2
votes
0answers
19 views

2D Convex hull exercise

I'm reading Real World Haskell, and this is my first try with the language. This is the result of the exercises of chapter 3: Consider three two-dimensional points a, b, and c. If we look at ...
4
votes
1answer
39 views

Copying files in Haskell

I recently watched a video in which the speaker said that Haskell is not suited for real-world tasks, such as copying files from one folder to another. So I tried to write a program that copies a ...
0
votes
1answer
25 views

Searching a Join List for an index

For the Join List algebraic data type: ...
1
vote
2answers
28 views

Implementing (+++) to Join JoinList's

Related to this question, I wrote the (+++) function to join 2 JoinList's: ...
5
votes
1answer
43 views

Retrieve annotation from a tree annotated with a Monoid

Working on this homework from 2013 for self-learning. For the following Algebraic Data Type: ...
6
votes
0answers
45 views

(Yet Another) Conway's Game of Life in Haskell (Naive)

I code Haskell as a hobbyist. I'm interested in feedback on my naive implementation of Conway's Game of Life. Specifically, as stated in the Quick Tour of the website, I am interested in: Best ...
7
votes
1answer
124 views

TicTacToe in Haskell

Are there any ways which I could improve and simplify this code? Is my code idiomatic Haskell? Is the use of a lens library to change an element of a two-dimensional array unnecessary? If so, how ...
1
vote
0answers
27 views

Extract logic applied in a sequence of integers

I've done it in C# before but thought that a functional language would be a good fit for this kind of thing. From this ascending list of integers: [100,103,106,112,118,121] I had to calculate ...
1
vote
2answers
53 views

Monoid Instance for `a -> b` [closed]

I attempted to implement a Monoid' instance for a function a -> b. ...
3
votes
2answers
39 views

Implementing Division of Streams (where it's a stream of polynomial coefficients)

Per this homework, I'm trying to implement a Fractional (Stream Integer) where the stream represents coefficients of polynomials: where Q is defined as Q = ...
1
vote
0answers
42 views

Quick Sort: Mutable or ST Array

This is the most Monadic code I have written to date :-) and I'd welcome comments. I'm also struck how much faster this mutable approach is than the immutable version I first wrote (see end). OK, so ...
0
votes
0answers
35 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? ...
6
votes
0answers
64 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 ...
1
vote
0answers
18 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
37 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
38 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
51 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
24 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
60 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
309 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
90 views
3
votes
1answer
70 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
60 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 ...