51,579 questions
1
vote
0
answers
43
views
Why is this Haskell program throwing a type signature error?
I'm new to Haskell (as you can probably see in my code) and I wanted to make a simple Brainf### interpreter:
import Text.Read (readMaybe)
import Data.Maybe (fromJust)
import Data.List (findIndex)
...
0
votes
0
answers
16
views
Cabal package reading problem when trying to build a project
So i am trying to set up haskell on my macbook (m1) and i need to use cabal for one project. I installed most of what i needed with homebrew.
So when i try to run cabal build in the directory of the ...
3
votes
0
answers
41
views
How to Free Resources Allocated During Debugging in GHC or Stack Debugger?
I'm debugging a Haskell program using GHC's debugger (ghci) or via stack ghci, specifically with the Haskell GHCi Debug Adapter (Phoityne extension) in Visual Studio Code, and I'm encountering a major ...
0
votes
0
answers
64
views
Is there anything like Haskell "guarded equations" in modern C++?
I would like to know if there are equivalent to Haskell guarded equations in Modern C++ (C++20, C++23). Here is an example from Richard Bird's Haskell book where guided equations are used:
combine2 :: ...
0
votes
1
answer
37
views
What part of the type system is getting in the way, when I try to pass IO action via reader monad transformer instead of via function argument?
Look at this answer from an older question about Testing functions in Haskell that do IO.
It proposes, as a solution, to pass IO actions as arguments to a function that doesn't hardcode IO, but just ...
1
vote
0
answers
31
views
How can I unit-test computations that happen in a monadic transformer stack with an IO base layer?
Below is very simplified version of a program I wrote¹, where I have some read-only state (e.g. screen size, etc) made available via ReaderT, and some mutable state (the state of the game) that I ...
1
vote
2
answers
68
views
Indentation of a nested function appears to require at least 5 spaces in haskell
I am trying to learn haskell through the advent of code (I know, it's late in the season), but I am encountering indentation issues I do not understand, despite checking what I believed to be the ...
0
votes
2
answers
82
views
Compute time-to-next-warmest-day in Haskell without using a conversion to-or-from `Data.Map`
Consider the following problem:
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ...
0
votes
0
answers
34
views
Approaches to a `Render` function in functional reactive programming
You have a signal function PointlessButton which inhabits Signal (Maybe Unit) -> ? that represents a button that does nothing, and a rendering function, Render that inhabits ? -> Signal (...
0
votes
0
answers
41
views
Error occured while (re-)installing GHC and setting up the VSCode Haskell Plugin
I was trying to setup the Haskell Plugin for VSCode and I had two seperate problems while trying.
First: The original error I faced while setting up the Haskell Plugin in VSCode was:
HLS does not ...
0
votes
0
answers
34
views
How to exclude field record wildcard imports from ghc -Wmissing-import-lists?
I'd like to get the behavior of -Xmissing-import-lists but exclude record field wildcard imports.
Example: $ ghc -XNoImplicitPrelude -Wmissing-import-lists {a,b,c}.hs
a.hs:
import Prelude (putStrLn, ...
1
vote
0
answers
19
views
How can I suppress the error summary at the bottom of `stack test`
I like to have stack test --file-watch running in a terminal below my editor so when I make a change and save, it reruns my tests and gives feedback. However, in the output below, everything after the ...
4
votes
0
answers
94
views
Is there a way to define `Eq` for this free group implementation (without implementing it twice)?
I have defined a free group type as follows:
{-# Language RankNTypes #-}
{-# Language ConstraintKinds #-}
{-# Language KindSignatures #-}
import Data.Kind
newtype Free (s :: Type -> Constraint) (...
4
votes
1
answer
64
views
Why can't constructors have required type arguments?
Let's say I define the following datatype:
data fmt :* (n :: Nat) where
Rep :: fmt -> fmt :* n
Using RequiredTypeArguments, I can define a function that takes the n parameter as a required ...
0
votes
1
answer
60
views
Are there alternatives to having an idle thread waiting for user input, in gaming?
I've coded a very basic Snake game, and as far as input/output goes, I've taken the following approach:
I create an MVar to store the most recent keypress;
I use withAsync to spawn two threads, both ...