by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:13
    markmiro starred sanctuary-js/sanctuary
  • 10:23

    davidchambers on lift

    fantasy-land: document use of S… (compare)

  • Aug 13 15:02
    davidchambers synchronize #90
  • Aug 13 15:02

    davidchambers on replace

    generate: add string replacemen… (compare)

  • Aug 13 15:00

    davidchambers on lift2

    (compare)

  • Aug 13 15:00

    davidchambers on gh-pages

    generate: use S.lift2 as conver… Merge pull request #92 from san… (compare)

  • Aug 13 15:00
    davidchambers closed #92
  • 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
David Chambers
@davidchambers
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
Wellington Mendoza
@well1791
Hi there!
David Chambers
@davidchambers
Hello!
Wellington Mendoza
@well1791
hey @davidchambers !! I'm here just to learn about great minds!! but also I want to do a presentation for my teammates to use sanctuary and.. If it's ok I would like to ask some questions! being this the first one: what are the major benefits of using sanctuary instead of something like purescript/elm or alikes??
the first thing I'll say is that when you use something like purescript it's a bit hard to mix some libraries..
but still not sure.. I haven't played with purescript or elm before.. so that's why I'm asking here.. ^^
David Chambers
@davidchambers
If using PureScript or Elm is an option, that's the way to go. Sanctuary may be useful for existing JavaScript projects, though, and for other situations where using a "new" language is not an option for some reason or another.
Brad Compton (he/him)
@Bradcomp
For me one benefit is that Sanctuary is still JavaScript. This means you have better interop with the rest of the JS community, and less buy in from the rest of the team.
:point_up:
It's often not reasonable to switch to a pure FP language for one reason or another, as much as we would like to.
David Chambers
@davidchambers
Well put, @Bradcomp. Another way to think about Sanctuary is as a stepping stone. One isn't going to go from writing imperative JavaScript to writing Haskell overnight. Underscore, Ramda, and Sanctuary make such a transition possible over months or years.
Wellington Mendoza
@well1791
@davidchambers @Bradcomp thanks for your responses!! actually that's a good reason to choose sanctuary! thanks for your time guys! you're awesome!
David Chambers
@davidchambers
You're welcome. :)
Mika Kalathil
@MikaAK
Hey guys quick couple questions for you, how does one extract a value from a Maybe? If I'm doing Maybe.of(2).map(someThing) do i just do .value to get the value? Is there some way to chain a fromMaybe to a Maybe chain?
David Chambers
@davidchambers
It's nice to use pipe rather than method chaining, @MikaAK. Let me find an example featuring fromMaybe.
Mika Kalathil
@MikaAK
It's hard to use pipe in my situation maybe you can provide some guidance @davidchambers? I wasn't sure how to use it
const replaceIndex = curry((array, replacement, index) => set(lensIndex(index), replacement, array))

const replaceInArray = (findFn, array, replacement) => findIndex(findFn)
  .map(replaceIndex(array, replacement))
  // need fromMaybe(array.concat(replacement))
In general I have a hard time with things like this because I'm unsure of how to compose them together point free style when I have a requirement on args like that
Irakli Safareli
@safareli
if findIndex could return Maybe Index then you replaceIndex(array, replacement) would be called with Index only if it is present, if findIndex returns Nothing then map will just ignore that function (I might not get you question thou)
David Chambers
@davidchambers
What is the type of replaceIndex, @MikaAK?