Do these type signatures look correct?

```
//# Maybe#ap :: Maybe (a -> b) => Maybe a -> Maybe b
//# Either#ap :: Either a (b -> c) => Either a b -> Either a c
```

I’m using `=>`

because I’d like to include `this`

in the signatures somehow. The type of `this`

appears to the left of the arrow; the types of the method’s arguments and the return value appear to the right of the arrow. For example:

`//# Array#filter :: [a] => (a -> Boolean) -> [a]`

I’m not asking about the `=>`

syntax (though feedback is welcome), I’d like to know whether the `ap`

signatures are correct (given the made-up syntax).

Progress. But could use some guidance. I now have a function that takes the old appBus registry and any time something new is added it clones the old version and returns it with the newly registered object.

The idea is to construct the registry and freeze it

But I'm generating a lot of obj in the process. Should I null out the old registry when I create the new one?

I'm only using const as a way of forcing no mutation

@paldepind no problem, I didn't really know abotu it until recently, so my understanding might not be 100%

@buzzdecafe anything by Oleg Kiselyov :)

@buzzdecafe anything by Oleg Kiselyov :)

@buzzdecafe his finally tagless paper pretty well covers the ideas, also any of the talks by Simon Peyton-Jones that have to do with the expression problem are very approachable resources

@davidchambers: The

`Maybe`

one looks right. I'm not following `Either`

. Is the `=>`

placed correctly?
@ChetHarrison: Are you using something like

`assoc`

/`assocPath`

to update? This should reduce the number of created objects.
@CrossEye: I think so. In

`x.ap(y)`

, `x`

is a value of type `Either a (b -> c)`

. If `x`

is a Right its value must be a unary function, no?
@buzzdecafe also see object algebras and the paper associated with it: https://www.cs.utexas.edu/~wcook/Drafts/2012/ecoop2012.pdf

@davidchambers: Starting to see....

@buzzdecafe finally the GoF Interpreter pattern. though most of the examples are pretty bad for that though.

@davidchambers: Yes, I get it, and yes, it looks right to me.

Okay. Thanks. :)

Hmm @CrossEye thanks! Have not looked into to those. Thanks for the tip.

I Been wondering when to break out the monads.

@joneshf thanks, i've added your recommendations to my list.

anything by Oleg Kiselyov

Like *The Reasoned Schemer* for example? :smile:

Why is

`R.__`

two underscores?
LiveScript looks pretty awesome, are there any other good languages out there that transpile down to javascript out there? One other requirement is that Node/iojs can be a dependency (for the compiling), but prefer not to deal with other languages.

I.e. clojurescript is out b/c I have to deal with the JVM and clojure build chain.

@JediMindtrick PureScript. I haven't tried it. But people tell me it's quite awesome.

@paldepind thanks

Why is R. two underscores?

I believe that is because some of us like to "install" ramda functions onto the global object. But we don't wanna clobber anything that's liable to be there. Maybe not the best reason.

@JediMindtrick Last time I looked at LiveScript it was way too huge. I talked with the author and her agreed but I'm not sure if they've got it trimmed down.

@buzzdecafe Such an "installation" sounds really neat. Typing two underscores feels weird though.

It's not too bad. I was just wondering.

i believe that's why

HOW CAN I INSTALL RAMDA?!

Please.

```
for (f in R) {
global[f] = R[f];
}
```

I quit doing that after getting an obscure bug where no symptom pointed to extending global being the reason

yes, there is some risk

that is why we deprecated/removed

`R.isNaN`

Is the desire there to be able to just call filter() instead of R.filter()?

@JediMindtrick exactly

I'll have to try that.

I know eval is evil...but...you could do something similar with that and I think avoid some of the weirdness you can sometimes see with that method.

I've done something like that before awhile back.

But I stopped b/c it just felt wrong.

Might be slightly safer:

```
for (f in R) {
if (global[f] === undefined) global[f] = R[f];
}
```

yes

then you may get weird bugs in the other direction though

