Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 20 18:42
    marcelohmdias starred sanctuary-js/sanctuary-either
  • Jan 20 08:42
  • Jan 20 03:52

    davidchambers on everything

    sanctuary@3.0.0 (compare)

  • Jan 20 03:32

    davidchambers on fira-code

    (compare)

  • Jan 20 03:32

    davidchambers on gh-pages

    fetch Fira Code from Google Fon… Merge pull request #84 from san… (compare)

  • Jan 20 03:32
    davidchambers closed #84
  • Jan 20 03:25
    davidchambers opened #84
  • Jan 20 03:20

    davidchambers on fira-code

    fetch Fira Code from Google Fon… (compare)

  • Jan 20 03:12
  • Jan 20 02:53

    davidchambers on redirect

    (compare)

  • Jan 20 02:52

    davidchambers on gh-pages

    remove redundant client-side re… Merge pull request #83 from san… (compare)

  • Jan 20 02:52
    davidchambers closed #83
  • Jan 20 02:51
    davidchambers opened #83
  • Jan 20 02:43

    davidchambers on redirect

    remove redundant client-side re… (compare)

  • Jan 20 02:34

    davidchambers on update

    (compare)

  • Jan 20 02:33

    davidchambers on gh-pages

    sanctuary@3.0.0 Merge pull request #82 from san… (compare)

  • Jan 20 02:33
    davidchambers closed #82
  • Jan 20 02:32
    davidchambers opened #82
  • Jan 20 02:23

    davidchambers on update

    sanctuary@3.0.0 (compare)

  • Jan 20 01:35

    davidchambers on sanctuary

    (compare)

voxbono
@voxbono
@Avaq Thank you so much! Now the code looks like artwork! :heart:
Aldwin Vlasblom
@Avaq
:D
Asad Saeeduddin
@masaeedu
i may be misunderstanding the question, but wouldn't solving the problem require chain @Avaq?
voxbono
@voxbono
I’m doing S.chain(Future.parallel(Infinity)) in the next step.
David Chambers
@davidchambers
Andy Chen
@KsRyY
I think that there's a XSS problem on the document site
If you type in "alert("xss")"
There will be an alert
and other objects such as document are accessible through the REPL
David Chambers
@davidchambers
Is that a problem, do you think?
Aldwin Vlasblom
@Avaq

@KsRyY That's not actually a XSS vulnerability.

XSS is when you manage to insert some code to the server side of a website in such a way that it then runs on other people's computers when they browse to the website.
Unless I'm missing something, what you've demonstrated is an attack on yourself. And there's worse ways to attack yourself. ;)

leosbotelho
@leosbotelho

XSS is when you manage to insert some code to the server side ...

Not necessarily. I like OWASP's definition: "XSS attacks occur when an attacker ... send[s] malicious code ... to a different end user".

The payload could rest in a url fragment, for instance. e.g: https://www.owasp.org/index.php/DOM_Based_XSS#Advanced_Techniques_and_Derivatives
But yeah, in this case there's no way to "send the payload to another user". So there's no XSS.
voxbono
@voxbono
Does Sanctuary have any build in methods for getting a value in a StrMap containing an array? For example, to get the b prop here:
const myObj = {
  a: [{b: 'c'}]
}
for instance, can I do this with S.gets in any way?
David Chambers
@davidchambers
@silly-goat
S.value
silly-goat
@silly-goat
value :: String -> StrMap a -> Maybe a
David Chambers
@davidchambers
In this case a is Array (StrMap String).
@silly-goat
S.value ('a') ({a: [{b: 'c'}]})
silly-goat
@silly-goat
Just ([{"b": "c"}])
David Chambers
@davidchambers
@voxbono, given [{x: 1}, {x: 2}, {x: 3}] do you want to choose 1, 2, or 3?
voxbono
@voxbono
In this case, I knew I wanted index 0 (head). I played around til S.getsand it looks like I can do S.gets(S.is($.String)(['a', '0', 'b'])(myObj)
David Chambers
@davidchambers
That's the perfect solution if you don't know the shape of myObj, @voxbono.
If you do know the shape of myObj you do not need S.gets.
@silly-goat
S.chain (S.value ('b'))
        (S.chain (S.head)
                 (S.value ('a') ({a: [{b: 'c'}]})))
silly-goat
@silly-goat
Just ("c")
voxbono
@voxbono
thanks! :)
David Chambers
@davidchambers
/versions
silly-goat
@silly-goat
Node v10.16.0

