`bindTo` messes up the monadic index
See original GitHub issueš Bug report
bindTo messes up the monadic index. For example, consider a broader monadic index that takes you through AuthenticationOpen to AuthorizationOpen and then StatusOpen and so forth.
authentication middleware:
declare const authenticate: Middleware<AuthenticationOpen, AuthorizationOpen, unknown, AuthenticatedUser>
one of many authorization middlewares
declare const userHasReadAccess: (u:AuthenticatedUser) => Middleware<AuthorizationOpen, StatusOpen, unknown, AuthorizedUser>
const myController = pipe(
authenticate,
H.ichain(userHasReadAccess),
H.bindTo('user'), // <-- property AuthenticationOpen is missing in type StatusOpen . . .
H.bind('query', () => H.decodeQuery(/* . . . */)),
/* . . . */
bindTo takes Middleware<I,I,E,A> and returns Middleware<I,I,E,{ ... }> but it should take Middleware<I,O,E,A> because not every middleware passed into bindTo will have the same "inā and āoutā index.
Your environment
Which versions of hyper-ts are affected by this issue? Did this work in previous versions of hyper-ts?
| Software | Version(s) |
|---|---|
| fp-ts | 2.10.5 |
| hyper-ts | 0.6.5 |
| TypeScript | 3.9.2 |
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)

Top Related StackOverflow Question
Itās the same difference between
chainandichain(sincebindis just a utility aroundchain).ichainis the indexed version ofchain, which additionally updates the indexes.You should use
chainwhen the operation doesnāt change the indexes.mapis fine, we need an indexed versionimapfor that too, see https://hackage.haskell.org/package/indexed-0.1.3/docs/Data-Functor-Indexed.html or https://pursuit.purescript.org/packages/purescript-indexed-monad.@DenisFrezzato Iām closing my issue since it appears youāve implemented this in a forthcoming version.