by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 12 17:21
    nythrox starred sanctuary-js/sanctuary
  • Aug 12 16:47

    davidchambers on min-max-by

    fantasy-land: add S.minBy and S… (compare)

  • Aug 12 16:45
    davidchambers synchronize #693
  • Aug 12 16:45

    davidchambers on replace

    regexp: add S.replace (compare)

  • Aug 12 16:44

    davidchambers on no-curry

    (compare)

  • Aug 12 16:43

    davidchambers on master

    function: remove S.curry2, S.cu… Merge pull request #692 from sa… (compare)

  • Aug 12 16:43
    davidchambers closed #692
  • Aug 12 16:41

    davidchambers on replace-with

    (compare)

  • Aug 12 16:41
    davidchambers closed #88
  • Aug 12 16:41
    davidchambers commented #88
  • Aug 12 16:38

    davidchambers on replace-with

    (compare)

  • Aug 12 16:38
    davidchambers closed #686
  • Aug 12 16:38
    davidchambers commented #686
  • Aug 12 16:36
    davidchambers labeled #693
  • Aug 12 16:36
    davidchambers review_requested #693
  • Aug 12 16:36
    davidchambers opened #693
  • Aug 12 16:14

    davidchambers on replace

    regexp: add S.replace (compare)

  • Aug 12 16:05
    davidchambers review_requested #92
  • Aug 12 16:05
    davidchambers opened #92
  • Aug 12 15:58

    davidchambers on lift2

    generate: use S.lift2 as conver… (compare)

David Chambers
@davidchambers
What are you expecting the result to be, @kwijibo?
Keith Alexander
@kwijibo
@davidchambers tbh, I was curious (what the result would be), which was why I tried :) Just has a concat method, so presumably is a SemiGroup, but won't accept another Just as an argument?
David Chambers
@davidchambers
If you look closely at the error message you'll see that it's complaining about the a rather than the Maybe a.
Maybe#concat only applies to a types which satisfy the Semigroup constraint (i.e. provide a concat method).

This is valid:

Maybe String ~> Maybe String -> Maybe String

This is invalid:

Maybe Number ~> Maybe Number -> Maybe Number
The values inside the maybes must themselves support concatenation.
Keith Alexander
@kwijibo
gotcha
David Chambers
@davidchambers
@ram-bot
S.Just('abc').concat(S.Just('def'))
ram-bot
@ram-bot
Just("abcdef")
Brad Compton (he/him)
@Bradcomp
What is the benefit of Maybe having a concat rather than just doing this:?
S.lift2(concat)(S.Just([1]), S.Just([2]))
David Chambers
@davidchambers
It's still useful for interoperability, @Bradcomp.
Brad Compton (he/him)
@Bradcomp
I guess you get better type checking too
Well, until S.concat is a thing
Keith Alexander
@kwijibo
I was wondering what would happen if you concat'd Just(1) with Nothing()
Just, Nothing, or "who knows"
David Chambers
@davidchambers
S.concat actually already exists, @Bradcomp, but as you say the other FL functions are coming soon!
Brad Compton (he/him)
@Bradcomp
Sorry!
David Chambers
@davidchambers
Just(1) specifically, @kwijibo, or are you wondering what happens when one concats just and nothing in general?
No problem, @Bradcomp. I'm itching to get all these pull requests finished. I'm close. I'm also trying to sort out a work permit in Berlin, and I don't know any German yet. My plan to work full-time on Sanctuary is being undermined by bureaucracy. :scream:
Brad Compton (he/him)
@Bradcomp
That's exciting! I would love to see all that stuff merged as well.
Keith Alexander
@kwijibo
S.Nothing().concat(S.Nothing()) //=> S.Nothing() <-- that's nice :)
David Chambers
@davidchambers
:)
Keith Alexander
@kwijibo
@davidchambers I was just wondering if it would be like true || false
David Chambers
@davidchambers
In what sense?
Keith Alexander
@kwijibo
that || is a type of combining, for booleans, and concat is a method for combining values
but there are other ways of combining booleans of course
David Chambers
@davidchambers
You may also be interested in S.or.
Keith Alexander
@kwijibo
yeah that was probably what made me think about it
(so what does it mean to concat them?)
David Chambers
@davidchambers
I can imagine wanting to do something like this:
@ram-bot
R.reduce(S.concat, S.Nothing(), [S.Just('foo'), S.Nothing(), S.Just('baz'), S.Just('quux')])
ram-bot
@ram-bot
Cannot read property '@@transducer/step' of undefined
David Chambers
@davidchambers
That should evaluate to Just('foobazquux').
Brad Compton (he/him)
@Bradcomp
I see! Using lift2(concat) instead resolves to Nothing()
David Chambers
@davidchambers
Ah, good point!
Keith Alexander
@kwijibo
Interesting :)
Irakli Safareli
@safareli
David Chambers
@davidchambers

I understand these:

Identity.empty.concat(Identity([]));  // => Identity([])
Identity([]).concat(Identity.empty);  // => Identity([])

I'm confused by these:

empty.concat(Identity([]));  // => Identity([])
Identity([]).concat(empty);  // => Identity([])
Irakli Safareli
@safareli
// f :: (Monoid m, Applicative m) => Number -> m Number
const f = a == 0 ? empty : of(2)

Then if we use this f and concat some other (Applicative m, Monoid m) => m to it than the result should be this other thing

f(0).concat(Identity([])) // Identity([])

empty represents empty for any monoid

David Chambers
@davidchambers
Oh, I see now.
If we have the special empty value and we want to get an actual empty value, how would we do so? How would we get from empty to '', for example?
Irakli Safareli
@safareli
empty.concat(String.empty)
and that concat on empty is just id so it returns String.empty
David Chambers
@davidchambers
That makes sense.
Irakli Safareli
@safareli
:tada:
David Chambers
@davidchambers
Very cool stuff, @safareli!
Irakli Safareli
@safareli
yeh I'm excited! This weekend I would set up a repo for that, but first i should thinking on the name :smile:
David Chambers
@davidchambers
That's often the trickiest part.
Irakli Safareli
@safareli
here is wip implementation of that empty|of safareli/quasi#1