-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Alternative approach to higher-kinded types #547
Comments
Hi @pelotom, thanks for sharing. How do you define a |
Good question. The only thing I can think to do is have a parameterized instance creator const RightMonad = <L>() => Monad<Either<Fixed<L>, _>>({
pure: right,
bind: (ma, f) => (ma.tag === "left" ? ma : f(ma.right)),
});
const either: Either<string, number> = right(42);
const result = RightMonad<string>().map(either, n => n + 1);
expect(result).toEqual(right(43)); The new |
It"s a shame that you can"t just say:
The ability to introduce foralls is restricted to functions. |
Actually it looks like the const RightMonad = <L>() => Monad<Either<L, _>>({
pure: right,
bind: (ma, f) => (ma.tag === "left" ? ma : f(ma.right)),
}); Not really sure why this is 😅 |
Yes, it is... I hope your issue microsoft/TypeScript#17574 gets some attention! |
Hi @gcanti, I"ve been playing with a simple encoding of HKTs using conditional types to substitute virtual type variables within a saturated type. Reference project here:
https://github.com/pelotom/hkts
It"s attractive to me in that it doesn"t require defining your type constructors in any special way; you can take any given
type Foo<A> = ...
for example and then abstract overFoo
. Would this be a useful approach forfp-ts
? Would love to hear your thoughts!The text was updated successfully, but these errors were encountered: