Questions tagged [purity]

6 questions
45
votes
3 answers

What is the connection between laziness and purity?

Laziness is what kept Haskell pure. If it had been strict, purity would soon go out the window. I fail to see the connection between the evaluation strategy of a language and its purity. Considering the reputation of the tweet's author I am most…
10
votes
2 answers

Are cuts that bad in programming?

I am taking an AI course this semester in which we are learning Prolog. Our lecturer has told us to try and avoid using cuts in our assignment, however, for a couple of the questions I can't seem to avoid using them. I'm just curious why are cuts…
Achaldo
  • 163
  • 8
1
vote
1 answer

Is there a cleaner way to express many nested map functions in TypeScript?

Given the code below, are there cleaner ways to express many nested map functions in TypeScript? I love the Scala "for-comprehension" for this use-case, but I can't find the equivalent in TypeScript. I feel like I'm missing something pretty obvious…
dbrown428
  • 183
  • 1
  • 12
1
vote
0 answers

Can impurity affect the associativity of an operation?

Associativity is a desirable property and quite common for many operations in FP. Now I was wondering if an impure function can interfere with it. The only example I found isn't really convincing, because I'm not sure if nullary functions count as…
0
votes
1 answer

How would a functional language actually define/translate primitives to hardware?

Let's say I have a few primitives defined, here using javascript: const TRUE = x => y => x; const FALSE = x => y => y; const ZERO = f => a => a; const ONE = f => a => f(a); const TWO = f => a => f(f(a)); If a language is purely function, how would…
David542
  • 104,438
  • 178
  • 489
  • 842
0
votes
1 answer

Can one store a value indexed by a string in the IO monad?

I want to use custom ManagerSettings to build a custom Network.Wreq.Session. I modify from the defaultManagerSettings both managerRawConnection and managerModifyRequest. I want managerModifyRequest to use a configuration value known at runtime from…
fyusuf-a
  • 255
  • 1
  • 9