Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 02 23:58
    @SethTisue banned @fakubishes:nerdsin.space
  • Dec 15 2021 05:01
    som-snytt commented #12516
  • Dec 15 2021 04:38
    SethTisue edited #1312
  • Dec 15 2021 04:38
    SethTisue opened #2273
  • Dec 15 2021 04:31
    jackkoenig opened #12516
  • Dec 15 2021 04:29
    SethTisue edited #1312
  • Dec 15 2021 04:28
    SethTisue edited #1312
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    scala-jenkins milestoned #9831
  • Dec 15 2021 04:27
    SethTisue labeled #9831
  • Dec 15 2021 04:27
    SethTisue opened #9831
  • Dec 15 2021 03:35
    som-snytt commented #11339
  • Dec 15 2021 03:27
    som-snytt labeled #12494
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:07
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 03:05
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue edited #1312
  • Dec 15 2021 02:58
    SethTisue synchronize #1312
Martijn Hoekstra
@martijnhoekstra
If "manual (e.g. passing constructor parameters)" is given as an option on what DI you use, I think it should be obvious that it's not limited to magic frameworks in this context
Fabio Labella
@SystemFw
I agree :)
the question of whether this should be called DI or not is probably a separate conversation
Dominic Egger
@GrafBlutwurst
code that actually does anything is impure and evil :D
Martijn Hoekstra
@martijnhoekstra
fun fact: code doesn't actually do anything at all
Josh
@joshlemer
code doesn't do side effects, people do side effects
Martijn Hoekstra
@martijnhoekstra
CPUs may do stuff with code that a compiler generated from the code you wrote, but if that's "close enough" to the code doing things, then I'd argue pure effects in an IOApp runtime is "close enough" as well
PsyfireX
@PsyfireX
The CPU was just following orders.
vijendra singh
@viju0731_twitter
image.png
value current is not a member of object java.sql.SQLException
not found: value JDBCConnectionException
Getting this error any help
PsyfireX
@PsyfireX
Could you copy a larger code-snippet?
Harrison Houghton
@hrhino
also, that's Java...
Josh
@joshlemer

Also I feel like it's so easy to "sneak in" mutability, if that makes sense. For example:

Seq[(String, Int)](
  "x" -> 1,
  "y" -> 2,
  "z" -> 3,
  "x" -> 2
).foldLeft(Map.empty[String, Int])(_ + _)

In a sense, we're reassigning a value to "x" here, right?

Harrison Houghton
@hrhino
... no? not any more than using updated on a map
Josh
@joshlemer
If you kinda squint at it and pretend that each line is binding to a variable then it's as if we have invented var out of purely functional constructs
PsyfireX
@PsyfireX
I don't get it, how are you assigning anything to "x"
"x" isn't mutable, nor is "x".->(2)
Martijn Hoekstra
@martijnhoekstra
@joshlemer sure, if you consider a Map[String, Int] as the runtime of your programming environment, with the strings as identifiers, updating values in that map can be seen as mutating values pointed to by identifiers
Josh
@joshlemer
Exactly @martijnhoekstra gets it
Martijn Hoekstra
@martijnhoekstra
but that's not scala, that's the Map[String, Int] language
Josh
@joshlemer
so if you aren't careful, mutability can "foam up" from beneath you
or rather, emerge would be the verb
Fabio Labella
@SystemFw
mutability is not a problem, lack of referential transparency is
also, that Map is a common technique to implement environments for closures when doing e.g. an interpreter :)
Josh
@joshlemer
a more flushed out example
sealed trait AssignmentTo 
case class Constant(c: Int) extends AssignmentTo
case class Variable(varName: String) extends AssignmentTo


Seq[(String, AssignmentTo)](
  "x" -> Constant(1),
  "y" -> Constant(2),
  "z" -> Constant(3),

  "uhoh" -> Variable("x"),

  "x" -> Constant(1),

  "uhoh" -> Variable("x")

).foldLeft(Map.empty[String, Int]) { case (acc, (ident, assign)) =>
  val newValue = assign match { 
    case Constant(c) => c
    case Variable(varName) => acc(varName)
  }
  acc + ((ident, newValue))
}
Martijn Hoekstra
@martijnhoekstra
The mutability there is in the interpreted language of AssignmentTo, not in scala
Josh
@joshlemer
like, aside from throwing exceptions, this is as pure as it gets.Yet, it is starting to look a lot like imperative programming
PsyfireX
@PsyfireX
I don't see the mutability
It seems like you're trying to prove a point by starting with "squint very hard"
Amit Prasad
@amitprasad01_twitter
Hi Guys
anyone familiar here of scalamock
?
Josh
@joshlemer
here we've invented a little world/language/abstraction where identifier can be mutably updated using only purely functional constructs
Amit Prasad
@amitprasad01_twitter
need some urgent help
Josh
@joshlemer
"x" can be assigned values, it can be read and assigned to other values, updated. It's a var
Pierre Marais
@Deeds67
@joshlemer Do you see recursion as mutation then as well?
Josh
@joshlemer
I'm not saying I have any answers or rules, just pointing out that purity maybe is less black and white than it seems?
PsyfireX
@PsyfireX
No, that's not what's happening.
"if you squint really hard 98 + 1 = 100"
Josh
@joshlemer
Unless there's like really a rule for why this is not to be breaking referential transparency
PsyfireX
@PsyfireX
^ that is an incorrect statement relying on ignoring logic/facts in favor of fuzzy logic
Josh
@joshlemer
@PsyfireX I'd like to hear why this is wrong if you wouldn't mind elaborating
PsyfireX
@PsyfireX
What is being mutated in your example?
Josh
@joshlemer
@amitprasad01_twitter I'm not familiar but if you pose specific questions maybe someone will know
@PsyfireX the binding of "x" to 1
Martijn Hoekstra
@martijnhoekstra
@joshlemer I see your exmple, but what you did was show that you can interpret an impure language in a pure interpreter. Just because you can use pure programming to write an interpreter to interpret an impure program doesn't make the interpreter impure.
PsyfireX
@PsyfireX
The binding is never mutated