hubot@3.0.1
hubot-gitter2@1.0.0

fluture@10.3.1
fluture-sanctuary-types@3.0.0
ramda@0.26.1
sanctuary@3.0.0
sanctuary-def@0.21.1
sanctuary-descending@2.1.0
sanctuary-either@2.1.0
sanctuary-identity@2.1.0
sanctuary-int@3.0.0
sanctuary-maybe@2.1.0
sanctuary-pair@2.1.0
sanctuary-show@2.0.0
sanctuary-type-classes@12.1.0
sanctuary-type-identifiers@3.0.0
sanctuary-useless@2.0.1
David Chambers
@davidchambers
@silly-goat
S.intercalate ('a') ({foo: 'ry', bar: 'S', baz: 'nctu'})
silly-goat
@silly-goat
"Sanctuary"
Aldwin Vlasblom
@Avaq
:tada:
Vladimir Kapustin
@kapooostin
S.intercalate ('a') ({foo: 'ry', bar: 'S', baz: 'nctu'})
Here you rely on the order StrMap is reduced in. It looks kind of inconsistent compared to how arrays are intercalated in examples. I get that Object’s reduce uses sortedKeys internally, but maybe this specific example is also needed in docs.
David Chambers
@davidchambers
Good idea, @kapooostin. We should at least include a string map example at https://github.com/sanctuary-js/sanctuary-type-classes#reduce.
Aldwin Vlasblom
@Avaq
Yeah, it's a good example because it shows very clearly how it behaves under a condition where the developer might not know what to expect.
Vladimir Kapustin
@kapooostin
S.intercalate looks especially powerful once I learnt that it is reduce with concat starting from an empty value of a separator.
fillon
@fillon

With sanctuary@3 is there any change to S.map behaviour?

My tests are now failing and were passing with @2.0.2 & Fluture@11.0.3.

That’s the kind of error I get with Jest

 TypeError: Type-variable constraint violation

    map :: Functor f => (a -> b) -> f a -> f b
                                      ^
                                      1

    1)  function (done) {
            /* istanbul ignore next */
            cov_t6cln3sc5.f[2]++;
            cov_t6cln3sc5.s[3]++;
            return connection.query(options, done);
          } :: Function, (c -> d)
        {"head": null, "tail": <Circular>} :: Object, StrMap ???

    Since there is no type of which all the above values are members, the type-variable constraint has been violated.

      at typeVarConstraintViolation (node_modules/sanctuary-def/index.js:2527:12)
      at Object.value (node_modules/sanctuary-def/index.js:1378:20)
      at assertRight (node_modules/sanctuary-def/index.js:2624:37)
      at node_modules/sanctuary-def/index.js:2715:27
      at node_modules/sanctuary/index.js:1672:14
      at node_modules/sanctuary/index.js:1242:56
      at Array$prototype$reduce (node_modules/sanctuary-type-classes/index.js:816:58)
      at Object.reduce (node_modules/sanctuary-type-classes/index.js:1906:47)
      at node_modules/sanctuary/index.js:1242:18
      at node_modules/sanctuary/index.js:1834:29
David Chambers
@davidchambers
@fillon, you may need to wait until Fluture and fluture-sanctuary-types have been updated in response to sanctuary-type-identifiers@3.0.0.
fillon
@fillon
Thanks @davidchambers … seems like it’s when i have a function returning Future and doing S.map(S.map) on it
Aldwin Vlasblom
@Avaq
@fillon The Future is being treated as a regular object, because the newer version of Sanctuary is no longer able to identify its type. Fluture 12 has been updated to communicate its type in the new way, but upgrading to Fluture 12 could be quite an endeavour.
Aldwin Vlasblom
@Avaq
@silly-goat
S.map (S.add (1)) (Future.resolve (41))
silly-goat
@silly-goat
Future.of(41).map(function(x) {
          if (arguments.length !== expType.arity - 1) {
            throw invalidArgumentsLength (typeInfo,
                                          index,
                                          expType.arity - 1,
                                          slice.call (arguments));
          }

          var args = arguments;
          typeVarMap = assertRight (
            (init (expType.keys)).reduce (function(either, k, idx) {
              var arg = args[idx];
              return Z.chain (function(typeVarMap) {
                return checkValue (typeVarMap, index, k, arg);
              }, either);
            }, Right (typeVarMap))
          );

          var output = value.apply (this, arguments);
          var k = last (expType.keys);
          typeVarMap = assertRight (checkValue (typeVarMap, index, k, output));
          return output;
        })
