`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 GitHub Comments
Itās the same difference between
chain
andichain
(sincebind
is just a utility aroundchain
).ichain
is the indexed version ofchain
, which additionally updates the indexes.You should use
chain
when the operation doesnāt change the indexes.map
is fine, we need an indexed versionimap
for 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.