Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 18:49
    neko-kai edited #9614
  • 04:15
    SethTisue edited #1405
  • 04:15

    SethTisue on 2.12.x

    2.12: new Scala SHA (#1405) (compare)

  • 04:15
    SethTisue closed #1405
  • 02:05
    scala-jenkins milestoned #9618
  • 02:05
    eltociear opened #9618
  • May 07 21:50
    neko-kai commented #9605
  • May 07 21:49
    neko-kai commented #9614
  • May 07 18:00
    smarter commented #9605
  • May 07 17:57
    neko-kai commented #9605
  • May 07 17:56
    neko-kai commented #9605
  • May 07 17:56
    neko-kai commented #9605
  • May 07 17:56
    neko-kai commented #9605
  • May 07 17:50
    smarter commented #9605
  • May 07 17:47
    neko-kai commented #9605
  • May 07 17:47
    neko-kai commented #9605
  • May 07 17:46
    neko-kai commented #9605
  • May 07 17:41
    smarter commented #9605
  • May 07 17:41
    smarter commented #9605
  • May 07 17:30
    SethTisue labeled #12391
Otto Chrons
@ochrons
@lysium check out @tpolecat's presentation on the topic https://www.youtube.com/watch?v=po3wmq4S15A
Martijn Hoekstra
@martijnhoekstra
it only makes sense to talk about effects IMO, if you can say something like "somesuch is an effect, and therefore foo"
as soon as you have to debate that, that statement becomes just, like, your opinion, man
Otto Chrons
@ochrons
@lysium jump to around 25mins for the discussion on F[A] vs A
trepidacious
@trepidacious
The word "effect" has always confused me in any description of FP, I only have a kind of mental model of the type of thing that might be going on when someone says effect, it definitely makes any sentence in it less informative to me :) But that's probably just me
Martijn Hoekstra
@martijnhoekstra
no, it's not @trepidacious
trepidacious
@trepidacious
I've never seen anyone define it in any concrete way (not just giving examples or hand waving, but actually defining it like a functor or a monad)
Martijn Hoekstra
@martijnhoekstra
I struggled with this for the longest time, and asked around for quite a while what an "effect" really is, without getting into things that are, like, someones opinion, man
Smart people weren't able to give me an answer that extended beyond some F[A]
Otto Chrons
@ochrons
Opinion[A] is that an effect? :stuck_out_tongue_winking_eye:
Martijn Hoekstra
@martijnhoekstra
so that's what I'm going with
only if you make a binding for it @ochrons: val myOpinion = Opinion(None)
trepidacious
@trepidacious
There is an "Effect" in cats I think, is that relevant?
Martijn Hoekstra
@martijnhoekstra
yes, there is
which makes things all the more confusing
Otto Chrons
@ochrons
it's more like side-effect
Fabio Labella
@SystemFw
in FP we use effect and side-effect to mean different things
the key thing is that side-effect has a very precise definition
effect does not, it's just a convenient term
basically used to refer to an F[_]

I would not consider Option/Either an effect. Sometimes Either is used where non-FP people would throw an exception (which would be an effect), but that's the closest connection I can see. At the moment, I have a hard time to define 'effect', but I'd describe it as changes that were not part of your functions' arguments or return values, such as the contents of the stdin buffer, some observable memory location, or the continuation of the function call.

you are talking about side-effects here, which has a precise definition: something that breaks referential transparency

Martijn Hoekstra
@martijnhoekstra
I think (but I'm not sure) Effect[F[_]] in cats effect could have the more precise (but less convenient) name SideEffectSuspensionStrategyProvider
as soon as you name it that though, you really need to make a SideEffectSuspensStrategyProviderFactoryBeanjust as a sort of Pavlov reaction
(queue vehement disagreement from Fabio)
Fabio Labella
@SystemFw
:P
lysium
@lysium
@SystemFw Thank you for clarifying! You're completely right!
@ochrons Thank you for the video! I love the phrase "F[A]: This is a program in F that computes a value of type A." I think it accurately describes what we think of F[A]: we are actually interested in computing A, but we use the stuff fromF to do that. Now I think I better understand the phrase "F[A] is an effect on A".
Martijn Hoekstra
@martijnhoekstra
Of course, "a program in F" is still a bit wishy-washy
at some point, you run out of analogies though, and things are just what they are
dadepo
@dadepo

The word "effect" has always confused me in any description of FP, I only have a kind of mental model of the type of thing that might be going on when someone says effect, it definitely makes any sentence in it less informative to me :) But that's probably just me

@trepidacious Nope...that makes us two...plenty sure many more like us out there :D

effect does not, it's just a convenient term basically used to refer to an F[_]

@SystemFw I have seen context, or computational context used to describe this...will I be right to say that effect is just another way of saying the same thing?

Fabio Labella
@SystemFw
yes, it's the same thing
they both are convenience terms
they aren't precise
it's just F[_]
dadepo
@dadepo
Great! That clarifies things!
trepidacious
@trepidacious
Good to know I shouldn't be looking for a precise definition :)
Fabio Labella
@SystemFw

it goes like this:

  • purity is a syntactical property of programs, more precisely defined as referential transparency: replacing an expression for its bound value doesn't change meaning (precise definition)
  • side effects are things that break referential transparency (precise definition)
  • There's no direct connection between the concepts of IO, State and so on, and side effects. Traditionally, these things are side effectful (break referential transparency), but you can have abstractions that are pure (don't break ref.trans.)
  • Due to the above, the term purely functional programming is not an oxymoron, it makes perfect sense.
  • In haskell style pure FP, type constructors and algebras are used to represent "things that would otherwise traditionally be side effects (break ref.trans.)". We call these F[_]s effects or computational contexts for brevity. You can see for yourself how this cannot be a precise definition (especially because they could also have kind higher than * -> *, even though most famous algebras like Functor and Monad operate on F[_]

I guess the other thing to add is that purity really matters a lot, it's not pedantry. Referentially transparent expressions respect the substitution model, which means you can use local reasoning only to understand and compose your programs, which is a huge win

trepidacious
@trepidacious
So "effect" is kind of "replacement for side-effect, without a side-effect"
Fabio Labella
@SystemFw
yeah, so necessarily wishy-washy
trepidacious
@trepidacious
That makes sense though, thanks :)
Fabio Labella
@SystemFw
just think about a higher kinded type with some algebras defined for it, really
like "a final tagless api for a DB abstracts over the effect" <-- "takes an F[_], which will have algebras like Monoid, Monad or Sync, most likely"
RoelofWobben
@RoelofWobben
@lysium thanks for letting me see this solution
Otto Chrons
@ochrons
@SystemFw mind explaining "final tagless" while you're on a roll? :)
Fabio Labella
@SystemFw
yep
so, final tagless is a broader term, which is now getting used in a more specific meaning increasingly often
generally speaking final tagless is a technique for encoding DSLs
these days, often it's used to mean "a final tagless encoding of an effectful algebra", like a DB or something
which one are you interested in?
what the term means precisely (final + tagless)