Skip to main content
3 votes
2 answers
64 views

Why doesn't readFile block on unix pipe in which no write has happened yet?

If in a terminal I enter mkfifo /tmp/pipe echo hello > /tmp/pipe (which blocks) and in another I run the haskell program main = readFile "/tmp/foobar" >>= putStr then I see it ...
Enlico's user avatar
  • 30k
-1 votes
0 answers
75 views

add function to it's own closure in a haskell interpreter? [closed]

I am writing a functional language using Haskell, The language of course has functions as a top level deceleration: data Stmt = Function String -- function name. [String] -- Parameter names. ...
buzzbuzz20xx's user avatar
1 vote
1 answer
62 views

What does it mean that the arguments to <*> and their associated effects are known statically?

I'm reading the paper Selective Applicative Functors. So far I've read from page 16 out 29, and I think I've understood the gist of this abstraction, but I'm having some trouble with some basic ...
Enlico's user avatar
  • 30k
1 vote
2 answers
210 views

How can I transform large nested PHP arrays immutably without creating expensive deep copies?

I’m working with large nested associative arrays in PHP and I need to apply transformations (like map, filter, reshape) immutably, meaning the original array should not be modified. The problem is ...
Dharm's user avatar
  • 1
1 vote
0 answers
116 views

How to parametrize a loop body with a function while guaranteeing performance?

Consider the following toy code which performs very simple (a few instructions) operations on a hot loop over a large amount of values: template<float (*f)(float)> void process_f(int count, ...
F.X.'s user avatar
  • 7,445
0 votes
1 answer
52 views

Haskell Parsec Parser giving strange error

I am having trouble getting the following code to work. I got it to work originally, then I changed it so all the Nonterminals also have positions. And I added the method parseLexeme that transforms ...
Jacob Bauer's user avatar
1 vote
1 answer
98 views

How can I avoid declaring full generic parameters when storing a custom typed object, while keeping type safety at compile time?

I've created a small library called StreamX, which acts like a type-safe, index-aware zipper to enable parallel streaming over multiple lists. It supports functional operations like forEach, map, ...
M S's user avatar
  • 19
7 votes
2 answers
181 views

What is wrong with this closed type family in GHC2021-GHC2024 as compared to Haskell2010?

In Haskell in Depth, Chapter 11, there's an example aimed at avoiding character escaping in GHCi, which is what happens automatically when you enter print "ë", as it'll be printed like "...
Enlico's user avatar
  • 30k
0 votes
1 answer
118 views

How Can I Make an Infinite Already Sorted Heap in Haskell?

I start with several containers of things: [1,2,3] fromList [4, 42, 77] Array Vertex [99, 44, 33] -- The specific containers are just examples. It would be nice to not assume -- they are Ord instances,...
James Strieter's user avatar
0 votes
1 answer
79 views

What is a Nothing->Nothing function called in FP?

I am a beginner to functional programming where most of my experience comes from Java/Kotlin. From my understanding functional programming has special names for certain function signatures. Type ->...
liampace's user avatar
0 votes
2 answers
71 views

How to write a fold method for an iterator in a language without mutability?

Suppose you had a programming language in which all variables are immutable. Modifying iterables could be accomplished by providing a magic variable that is immutable during an iteration step, but ...
Armin Repsold's user avatar
0 votes
2 answers
77 views

conditional map fetch efficiently

I have a map which lays down prices of commodities in different currencies val commpricemap: Map[String , Map[String, Double]] = ??? AN example of an entry for gold is as below: ("AU" -> ...
IUnknown's user avatar
  • 9,967
1 vote
1 answer
106 views

How to implement interrupts in pure functional languages [closed]

How would a pure functional programming language with encapsulated effects via monads (e.g. haskell) deal with interrupts? Usually, interrupt handlers modify some global state, but accessing a global ...
Alec You's user avatar
4 votes
1 answer
92 views

Why aren't all instances of Data.Vector.Fixed.Vector also instances of Functor?

For Vec2, Vec3, and others from Data.Vector.Fixed.Boxed, I see a Functor instance, so something like this type-checks: fff :: B.Vec2 Int -> B.Vec2 Int fff = fmap (+1) and fmap is just Data.Vector....
Enlico's user avatar
  • 30k
0 votes
0 answers
51 views

Any way to make this type-aligned sequences constructor infer types properly?

I am in the process of trying to implement Reflection Without Remorse in Typescript, as an exercise, and in the process I'm implementing a bit of a standard library for functional programming. For ...
JSONMagic's user avatar

15 30 50 per page
1
2 3 4 5
1283