Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 15 20:18
    rpominov commented #318
  • Dec 15 20:08
    davidchambers commented #318
  • Dec 15 19:41
    Ne4to777 closed #318
  • Dec 15 19:41
    Ne4to777 commented #318
  • Dec 15 19:30
    davidchambers commented #318
  • Dec 15 18:59
    Ne4to777 opened #318
  • Nov 17 14:44
    davidchambers commented #317
  • Nov 17 00:42
    Avaq edited #317
  • Nov 17 00:24
    Avaq edited #317
  • Nov 17 00:21
    Avaq edited #317
  • Nov 17 00:21
    Avaq edited #317
  • Nov 17 00:09
    Avaq edited #317
  • Nov 16 19:15
    bergus commented #317
  • Nov 16 12:49
    Avaq edited #317
  • Nov 16 12:48
    Avaq opened #317
  • Oct 08 11:13

    davidchambers on master

    Added Zion Merge pull request #316 from on… (compare)

  • Oct 08 11:13
    davidchambers closed #316
  • Oct 08 11:12
    davidchambers commented #316
  • Oct 08 05:36
    oncicaradupopovici opened #316
  • Jul 17 15:02
    masaeedu closed #290
Rick Medina
@rickmed
@JAForbes yeah, I read a fair bunch of the comments. Many people disagreeing with him and many arguing that he didn't prove his point in the article. I for one was coming from a POV disagreeing with him but seeing an article like this from someone like him makes you doubt
Keith Alexander
@kwijibo
@rickmed is it less contentious if you replace Mostly Functional with Mostly Pure?
Rick Medina
@rickmed
@kwijibo I guess it would help since it would more clearly distinguish upfront the concept of "function" between the math definition and the (I'd argue) most programmers definition. But the general article's point would stand unchanged.
Keith Alexander
@kwijibo

@dtipson

If someone could do a version of this video https://www.youtube.com/watch?v=hmX2s3pe_qk but with javascript instead of Scala, I have a feeling that my mind would be blown. But my inability to follow Scala notation prevents me from following all the way through

@dtipson https://www.youtube.com/watch?v=WH5BrkzGgQY&list=PLK_hdtAJ4KqUWp5LJdLOgkD_8qKW0iAHi&index=1 these here are pretty much the JS equivalent of the scala code in The Interpreter Pattern Revisited
(you can turn off the sound if the trippy music doesn't aid your concentration, there's no speech ....)
Irakli Safareli
@safareli
@dtipson here are some resources I have collected when I was trying to get my head around Free https://gist.github.com/safareli/b43f43d3e65483b71b08b894386f4d71
Keith Alexander
@kwijibo
@safareli I see you also wrote an implementation. Have you used Frees much in production ?
Irakli Safareli
@safareli
I have used it in one internal chrome extention
it was really handy, main logic was expressed as a free structure it was pure and first interpreter I wrote was test one as at first I have not implemented needed http services
Irakli Safareli
@safareli
I have also tried to use it with react/redux from components I was dispatching Free structures which could be mapped by parent components and this way i pushed all side effects to middleware which was interpreting dispatched Free structures
Keith Alexander
@kwijibo
@safareli that's interesting thanks.
@safareli any downsides?
Markus Pfundstein
@MarkusPfundstein
one question, how do you use the forall sign here ? ['foldMap(f, of) ≡ compose(retract(of), hoist(f))', Ɐ.forall('number -> number', (f) => {
Keith Alexander
@kwijibo
https://www.youtube.com/watch?v=U0lK0hnbc4U is actually a really good clear explanation of what Free Monads are, though I found the explanation of the pitfalls and when to use vs when not to use, less clear
Irakli Safareli
@safareli
downside is that none of my coworkers will understand that :smile:
Markus Pfundstein
@MarkusPfundstein
as stupid as it sounds, but this is really a problem :(
hope this will change someday...
Keith Alexander
@kwijibo
I was wondering about that - from a library users POV, isn't the API quite straight forward?
you can just chain everything, instead of dealing with nested types, no?
so in that sense, it's more straightforward than a mix of Task, Maybe, Either, etc
Or are there more gotchas in practice?
I was also thinking it seemed like you could get similar advantages using Reader.T (https://github.com/ramda/ramda-fantasy/blob/master/docs/Reader.md) ?
Keith Alexander
@kwijibo
(ie, you could pass all the "interpreter specific" functions to the run at the end)
Irakli Safareli
@safareli
Scott Christopher
@scott-christopher

@safareli: I like that it just leans on the Monoid laws in regards to concat. The only other thing missing from those examples (I may have just missed it) is how you go about getting the value out of empty, e.g.

fold = xs => xs.reduce((m, x) = m.concat(x), empty)
// sums :: Additive
sum = fold([])

You could perhaps adopt something like:

Additive.valueOf = a => a === empty ? 0 : a.value
Irakli Safareli
@safareli

So type of fold is :: (Monoid m) => [m] -> m i.e. items in list should be monoids.
sum = fold(["a", "b"]) // should be ["ab"]

foldr f z []     = z 
foldr f z (x:xs) = f x (foldr f z xs)

But if we empty list to reduce then it will just return the empty and will lose the type information which we actually did not had as there is nothing in list, so result of sum = fold([]) would be empty

Irakli Safareli
@safareli
When enter the "world" of Monoid you can just concat so there's no problem, but when we are extracting value from Additive for example, yes we can do a => isEmpty(1) ? 0 : a.value if before that we can't convert empty to actual typed empty
Markus Pfundstein
@MarkusPfundstein
when implement flatMap, is it necessary to implement it in terms of map and join? Thus must I write a join function to join two Monads?

for instance for the Maybe monad, I can just do

flatMap(f) {
     return match(this)
          .when(Empty, this)
          .when(Just, f(this.__value))
}

where f is a function that returns a Maybe. So I don’t need join here that joins two Maybes…

but I think its more nice to do it with a join or not? Or even required?
flatMap(f) {
     return match(this)
          .when(Empty, this)
          .when(Just, Maybe.join(this, f(this.__value)))
}
join can be concat when Maybe is also a monoid right?
Drew
@dtipson
I see it as f(this.value) in a lot of places. Technically that means that improperly used with an f that isn't x => Type x, it can return some other random type. But most implementations don't seem concerned about that
probably because defining it using join wouldn't even necessarily even solve that problem
Ralph
@ralphbecket
@rickmed I'm inclined to agree with Meijer based on my experience. When I was working in a rigorously pure language, sordid assignment-based shortcuts simply weren't an option and you just had to Do Things Properly. That turned out not to be particularly costly and to have several benefits: code was noticeably more reliable, bugs were significantly rarer, refactoring was very easy, error cases had to be tested for, we had great faith in our code, reasoning about bugs was a fair bit simpler, and in general things just worked. As soon as you can't guarantee purity (i.e., you were depending on "discipline"), those wonderful properties evaporate.
Syaiful Bahri
@syaiful6
quick question: is fantasy land Foldable.reduce is foldr or foldl
hmm, i guess it foldl
Scott Christopher
@scott-christopher
yep, foldl
Markus Pfundstein
@MarkusPfundstein
@dtipson this is a big problem when learning Monads with js . For instance it wasn’t clear to me in the beginning that I am not allowed to change the monad type in the flatMap function. Because the implementations I found, just use f(this.value).. so its no problem to declare f as f :: (a -> Either Error b) and call it on a Maybe Monad. While in Haskell this wouldn’t compile.
if implemented with join, one could add a TypeError for instance.
I also find that using flow while implementing my own monads is much better for the learning effect as at least the type system helps me somehow.. Learning Haskell is a goal, but its so tedious to get started -.-
Rick Medina
@rickmed
@ralphbecket my POV is that those wonderful properties evaporate in the parts of your app where you are not using fp. Meaning, there is a net value added in using fp in only parts of an app. Also, going functional all the way would mean anyone/team who wanted to learn/apply fp would need to learn haskell/similar which is too steep of a curve -and I don't even think that haskell is 100% pure.
Ryan Zeigler
@rzeigler
unsafePerformIO is my favorite impure part of haskell :-)
unsafeCoerce is pretty awesome too
Irakli Safareli
@safareli
here is wip implementation of that empty|of safareli/quasi#1
Keith Alexander
@kwijibo
Seems unlikely that fp would have no net value unless 100% of the code was pure, but I can imagine the value increasing exponentially as the purity approached 100% :)
Keith Alexander
@kwijibo
Hey, is React.js the Interpreter pattern? React.render() is an interpreter, all the virtual-dom things are just data that has no effect until run by the interpreter.
Hardy Jones
@joneshf
Yep!
Keith Alexander
@kwijibo
Gang of Four FTW :)