referential-transparency Questions

8

Solved

The terms do appear to be defined differently, but I've always thought of one implying the other; I can't think of any case when an expression is referentially transparent but not pure, or vice-ver...

15

Solved

What does the term referential transparency mean? I've heard it described as "it means you can replace equals with equals" but this seems like an inadequate explanation.

4

Solved

Since side-effects break referential transparency, don't they go against the point of functional languages?
Generalship asked 3/10, 2010 at 15:31

8

Solved

After touching on Monads in respect to functional programming, does the feature actually make a language pure, or is it just another "get out of jail free card" for reasoning of computer systems in...

1

Solved

I'm trying to work out how move semantics affect referential transparency. Referential transparency (RT) allows us to replace any expression with its result without changing the meaning of the pro...

1

Solved

I'm looking at cats.effect.concurrent.Deferred and noticed that all pure factory methods inside its companion object return the F[Deferred[F, A]], not just Deferred[F, A] like def apply[F[_], A](i...

8

Solved

Haskell is generally referenced as an example of a purely functional language. How can this be justified given the existence of System.IO.Unsafe.unsafePerformIO ? Edit: I thought with "purely func...

3

Solved

So I'm trying to learn FP and I'm trying to get my head around referential transparency and side effects. I have learned that making all effects explicit in the type system is the only way to gua...

2

Solved

This may border on philosophical, but I thought it would be the right place to ask. Suppose I have a function that creates a list of IDs. These identifiers are only used internally to the applicat...
Imprimis asked 1/8, 2016 at 18:26

4

How can I use pure functions inside IO functions? :-/ For example: I'm reading a file (IO function) and I want to parse its context, a string, by using a pure function with referential transparenc...
Noleta asked 17/2, 2013 at 0:24

1

Solved

Reading "Functional Programming in Scala" and I'm a little confused by the section on exceptions not being referentially transparent. The example given is def failingFn(i: Int): Int = { val y: I...
Snoddy asked 11/3, 2015 at 16:51

1

Solved

I was reading the description of the Scala WartRemover tool, and was confused by one of the points they had. The description said this: return breaks referential transparency. Refactor to termin...
Kinross asked 6/1, 2015 at 14:8

7

Solved

What is the precise promise/guarantee the Haskell language provides with respect to referential transparency? At least the Haskell report does not mention this notion. Consider the expression (7^...
Zapateado asked 19/11, 2014 at 14:56

2

Solved

I'm picking a specific task to illustrate what I was talking about Let's say I wanted to find the sum of all the factors of a large number, naively -- by checking every number below it if it was a...
Gorse asked 25/6, 2013 at 6:11

1

Solved

Say I have a function: f :: Int -> (Rational, Integer) f b = ((toRational b)+1,(toInteger b)+1) I want to abstract away the (+1) like so: f :: Int -> (Rational, Integer) f b = (h (toRatio...

3

Solved

I'm a complete newbie currently trying to learn Haskell with "Learn You a Haskell for Great Good". I've reach the section explaining how to work with command line arguments, and something is buggin...

2

Solved

When looking through the docs of Data.Set, I saw that insertion of an element into the tree is mentioned to be O(log(n)). However, I would intuitively expect it to be O(n*log(n)) (or maybe O(n)?), ...
Oilstone asked 4/1, 2013 at 22:23

9

Solved

I've played around with a few functional programming languages and really enjoy the s-expr syntax used by Lisps (Scheme in particular). I also see the advantages of working in a purely functional ...

3

Let's say we have a program like this : list = [1..10000000] main = print $ sum list I want this to be compiled such that the executable just prints 50000005000000, without taking as much time ...
Streamlined asked 10/4, 2012 at 17:54

6

Solved

putStrLn when called with any arguments will always return a value of type IO (). I agree that's pure, I can handle that. But is it referentially transparent? I think so, because for any given inpu...

2

Solved

Not sure what exactly to google for this question, so I'll post it directly to SO: Variables in Haskell are immutable Pure functions should result in same values for same arguments From these t...

3

Solved

I wrote a function in haskell that takes a few parameters like Word32, String (ignore currying) and outputs IO Word32. Now, this is a function in the true sense: for the same inputs, the output wil...

2

Solved

In other words, can we model many to many relationships in a persistent data structure efficiently? A pair of unidirectional multimaps was suggested. However, I'm not sure how this would work we...

1

Solved

What is the meaning of the term "Non-observable" when used in context with the term "referentially transparent" in functional programming?

2

Solved

I'm surprised I couldn't find an answer to this anywhere. I'm writing a roguelike and I'm using the ncurses library from hackage, which is a pretty good wrapper around the ncurses library. Now ncu...
Reyreyes asked 22/11, 2010 at 7:14

© 2022 - 2025 — McMap. All rights reserved.