Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

thoughts #8

Open
mattdesl opened this issue Mar 19, 2015 · 14 comments
Open

thoughts #8

mattdesl opened this issue Mar 19, 2015 · 14 comments

Comments

@mattdesl
Copy link

I'm digging this. 馃憤 My two cents:

I was initially pretty confused reading through source, until I realized it was the transpiled output. Maybe it would be better to only transpile on prepublish, and avoid bloating github with transpiled code. Or, putting it in a build or dist folder.

It would also be great to embrace other modules a bit more rather than try to reinvent the wheel. Some inspiration:

@hemanth
Copy link
Member

hemanth commented Mar 20, 2015

+1 For revamping the publishing process (also felt the same), feel free to send a PR on module-template this is what is being used for all the modules that are created here.

Yup npm-dom is cool, the idea is keep everything as functional as possible.

fp-js would be all the helper/util js for fp-dom is the idea.

Thank you for pitching in :)

@stoeffel
Copy link

馃憤

@hemanth
Copy link
Member

hemanth commented Jan 16, 2016

@mattdesl Still interested?

@stoeffel
Copy link

I have put some thoughts in it and I would prefer to change some stuff in the current implementation, to embrace a truly functional api.

  1. I think I would deprecate fp-js in favor of ramda (and ramda-fantasy). Ramda is much more sophisticated (and why inventing the wheel twice)
  2. Removing side-effects by returning monadic data types (i.e. IO, Maybe or Future from ramda-fantasy

f.e.

- const blueLi = addClass(always('blue'), select('li'));

+ const blueLiIO = R.compose(R.map(addClass('blue')), select('li'));
+ blueLiIO.runIO();
  1. using transcribe to create an api doc from a Hindley鈥揗ilner type annotation.
// select :: String -> IO(Maybe(DomElement));
const select = function() { /** ... **/ };

@stoeffel
Copy link

The current API has only one feature (currying). With adding monads we would gain a lot more, and that is a side-effect free API for the DOM.

@stoeffel
Copy link

Maybe we should also consider moving to a mono repo. It's much simpler to maintain/document and understand by new users.

@stoeffel
Copy link

It would also be great to embrace other modules a bit more rather than try to reinvent the wheel.

@mattdesl Totally agreed. IMO this should become a side-effect free, curried functional-api to the DOM using other modules or our own implementations.

@hemanth
Copy link
Member

hemanth commented Jan 17, 2016

I think I would deprecate fp-js in favor of ramda (and ramda-fantasy). Ramda is much more sophisticated (and why inventing the wheel twice)

@stoeffel Agree.

@stoeffel
Copy link

cool.
What do you think about the other ideas I proposed?

@hemanth
Copy link
Member

hemanth commented Jan 17, 2016

@stoeffel :

monadic data types

and

Hindley鈥揗ilner type annotation

Will be good to have, but would need a introduction as most of them from JS world would be new to it.

I am not really a big fan of a mono repo...

@stoeffel
Copy link

Yop, it would need a intro or some links. I can live without a mono repo. But I think it would make it a lot easier for new users to get started. We could still publish individual modules.
We could use https://github.com/kittens/lerna

@stoeffel
Copy link

select returning an IO

const selectorAll = function(query) {
  return new IO(function() {
    return document.querySelectorAll(query) || [];
  });
}

const innerHTML = R.lensProp('innerHTML');

const headInnerHtml = R.compose(
  R.view(innerHTML)
, R.head
)
const lines = R.split('\n')

const text = R.compose(
  R.map(
    R.compose( R.toUpper
             , R.head
             , lines
             , headInnerHtml
             )
  )
  , selectorAll
);

console.log(text('h1').runIO());

@hemanth
Copy link
Member

hemanth commented Jan 17, 2016

Looks much better! Thanks.

@stoeffel Let us create a todo list and attack this!

@stoeffel
Copy link

Sure, let's do this. Would be cool to hear what @guumaster or @mattdesl thinks about this changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@hemanth @stoeffel @mattdesl and others