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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Nasty bits from Pair #59

Closed
2 of 5 tasks
evilsoft opened this issue Feb 13, 2017 · 2 comments
Closed
2 of 5 tasks

Remove Nasty bits from Pair #59

evilsoft opened this issue Feb 13, 2017 · 2 comments
Milestone

Comments

@evilsoft
Copy link
Owner

evilsoft commented Feb 13, 2017

So, back when Pair was creates some horrible things were done, just to get that darn of.
Some cruft needs to be cut from Pair:

  • Remove of
  • Remove value
  • Add toArray
  • add pairToArray transformation
  • add pairToList transformation

EDIT: After some long, hard thought on this, decided to keep the Semigroup constraint for ap, chain and concat. They do in fact provide much value for things like a cheap Writer (which is just a Product type with a Semigroup in its fst.

@evilsoft
Copy link
Owner Author

Okay so after starting this change, turns out I will not be adding pairToArray and pairToList and will not add toArray to the Pair. While it is valid in JS, by allowing to move from Pair to Array or List, then we lose some of the benefits of having a List/Array of a single type.

since there will be special handling anyway, it makes sense to let the user use merge to make it a one "action" thing to map and extract into a value they have control over. For example, if they want to create an array like [ fst, snd ], then they can easily do things like this:

const { Pair, merge, reverseApply: thrush } = crocks

const f =
  thrush(Pair('George', 5))

// { name: 'George', count: 5 }
const obj = 
  f(merge((x, y) => ({ name: x, count: y })))

// [ 5, 'George' ]
const arr =
  f(merge((x, y) => [ y, x ]))

This seems like the more powerful interface

@evilsoft evilsoft added this to the 0.4.0 milestone Feb 26, 2017
@evilsoft
Copy link
Owner Author

Merged PR#86.
In master and going out with 0.4.0.
Closing!

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

1 participant