haskell Questions
2
Solved
I used the default stack new to setup a project that has a server and a client as separate executables. I altered the package.yaml file in what seems like the right way (As of April 21, 2020 "There...
Logrolling asked 23/4, 2020 at 1:14
1
Solved
Recently I've been trying to understand what, exactly, is forced by GHC upon the evaluation of seq. Suppose I save the below definitions:
f :: Int -> [Int] -> [Int]
f = \n -> \ns -> if ...
Sherrell asked 18/9, 2024 at 19:41
2
Is there a way to limit ghc's memory usage during compilation, without compromising code quality? I am on a 2GB machine, and it literally halts during builds. GHC version 7.10.3, Ubuntu 14.04, 4GB ...
1
Solved
In ghci:
Data.Semigroup> 0.1 :: Sum Double
<interactive>:2:1: error: [GHC-39999]
• No instance for ‘Fractional (Sum Double)’
arising from the literal ‘0.1’
• In the expression: 0.1 :: S...
Niigata asked 7/9, 2024 at 17:45
1
Solved
Consider the following GADT, Pin:
{-# LANGUAGE GADTs, KindSignatures, DataKinds #-}
module Mcu where
import Data.Kind (Type)
import GHC.Num.Natural (Natural)
data Pin :: Natural -> Type where...
Borghese asked 24/8, 2024 at 21:3
3
Solved
Is it possible to use CPP extension on Haskell code which contains multiline string literals? Are there other conditional compilation techniques for Haskell?
For example, let's take this code:
--...
Monochrome asked 30/3, 2010 at 22:26
1
Solved
I tend to stick to "recommended" versions:
┌──────────────────────────────────GHCup──────────────────────────────────┐
│ Tool Version Tags Notes │
│───────────────────────────────────────...
6
Solved
How can I zip two lists like
["Line1","Line2","Line3"]
["Line4","Line5"]
without discarding rest elements in first list?
I'd like to zip extra elements with empty list, if it can be done.
Uitlander asked 14/3, 2014 at 10:54
2
Solved
I don’t quite understand how functions behave when working with applicative functors.
Here's an example:
ghci> (&&) <$> Just False <*> undefined
*** Exception: Prelude.undefi...
Hermaphroditism asked 30/7, 2024 at 12:8
3
Solved
Say I have a list like:
[Nothing, Just 1, Nothing, Just 2]
I want to get the first Just (non-error) value; in this case, it's Just 1. The only thing I can think of is:
firstJust xs = case filte...
Dinnie asked 4/4, 2016 at 19:13
0
Some time ago I worked on this project, and I experimented a bit with package candidates.
Then, yesterday, I uploaded the real package on hackage. However, it fails to build. I think the reason is ...
2
Solved
I am testing out some of the ideas in this article.
I want to derive an instance of Eq for the type Term:
{-# LANGUAGE DeriveFunctor #-}
data Tree a = Branch Int [a] | Leaf Int deriving (Eq, Func...
Hash asked 15/8, 2016 at 16:19
1
Let's say I have:
data X = X Int Char Whatever
Now let's say I want to add a type parameter to X like so:
data Version = OldVersion | NewVersion
data X (phantomParam :: Version) = X Int Char What...
Glade asked 22/7, 2024 at 3:28
2
Solved
In our project we have a lot of TH-generated functions. It'd make sense to add generic comments to them so that they are visible in Haddock/Hoogle. At the very least, something like "This has been ...
Cisco asked 9/9, 2014 at 13:59
13
Solved
In Haskell, how can I generate Fibonacci numbers based on the property that the nth Fibonacci number is equal to the (n-2)th Fibonacci number plus the (n-1)th Fibonacci number?
I've seen this:
fi...
1
Solved
I'm new to Haskell and learning about Monad Transformer. I found that lift can be omitted when operating on an inner monad in a monad stack. For example:
type Foo = ReaderT String (WriterT String I...
9
Solved
I'm new to Haskell.
How to generate a list of lists which contains prime factors of next integers?
Currently, I only know how to generate prime numbers:
primes = map head $ iterate (\(x:xs) ->...
Hangup asked 22/1, 2014 at 7:35
0
At this point in my learning journey, I simply accepted that this function is called pure (both in Haskell and in PureScript), but it would have helped a lot if I had known the reasoning behind thi...
Photocomposition asked 1/6, 2024 at 12:6
3
Solved
iterate :: (a -> a) -> a -> [a]
(As you probably know) iterate is a function that takes a function and starting value. Then it applies the function to the starting value, then it applies...
Grille asked 22/9, 2010 at 13:34
5
I've defined a typeclass similar to an interface with a bunch of functions required for my program. Sadly, it needs multiple polymorphic types, but not every function of this multi-parameter typecl...
Plural asked 1/6, 2014 at 19:3
4
When I type the following in the interactive shell of Haskell on the repl.it website, it works perfectly.
let squareMe x = x * x
let myFruit = ["banana", "apple", "kiwi", "orange"]
But when I ty...
Swane asked 3/10, 2017 at 14:37
8
I am new to Haskell. Previously I have programmed in Python and Java. When I am debugging some code I have a habit of littering it with print statements in the middle of code. However doing so in H...
2
Solved
Update: I just found this documentation page. Wish there was a link to it from the documentation that I'd been using, which seemed to be the definitive API doc. But maybe it's a new, unreleased wor...
Because asked 9/9, 2010 at 19:5
3
Solved
I'm trying to get a sense of the relationship between view patterns and pattern guards in GHC. Pattern guards seem quite intuitive, while view patterns seem a bit confusing. It kind of looks like v...
Potty asked 24/12, 2013 at 21:17
2
Solved
I experimented with the closureSize# primitive in GHC. Here I define the helper function I use (x is forced using a bang pattern, so what I am measuring should be the data constructor closures them...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.