-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
Question: Types on interface vs. types on instance #1092
Comments
Your corrected code is import { Either, either } from 'fp-ts/lib/Either';
const myValidationHandler = (myEither: Either<any, any>) => {
either.map(myEither, () => {});
}; |
Or import { Either, map } from 'fp-ts/lib/Either'
import { pipe } from 'fp-ts/lib/pipeable'
const myValidationHandler = (myEither: Either<any, any>) =>
pipe(
myEither,
map(() => {})
) if you prefer data-last functions |
Thanks for the quick responses!
My question is more about why the type Either doesn’t have the behavior
types attached to it like either instance? Why is type either != type
Either?
…On Thu, 16 Jan 2020 at 12:58, Giulio Canti ***@***.***> wrote:
Or
import { Either, map } from 'fp-ts/lib/Either'import { pipe } from 'fp-ts/lib/pipeable'
const myValidationHandler = (myEither: Either<any, any>) =>
pipe(
myEither,
map(() => {})
)
if you prefer data-last functions
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1092?email_source=notifications&email_token=AB6G67HNJHDJQ57VEGDM3IDQ6BDVLA5CNFSM4KHQ5BTKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJD2BUA#issuecomment-575119568>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB6G67C5PDJV6GU4W3DKUCTQ6BDVLANCNFSM4KHQ5BTA>
.
|
This was the version 1 behavior of the library where every type was a class with all methods attached. The change was made cause of disadvantages when using classes like serialization, extendibility and tree shaking problems. You can find the full discussion in #823 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Guidance here would be appreciated :)
Current Behavior
Looking at the type declaration of
Either
in the.d.ts
shipped with the npm package I am seeing:But
either
instance is defined as:Which contains
Applicative
and soFunctor
meaning it canmap
but this code currently contains a type error:Message:
Expected behaviour
I would have expected the types as defined on the instance to be shared with the types as defined on the interface (per the example above). Or am I using the interfaces incorrectly? Should I rather be using
Functor
directly? Themap
functionality seems to be present at runtime though.Your environment
Which versions of fp-ts are affected by this issue? Did this work in previous versions of fp-ts?
The text was updated successfully, but these errors were encountered: