Category "haskell"

Applicative instance trying to use monoidal functors

I'm learning Haskell and trying to do exercises from book Haskell Programming from first principles and I'm stack trying to write applicative for Pair type da

Is there a way to tell stack that I want to use an older resolver by default?

How would I configure stack to use an older resolver by default? I know the resolver can be specified on the command line at build time and per project in the

What does " Non type-variable argument in the constraint" really mean?

For example: map (+1) 2 in ghci yields <interactive>:23:1: error: * Non type-variable argument in the constraint: Num [b] (Use FlexibleContexts to

random number generator function returns a nested tuple in haskell

I am trying to understand why my haskell function returns a nested tuple, and I cannot seem to wrap my head around the problem. I have this function that genera

Type signature for function with possibly polymorphic arguments

Can I, and if so, how do I, write the type signature for a function: g f x y = (f x, f y) Such that given: f1 :: a -> [a] f1 x = [x] x1 :: Int x1 = 42

Haskell Stack install package dependency from github

Is it possible to install a version of a package from github using Haskell stack? e.g. in a .cabal or a stack.yaml file, how can I point a dependency at a git

How to compute the symmetric difference of two lists using list comprehension?

To get the symmetric difference of two lists I think it would be a good idea to use list comprehension. But I don't know what I could do to remove the common el

Issues with QuickCheck involving a data type with a function as a constructor

wrote the code below and am getting some issues with it : The error I am getting is : Data constructor not in scope: Int :: Int If I eradicate the Numeric I

How do I run the tests that are part of an installed/installing Cabal package?

I have a Haskell package I've installed from Hackage, using cabal and would like to run the tests suites that are part of the package, but it isn't clear to me

Computational Complexity of Higher Order Functions?

Map and filter seem like they would be linear O(n) because they only have to traverse a list once, but is their complexity affected by the function being passed

Is there a cleaner way of converting an Either to an ExceptT?

I have some functions which return Either values and I'd like to use them in an IO do block with what I think is called "short circuit" behaviour so that any Le

Getting 'a' value from 'Maybe a' return type in Haskell

I have a Haskell function eval :: WExp -> Memory -> WValue with a bunch of different instances of itself for different cases. For now, knowledge about WEx

Haskell: Continue program execution

I am very new to Haskell. My question might be very basic for you. Here I go- I am writing a program to create a series of numbers using a specific mathematica

Writing Algebraic Data Type in Scala

In Haskell, I can define a Tree: data Tree a = Empty | Node a (Tree a) (Tree a) How could I write this in Scala? I'm not sure how to keep the type paramete

How does an instance of "Arbitrary" looks for a tree?

In our CS-Lectures we currently learn about QuickCheck in Haskell. Now I got a task to use QuickCheck with the following tree-type: data Tree = Leaf Int | Node

What exactly does "effectful" mean

Time and again I read the term effectful, but I am still unable to give a clear definition of what it means. I assume the correct context is effectful computati

Haskell Monoid Instance Question for a newtype

I am trying to define an instance: newtype Join a = Join { getJoin :: a -> Bool } deriving Generic instance Monoid (Join a) where f <> g = ???

Understanding the Reader monad

I'm reading PureScript by Example and got to the part introducing the Reader monad. The example goes like this: createUser :: Reader Permissions (Maybe User) c

New state of the art in unlimited generation of Hamming sequence

(this is exciting!) I know, the subject matter is well known. The state of the art (in Haskell as well as other languages) for efficient generation of unbounded

Is implementing the words function possible without a postprocessing step after folding?

Real World Haskell, chapter 4, page 98 of the print asks if words can be implemented using folds, and this is my question too: Is it possible? If not, why? If i