Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [haskell]

Haskell is a purely functional programming language featuring strong static typing, lazy evaluation, extensive parallelism and concurrency support, and unique abstraction capabilities.

haskell
1 vote
0 answers
51 views

Constructor classes: why not mention the content's type?

Following on from this q about monad transformers ... Before constructor classes were introduced [M.P.Jones 1993], Haskell class decls: Must have a single parameter; That parameter must be kind Type (...
AntC's user avatar
  • 2,796
0 votes
1 answer
42 views

If we bind two parsers and the second parser fails, does the string get parsed once?

So suppose this is a parser: data Parser a = MkParser (String -> Maybe (String, a)) runParser :: Parser a -> String -> Maybe a runParser (MkParser sf) inp = case sf inp of ...
user20102550's user avatar
1 vote
1 answer
40 views

How to parse CFG with operators

Ok so I have this parser and data: module SO where import Data.Char import Prelude hiding (fmap, (>>=), (*>), (<*), pure) data Parser a = MkParser (String -> Maybe (String, a)) data ...
user20102550's user avatar
2 votes
3 answers
80 views

Haskell list sum generalization

I was working in Python and created an example of how we can generalize the usual sumList function to sum any arbitrary list of lists: To sum any list of numbers in Python we can write: def sumList(...
Agustin Bustos Barton's user avatar
3 votes
1 answer
49 views

How to properly step through recursive parsing?

The code I have is this: -- my parser, takes a function that takes a string and gives -- the suffix and the answer data Parser a = MkParser (String -> Maybe (String, a)) unParser :: Parser a ->...
user20102550's user avatar
0 votes
1 answer
52 views

Cabal upload package fails with Encountered missing or private dependency

I'm trying to upload my first Haskell package: $ git clone https://github.com/OrenGitHub/dhscanner.ast.git 2>/dev/null $ cd dhscanner.ast/ $ cabal --version cabal-install version 3.10.1.0 # <--- ...
OrenIshShalom's user avatar
1 vote
1 answer
48 views

How do I extract this text from an xml file in Haskell

I have an xml file in a similar format to this. There are multiple parent tags: <file> <parent title = "counting"> <child> <notme></notme> <me>One <...
CodeWash's user avatar
  • 185
7 votes
1 answer
85 views

Extending types in a backward compatible way?

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 ...
Clinton's user avatar
  • 23k
3 votes
1 answer
66 views

Where is the inner m quantified over?

@pash writes: there's really no such thing as an "unquantified" type signature in Haskell. Here's a program: {-# LANGUAGE Haskell98, ScopedTypeVariables, InstanceSigs #-} module Identity ...
Janus Troelsen's user avatar
0 votes
0 answers
36 views

How to protect against XSS attacks in Servant Framework?

I have an S2S API which takes in user input and some of that input later gets sent to the frontend. If the user data contains any html like <script> tags, I want to throw a Bad Request 400 ...
DarkHorse1997's user avatar
0 votes
1 answer
26 views

How to use custom HTML attributes with Blaze in Haskell

I'm trying to write the following HTML element from Bootstrap in blaze-html in Haskell. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-...
Adam D's user avatar
  • 2,117
4 votes
2 answers
56 views

What does it mean in Haskell when a function doesn't handle every constructor of a data type?

Consider data Pair = Pair (Headers, Builder) | CompoundPair (Headers, [Pair]) showBoundPart :: Boundary -> Pair -> Builder showBoundPart (Boundary b) (Pair (headers, content)) = ...
user1713450's user avatar
  • 1,409
3 votes
1 answer
52 views

Why does GHC's type-checker accept this UndecidableInstance trick?

GHC accepts the following code. {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} class Blib b where blib :: b class Blob b where blob :: b instance Blib b => Blob b ...
141592653's user avatar
  • 689
0 votes
0 answers
69 views

How to run an inner "ServerT" with different context to the outer "ServerT"

We are writing custom servant combinators to handle various authorisation layers in our application. E.g. if you had a task management system, you might have an outermost scope where no authentication ...
GTF's user avatar
  • 8,285
2 votes
1 answer
63 views

What's the difference between placing a parser in its "box" vs using it without it? [duplicate]

So this is my parser, and two functions to run a parser: data Parser a = MkParser (String -> Maybe (String, a)) unParser :: Parser a -> String -> Maybe (String, a) unParser (MkParser a) inp =...
user20102550's user avatar

15 30 50 per page
1
2 3 4 5
3428