Aldwin Vlasblom
@Avaq
Hmm
That actually seems to work fine.
/versions
silly-goat
@silly-goat
Node v10.16.0

hubot@3.0.1
hubot-gitter2@1.0.0

fluture@10.3.1
fluture-sanctuary-types@3.0.0
ramda@0.26.1
sanctuary@3.0.0
sanctuary-def@0.21.1
sanctuary-descending@2.1.0
sanctuary-either@2.1.0
sanctuary-identity@2.1.0
sanctuary-int@3.0.0
sanctuary-maybe@2.1.0
sanctuary-pair@2.1.0
sanctuary-show@2.0.0
sanctuary-type-classes@12.1.0
sanctuary-type-identifiers@3.0.0
sanctuary-useless@2.0.1
fillon
@fillon
@Avaq i am using fluture@11.0.3 and fluture-sanctuary-types@4.1.1 if it helps. I will dig a bit more and see where it breaks
fillon
@fillon

Here is a code snippet that works well with fluture@11.0.3

        const f = x => Future.resolve([{ count: x }]);

        const g = x =>
            S.pipe([
                f,
                S.map(S.pipe([S.head, S.map(S.prop('count'))])),
                S.chain(S.maybe(Future.reject('error'))(Future.of))
            ])(x);

        const x = await g(10).promise();

A generate this when using sanctuary@3.0.0 sanctuary-def@0.21.1

TypeError: Type-variable constraint violation

    chain :: Chain m => (a -> m b) -> m a -> m b
                         ^              ^
                         1              2

    1)  Just (10) :: Maybe Number, Maybe NonNegativeInteger, Maybe PositiveFiniteNumber

    2)  {"head": {"context": {"head": null, "tail": <Circular>}, "mapper": function(x) {
            if (arguments.length !== expType.arity - 1) {
              throw invalidArgumentsLength (typeInfo,
                                            index,
                                            expType.arity - 1,
                                            slice.call (arguments));
            }

            var args = arguments;
            typeVarMap = assertRight (
              (init (expType.keys)).reduce (function(either, k, idx) {
                var arg = args[idx];
                return Z.chain (function(typeVarMap) {
                  return checkValue (typeVarMap, index, k, arg);
                }, either);
              }, Right (typeVarMap))
            );

            var output = value.apply (this, arguments);
            var k = last (expType.keys);
            typeVarMap = assertRight (checkValue (typeVarMap, index, k, output));
            return output;
          }}, "tail": {"head": null, "tail": <Circular>}} :: Object, StrMap Object
        Future.of([{"count": 10}]) :: Object, StrMap (Array Object), StrMap (Array (StrMap Number)), StrMap (Array (StrMap NonNegativeInteger)), StrMap (Array (StrMap PositiveFiniteNumber)), Future c (Array Object), Future c (Array (StrMap Number)), Future c (Array (StrMap NonNegativeInteger)), Future c (Array (StrMap PositiveFiniteNumber))

    Since there is no type of which all the above values are members, the type-variable constraint has been violated.

      at typeVarConstraintViolation (node_modules/sanctuary-def/index.js:2527:12)
      at Object.value (node_modules/sanctuary-def/index.js:2651:28)
      at assertRight (node_modules/sanctuary-def/index.js:2624:37)
      at MapperAction.mapper (node_modules/sanctuary-def/index.js:2692:22)
      at MapperAction.chainActionHandler [as resolved] (node_modules/fluture/index.js:883:19)
      at resolved (node_modules/fluture/index.js:525:21)
      at Resolved$interpret [as _interpret] (node_modules/fluture/index.js:663:5)
      at drain (node_modules/fluture/index.js:587:27)
      at settle (node_modules/fluture/index.js:509:17)
      at Transformation$interpret [as _interpret] (node_modules/fluture/index.js:600:5)