Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Stefano Vozza
@svozza
looking good!
David Chambers
@davidchambers
I didn't mean to make you feel guilty. I'm just pleased to see you around.
Stefano Vozza
@svozza
:D
do we still want to do that mergeStrMaps function? i'm guess it needs a serious rebase
David Chambers
@davidchambers
I think sanctuary-type-classes defines Object#concat. Let me check.
Yes, it does:
        //  Object#concat :: StrMap a ~> StrMap a
        'fantasy-land/concat': function(strMap) {
          var result = {};
          for (var k in this) if (has(k, this)) result[k] = this[k];
          for (k in strMap) if (has(k, strMap)) result[k] = strMap[k];
          return result;
        },
Brad Compton (he/him)
@Bradcomp
Thanks for the help @davidchambers!
David Chambers
@davidchambers
You're welcome. :)
Stefano Vozza
@svozza
ah yes, i like it
David Chambers
@davidchambers
Here you go, @svozza:
const Z = require('sanctuary-type-classes');

Z.concat({x: 1, y: 1}, {y: 2, z: 2});
// => {x: 1, y: 2, z: 2}
Stefano Vozza
@svozza
very nice
David Chambers
@davidchambers
What do you think of the approach to dispatching in sanctuary-type-classes, Stefano?
Stefano Vozza
@svozza
i really like it
the code looks very clean
getBoundMethod is clever
i like how it won't ever leak out to the user that you're using this
David Chambers
@davidchambers
I love being able to define the various fantasy-land/ methods separately. I'm finally living the OOP dream. :stuck_out_tongue_winking_eye:
Stefano Vozza
@svozza
hehe
we should rewrite everything in Smalltalk imo
David Chambers
@davidchambers
Haha, yes!
Does that mean I need to stop using Vim?
Stefano Vozza
@svozza
David Chambers
@davidchambers
:)
David Chambers
@davidchambers
If you're excited about the upcoming Sanctuary release and would like to help make it happen, a review of #259 would be much appreciated.
Brad Compton (he/him)
@Bradcomp
Looks great @davidchambers
David Chambers
@davidchambers
Thanks for your feedback. :)
David Chambers
@davidchambers
Small pull request seeks :eyes:: sanctuary-js/sanctuary-def#82.
It'll mean we can use $.__ or S.__ without having to rely on R.__ (or define our own placeholder value).
David Chambers
@davidchambers

Adding this line to my ~/.vimrc just blew me away:

let g:markdown_fenced_languages = ['haskell', 'javascript']

Now JavaScript code within code blocks in Markdown files has syntax highlighting. :)

Stefano Vozza
@svozza
Nice!
Aldwin Vlasblom
@Avaq

Is there a nice analogue to || when working with Maybe (like Fluture#or)? If I have two Maybe as, I want to use the first Just, or Nothing, so:

or( Just('a') , Nothing ) = Just('a')
or( Nothing , Just('b') ) = Just('b')
or( Just('a') , Just('b') ) = Just('a')
or( Nothing, Nothing ) = Nothing

Or am I looking over a better way to do this kind of thing?

Maybe#concat comes really close, but then it tries to concat its value.
Brad Compton (he/him)
@Bradcomp
@avaq Sanctuary has an or function that I think does just that.
Aldwin Vlasblom
@Avaq
Oh wow, yeah. Now that you mention it, I have seen that come by. Never had a use-case for it. Awesome :D
Thanks
Brad Compton (he/him)
@Bradcomp
:+1:
Keith Alexander
@kwijibo
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