Might be slightly safer:

```
for (f in R) {
if (global[f] === undefined) global[f] = R[f];
else console.warning('R.' + f + ' has not been injected into global scope');
}
```

Am I wrong, or does the ES6 module syntax also fail to provide a way to do this? Which is a shame.

you could always wrap your entire script

`with(R) ...`

That is certainly worse. You can't use strict for instance.

:smiling_imp:

i am joking of course

:)

@raine nice work. ramda-cli is slick!

@buzzdecafe :)

hey @joneshf I am very interested in understanding how to manipulate these functions algebraically.

seems to me that it bumps into some problems in reality

such as when you are rewriting a composition

you may get the equivalent result, but not the optimal path to the result

but that is another branch of research :smile:

what do you imagine this would do?

`$ echo [1,2,3] | R 'map multiply 2' sum`

12

yep, multiple arguments are composed from left to right. figured it's a nice shorthand for

`R 'pipe((map multiply 2), sum)'`

I'm rewriting code to use

`R.evolve`

. It's awesome.
any examples?

I've for instance turned this:

```
return {nextId: model.nextId + 1,
counters: R.append([model.nextId, counter.init(0)], model.counters)}
```

Into this:

```
return R.evolve({nextId: R.add(1),
counters: R.append([model.nextId, counter.init(0)]), model);
```

:+1:

This one is even better:

`return {nextId: model.nextId, counters: R.tail(model.counters)};`

Into this:

`return R.evolve({counters: R.tail}, model);`

With `R.evolve`

I wont have to name the property I'm not changing.

It's way more readable.

@buzzdecafe i'm not sure i follow, can you give an example?

for example consider query optimization

there are a number of heuristics to guide it

like select then project

and the heuristics are pretty good

but don't guarantee that you will get the optimal query strategy

likewise with functional algebra i expect

since it is not concerned with *how* you get the answer, just that the answer is correct

hmm, so are you concerned with using algebra for optimization (not necessarily query opt.)?

in the context of microkanren yes

ah

well, I guess it depends on what you consider optimal.

right!

for some definitions it might not be possible to optimize, and for others it could be

Also, there's no reason that there would be a single optimal solution. You might have an entire family of optimal solutions.

depending on what your feasible solution space is.

yep, or sometimes relaxing certain constraints may get you within some \epsilon of an optimum

yeah

i think...

this stuff fascinates me

If you can transform your microkanren optimization into a system of linear equations, then you can actually optimize it.

and for sure arrive at some optimal solution, assuming it is a feasible problem, and bounded.

those are pretty big constraints you tacked on :smile:

well, maybe

maybe not :)

i feel like this might already have some research in it

maybe look into compiler optimization, term rewriting, and similar ideas

yeah, i remember scratching the surface of it in grad school

of course, even if you can translate it, it might be NP to solve it

so you might even look into approximating an optimum.

like you said, some ϵ of an optimum

!!

it depends on how you specify the problem. If within epsilon is ok, then NP may become P for the purposes of that search

gitter supports KATEX!

:epsilon:

<dollar><dollar>\epsilon<dollar><dollar>

excellent!

λ

alright, apparently it's katex?

`KaTeX parse error: Expected 'EOF', got '\choose' at position 30: m_0^n n \choose̲ 2 : \lambda_n = \sum_0^n n \choose 2 `

yeah, it seems to be missing quite a few things.

maybe i have to add some macros in the header of my comment ....

`KaTeX parse error: Expected '}', got '\over' at position 8: {n \over̲ 2}: {n \over 2}`

∑1k

sorry @joneshf no combinatorics supported

Maybe gitter is using an older version or something?

it works on http://khan.github.io/KaTeX/

so anyway

how would you define optimality with microkanren?

idk yet! moving in too many directions at once.

have bookmarks in all sorts of projects

i've set up a google groups mailing list for any interested parties:

https://groups.google.com/forum/#!forum/ramda

https://groups.google.com/forum/#!forum/ramda