Haskell curly brace parse error

Running Manjaro and trying to get XMonad to work I encountered a parse error on input '{' with the following xmonad.hs: import XMonad import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Util.Run(spawnPipe) import XMonad.Util...
more »

2017-05-20 23:05 (1) Answers

Haskeline history in the wrong order

I'm using Haskeline to make a CLI interface for a program. I use the basic configuration of Haskeline to save the commands stroked in a file. mySettings = defaultSettings { autoAddHistory = True ...
more »

2017-05-20 19:05 (0) Answers

Haskell get directories in directory

How can I get a list of directories that are in a directory? I've come up with the below, but I'm hoping there is a more elegant way: import System.Directory import qualified Filesystem.Path as FsP import Filesystem.Path.CurrentOS import Control.Mo...
more »

2017-05-20 16:05 (2) Answers

Finding long Collatz sequences in Haskell

Today, I am playing with Collatz sequences in Haskell ... Here is my code: collatzLength :: Int -> Integer -> Int collatzLength count 1 = count collatzLength count n = collatzLength (count+1) $ if n `mod` 2 == 0 then n `div` 2 else 3*n+1 mai...
more »

2017-05-20 09:05 (1) Answers

How to nest unboxed vectors?

This may be a pretty basic question, but I've searched around and I cannot seem to find the answer. I would like to represent a 2D list using unboxed Vectors. This is easily done with normal vectors: > import qualified Data.Vector as V > V.fr...
more »

2017-05-20 08:05 (1) Answers

Using custom ghcjs fork with stack

I'm testing some of my own patches to ghcjs, and I was wondering how I can package it up to use with stack's fields, which seem to expect something like: setup-info: ghcjs: source: ghcjs-0.2.1.9007019_ghc-8.0.1: url: http://gh...
more »

2017-05-20 00:05 (1) Answers

Haskell Constructor Type Pattern Matching

I have a simple type and function below, but seems a lot of boilerplate there, so wonder is there a better way to do it. My real question I guess is if I know the input is of type Ability, so any one of the Str/Dex etc, what is the easiest way to ext...
more »

2017-05-19 23:05 (3) Answers

How can I import a module that is in GHCi paths?

I seem unable to import a module when executing ghci directly, however I am able to load the module when executing ghci xmonad.hs. Directory tree: . ├── ghcid.sh ├── lib │   ├── FocusWindow.hs │   ├── MiddleColumn.hs...
more »

2017-05-19 18:05 (1) Answers

generic-sop and lists, Data.Proxy etc

In the spirit of the question I asked here, (Generically) Build Parsers from custom data types? @danidiaz supplied a solution that works beautifully. I'd like to do a little more like this: if f is an instance of a HasParser, a list of f is also an...
more »

2017-05-19 17:05 (1) Answers

Removing inverted duplicates from list of tuples

So basically I have a list of tuples [(a,b)], from which i have to do some filtering. One job is to remove inverted duplicates such that if (a,b) and (b,a) exist in the list, I only take one instance of them. But the list comprehension has not been v...
more »

2017-05-19 10:05 (3) Answers

data declaration - use 3 parameter

i'm going to use the data types now but there is sth what i just know from other programming languages. imagine that "Date" get's (Year Month Day) when i have data Month = Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec data D...
more »

2017-05-18 18:05 (1) Answers

What is wrong with my haskell general tree?

Here is my code and there are so many things wrong about it that i can't see. What is the problem? or what "are" the problems?? I get these errors for several lines: Data constructor not in scope. NBaum Couldn't match expected type [NBaum [Char]]...
more »

2017-05-18 17:05 (1) Answers

Could not find module in nix-shell

What could be the reason for missing module? $ nix-shell -p haskellPackages.ghc -p haskellPackages.random give following shell [nix-shell:~]$ ghci GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /data...
more »

2017-05-18 14:05 (1) Answers

Insufficient definition of replicate

I have a question that I think is rather tricky. The standard prelude contains the function replicate :: Int -> a -> [a] The following might seem like a reasonable definition for it replicate n x = take n [x,x,..] But it is ac...
more »

2017-05-18 12:05 (1) Answers

Using recursion on list of lists

I have a matrix which is a list with nine lists inside it. A visual representation of my matrix is of a sudoku. I need to return the numbers (or elements) in each box (3x3) of the sudoku. For example, the first three rows from this picture would b...
more »

2017-05-18 11:05 (1) Answers

Data.Dependent.Map examples

Are there any examples anywhere of how to use the DMap type? The package documentation is very learned, and I know it if for reference only, but it is singularly unhelpful for one getting started. Google reveals nothing that I can see. ...
more »

2017-05-18 08:05 (0) Answers

runState and do blocks

This is a question more pertaining to do block usage than the state monad. In the following code we can use a do block directly with runState, but only by using flip to reverse the order of arguments so that the initial state to use is given first. ...
more »

2017-05-18 06:05 (2) Answers

Loading of Haskell source file is too slow in vim

After waiting for a while (2 or 3 minutes) to open .hs file in vim, I am getting following errors: Error detected while processing ~/.vim/bundle/haskellmode-vim/ftplugin/haskell_doc.vim: line 111: haskell_doc.vim can't find locaton of html document...
more »

2017-05-17 22:05 (1) Answers

How can i find the depth of an branch in Haskell?

I want to implement a function that gives me the depth of every branch from a tree and pack the integers of the depth in a list. I know how I can find the maximum and the minimum, but I don't know how to find the other ones. My code with an example ...
more »

2017-05-17 20:05 (3) Answers

Getting Access to 'a' in StateT

I'm trying to write a function with StateT only to learn more about it. In f, I'd like to access to the Int in the last type argument of StateT [Int] IO Int: f :: StateT [Int] IO Int f = state $ \xs -> update (error "I want a") xs update :: Int...
more »

2017-05-17 14:05 (1) Answers