Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 10 16:48
    dependabot[bot] labeled #167
  • May 10 16:48
    dependabot[bot] opened #167
  • May 10 16:48

    dependabot[bot] on npm_and_yarn

    build(deps): bump hosted-git-in… (compare)

  • May 09 12:15

    dependabot[bot] on npm_and_yarn

    (compare)

  • May 09 12:15
    dependabot[bot] closed #160
  • May 09 12:15
    dependabot[bot] commented #160
  • May 09 12:15
    dependabot[bot] labeled #166
  • May 09 12:15
    dependabot[bot] opened #166
  • May 09 12:14

    dependabot[bot] on npm_and_yarn

    build(deps): bump lodash from 4… (compare)

  • May 07 17:49

    dependabot[bot] on npm_and_yarn

    (compare)

  • May 07 17:49
    dependabot[bot] closed #161
  • May 07 17:49
    dependabot[bot] commented #161
  • May 07 17:49
    dependabot[bot] labeled #165
  • May 07 17:49
    dependabot[bot] opened #165
  • May 07 17:49

    dependabot[bot] on npm_and_yarn

    build(deps): bump handlebars fr… (compare)

  • Mar 30 19:36
    dependabot[bot] labeled #164
  • Mar 30 19:36

    dependabot[bot] on npm_and_yarn

    build(deps): bump y18n from 3.2… (compare)

  • Mar 30 19:36
    dependabot[bot] opened #164
  • Dec 11 2020 10:19
    dependabot[bot] labeled #163
  • Dec 11 2020 10:19
    dependabot[bot] opened #163
Alvaro Carrasco
@alvaroc1
a bit off-topic, but i'm trying to compare custom types in javascript... funfix-core has IEquals, but just that... any suggestions to where I should look? Should I be looking for implementations of fantasyland's Ord?
Alexandru Nedelcu
@alexandru
@alvaroc1 funfix-core also has the is function, which does use IEquals if it sees that the type implements it, or valueOf.
It's not very original either, it's what other libraries like immutable.js are doing as well.
Oh, you meant that you want ordering?
Alvaro Carrasco
@alvaroc1
yeah, sorry should have specified ordering
Alexandru Nedelcu
@alexandru
Somebody just committed Ord to funland. Not sure how much that helps — funfix/funland#12
Alvaro Carrasco
@alvaroc1
i REALLY miss typeclasses when I stray from scala :/
Alexandru Nedelcu
@alexandru
Right. Well the problem with Ord is that I'm not sure if there's any common protocol.
The closest you can get is to compare the output of valueOf() btw.
Alvaro Carrasco
@alvaroc1
ah good pointer, i didn't know about valueOf
but [...].sort() won't use that by default, right? I still have to give it an explicit comparison function?
Alexandru Nedelcu
@alexandru
@alvaroc1 I have no idea what the standard sort() uses, but it's a good chance that it uses valueOf(). Try it out.
Alvaro Carrasco
@alvaroc1
will do, thanks
Iván Portilla
@Ivykp
Hey guys, i hope you are fine today. I have a little question: i am trying to use phantomjs with angular-cli for headless testing, i configured everything but i have a problem with a library i am using: https://github.com/funfix/funfix. When i run ng test i receive the next error: PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR { "message": "SyntaxError: Use of reserved word 'class'\nat http://localhost:9876/_karma_webpack_/vendor.bundle.js:95636:0", "str": "SyntaxError: Use of reserved word 'class'\nat http://localhost:9876/_karma_webpack_/vendor.bundle.js:95636:0" }
Any idea what can i do?
Alexandru Nedelcu
@alexandru
@Ivykp how are you importing funfix into your project?
And are you using Webpack?
Funfix should work out of the box either with ES2015 or with CommonJS. However there's a catch — if you're using Webpack, then know that Webpack has an implemention that supports ES2015 modules, but NOT other ES2015 features.
So what you need to do is to work with import "funfix/dist/es5"
So the funfix/dist/es5 package is specifically prepared for usage with Webpack and similar.
Hope this helps.
David Dudson
@DavidDudson

@alexandru Would you be interested in having .map2 etc. added to Option in funfix.

I quite often find myself having 2 or more inputs that need to be sanitized before using them.

Unless I'm missing an easier way to do the following

