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

Feature/filterable #492

Merged
merged 7 commits into from
Jun 25, 2018
Merged

Feature/filterable #492

merged 7 commits into from
Jun 25, 2018

Conversation

raveclassic
Copy link
Collaborator

Part of #485

Adds:

  • Filterable typeclass
  • default implementations for Filterable methods
  • default implementations for Compactable methods via Filterable
  • eitherBool, optionBool helpers
  • tests
  • .prettierrc and .prettierignore to support WebStorm watchers

Changes:

@raveclassic raveclassic requested a review from gcanti June 22, 2018 13:12
}

/**
* @typeclass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want this, we will get multiple versions of the same type class in the docs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -119,51 +98,105 @@ export interface Compactable3C<F extends URIS3, U, L> {
* @function
* @since 1.7.0
*/
export function compactDefault<F extends URIS3, U, L>(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the renaming? Also I don't understand compactDefaultFilterMap and separateDefaultPartitionMap, they seem trivial. Maybe we can just add some documentation explaining how to derive compact/separate from filterMap/partitionMap and avoid some bloat

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming is to be explicit in what is needed for default implementation since there's more than one way to get it. The name reflects purescript implementation, firstly I picked this convention: get<Name>From<OtherName> which is more readabe.

Although they are trivial you still need to write them each time, I think it's just handy to have them as a part of the library as well as they are a good way of reflecting relation between these typeclasses, don't you think?

* @function
* @since 1.7.0
*/
export const eitherBool = <A>(p: Predicate<A>) => (a: A): Either<A, A> => (p(a) ? right(a) : left(a))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove eitherBool since eitherBool(p) = fromPredicate(p, identity)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

* @function
* @since 1.7.0
*/
export const optionBool = <A>(p: Predicate<A>) => (a: A): Option<A> => (p(a) ? some(a) : none)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove optionBool since is fromPredicate (<= Option module)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

* @since 1.7.0
*/
export function partitionDefaultPartitionMap<F extends URIS3, U, L>(
F: Pick<Filterable3C<F, U, L>, 'URI' | 'partitionMap'>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why an object here (as argument) instead of

partitionMap: Pick<Filterable3C<F, U, L>, 'partitionMap'>

(idem for the other default-functions)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object is more handy when default implementation requires more than one function (like wither). Also I have some problems with inference without passing URI in getFilterable of Either (next PR).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked this convention: getFrom which is more readabe

ok

as well as they are a good way of reflecting relation between these typeclasses

ok

Object is more handy when default implementation requires more than one function (like wither)

ok

Also I have some problems with inference without passing URI in getFilterable of Either (next PR)

Ah I see, ok

@raveclassic raveclassic merged commit 3284938 into master Jun 25, 2018
@raveclassic raveclassic deleted the feature/filterable branch June 25, 2018 08:30
@gcanti gcanti added this to the 1.7.0 milestone Jun 27, 2018
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

Successfully merging this pull request may close these issues.

2 participants