-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Feature/filterable #492
Conversation
src/Compactable.ts
Outdated
} | ||
|
||
/** | ||
* @typeclass |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
src/Filterable.ts
Outdated
* @function | ||
* @since 1.7.0 | ||
*/ | ||
export const eitherBool = <A>(p: Predicate<A>) => (a: A): Either<A, A> => (p(a) ? right(a) : left(a)) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/Filterable.ts
Outdated
* @function | ||
* @since 1.7.0 | ||
*/ | ||
export const optionBool = <A>(p: Predicate<A>) => (a: A): Option<A> => (p(a) ? some(a) : none) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
src/Filterable.ts
Outdated
* @since 1.7.0 | ||
*/ | ||
export function partitionDefaultPartitionMap<F extends URIS3, U, L>( | ||
F: Pick<Filterable3C<F, U, L>, 'URI' | 'partitionMap'> |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
Part of #485
Adds:
Filterable
typeclassFilterable
methodsCompactable
methods viaFilterable
eitherBool
,optionBool
helpers.prettierrc
and.prettierignore
to support WebStorm watchersChanges:
Compactable
helper namesCompactableA
andCompactable1A
which were accidentaly added in Feature/compactable instances #488