optA.map2(optB, (a, b) => a + b)
David Dudson
@DavidDudson
Nevermind. im blind, I just found the static methods
Alexandru Nedelcu
@alexandru
:+1:
Frank Filho
@frankpf
How do I convert a function that returns Promise<T> to a function returning IO<T>?
Alvaro Carrasco
@alvaroc1
maybe IO.deferFuture(() => Future.fromPromise( doSuff() )) not sure though... just a guess
Alvaro Carrasco
@alvaroc1
what's the best way to create a Future that can be fulfilled with a callback? ... kind of like scala Promise
Alexandru Nedelcu
@alexandru
@alvaroc1 Promise is called FutureMaker
... given the name was already taken, had to come up with something :)
Alvaro Carrasco
@alvaroc1
ah nice... thanks
Frank Filho
@frankpf
@alvaroc1 that works if I have a Promise<T> (i.e. a value that is a promise)
but I have a function that returns a Promise<T>
async function add(x: number, y: number): Promise<number> {
   return Promise.resolve(x + y)
}

Future.fromPromise(add) // error, fromPromise takes a Promise<T>
Here's what I've used to convert a function that uses callbacks, but I don't know if this is the "correct" way to do it:
import { QueryResult, Client } from 'pg'
import { Failure, Success, Duration, IO } from 'funfix'

function queryIO(client: Client, query: string, params: any[]) {
    const io = IO.async<QueryResult>((scheduler, callback) => {
        const task = scheduler.scheduleOnce(Duration.zero(), () => {
            client.query(query, params, (err, result) => {
                if (!err) {
                    callback(Success(result))
                } else {
                    console.log(err)
                    callback(Failure(err))
                }
            })
        })

        return task
    })

    return io
}
Alvaro Carrasco
@alvaroc1
You can do this: (a: number, b:number) => Future.fromPromise(add(a,b)) but i'm guessing you want something more general? not sure if it's possible without knowing before-hand the arity of the function
Alvaro Carrasco
@alvaroc1
I'm trying to create a "right" for Either<string,void>... is there an instance of void? how can i create it?
apparently undefined is an instance of void
Alvaro Carrasco
@alvaroc1
why is (... : Option<...>).orNull() a function call as opposed a getter? is there a reason to choose regular functions over getters in javascript? wouldn't a getter remove the extra ()?
Alexandru Nedelcu
@alexandru
@alvaroc1 turning those into getters might be a good idea. To tell you the truth, getters involving defineProperty, I thought it needs newer support than EcmaScript 5, so I avoided it completely.
Alvaro Carrasco
@alvaroc1
@alexandru is there a backwards-compatible way to make that change?
Alexandru Nedelcu
@alexandru
@alvaroc1 I don't know, I haven't played with it.
Iván Portilla
@Ivykp
Hey guys! I have a existencial question, would be worth to make a Scala Collections like library for JS using funfix-core types? I think one of the main facilities using Option in Scala is by example the collection library uses it for default, and so on with Future, etc.
Alvaro Carrasco
@alvaroc1
@Ivykp In the past i've considered using other collection libraries like Immutable.js, etc. But they always seem syntactically at a big disadvantage compared to the built in Array and Object because of things like the literal syntax and the spread operator
It has really made me appreciate how scala was able to offer syntactic niceties through more general means that can be leveraged by libraries and are not locked in to the built-in structures
@alexandru I usually follow the rule that if a function returns Unit, then it needs to make sure not to swallow any errors from futures... at the very least it should make sure that they get logged
Alvaro Carrasco
@alvaroc1
I lobbied for forEach on future returning void... which i still think makes sense, but now I think it should also log any exceptions... what do you think?
Adam Gajek
@agajek
Hi! I want to take one of the issues and while I had no problems with TS implementation I completely don't understand how to start with flow. Do I need to just provide signatures of functions and then it is magically linked with implementation provided in ts files?
Alexandru Nedelcu
@alexandru
@agajek Flow signatures should just work as well. Not sure if there's a problem with the latest Flow version or not and Funfix needs to be upgraded to latest versions. But there shouldn't be any problems.
Alexandru Nedelcu
@alexandru

Hi all, I published funland v0.1.5, with updated dev dependencies.

Will follow with funfix soon.

James Sinclair
@jrsinclair
Is anyone still working on funland or funfix?
lostintime
@lostintime
Probably not, @alexandru seems to be completely back to scala :)