The other one uses custom "dictionaries" and wrapping newtypes for every class - I don't think it makes much sense, because the former isn't that different from writing instance that interprets directly into some special-purpose effect, while the latter seems to only exist to safely allow passing the former into instance using reflection
instance(Members'[Final m, NonDet]r,MonadParsecesm)=>MonadParseces(Absorber(e,s,m_0)r)whereparseError=Abs.embedFinal.parseErrorlabell(Absma)=Abs$withStrategicToFinal$labell<$>runSmatry(Absma)=Abs$withStrategicToFinal$try<$>runSmalookAhead(Absma)=Abs$withStrategicToFinal$lookAhead<$>runSmanotFollowedBy(Absma)=Abs$withStrategicToFinal$liftA2(<$)getInitialStateS$notFollowedBy<$>runSmawithRecoveryf(Absma)=Abs$withStrategicToFinaldos<-getInitialStateSf'<-bindS$unAbs<$>fwithRecovery(f'.(s$>))<$>runSmaobserving(Absma)=Abs$withStrategicToFinaldos<-getInitialStateS(fmap.fmap)(either((s$>).Left)(fmapRight))$observing<$>runSmaeof=Abs$embedFinaleoftokenf=Abs.embedFinal.tokenftokensf=Abs.embedFinal.tokensftakeWhilePf=Abs.embedFinal.takeWhilePftakeWhile1Pf=Abs.embedFinal.takeWhile1PftakePf=Abs.embedFinal.takePfgetParserState=Abs$embedFinalgetParserStateupdateParserState=Abs.embedFinal.updateParserStateabsorbParsec::forallesmra.(Member(Finalm)r,MonadParsecesm,MonadParseces(Absorber(e,s,m())(NonDet:r)))=>(MonadParseces(Sem(NonDet:r))=>Sem(NonDet:r)a)->SemraabsorbParsecma=interpretFinal(\caseEmpty->pureemptyChooselr->(<|>)<$>runSl<*>runSr)$absorb@(MonadParseces)@(e,s,m())ma
Was tinkering with possibility of making even simpler version of absorber interface:
awesome
hm, but if we live in the unreal ideal world where everything gets inlined away, doesn't the
unsafeCoerce
get in the way of ghc?or does the existing one also use
unsafeCoerce
?also, is this simpler for usage/creating user "absorb" functions? not too familiar with the other one
It does - as it does in current version in
zoo
oh yeah, cause
reflection
itself also doesThe other one uses custom "dictionaries" and wrapping newtypes for every class - I don't think it makes much sense, because the former isn't that different from writing instance that interprets directly into some special-purpose effect, while the latter seems to only exist to safely allow passing the former into instance using
reflection
I will investigate possibility of using
magicDict
, which is compile-time only and replaced using builtin ruleI didn't know it does that
See https://hackage.haskell.org/package/polysemy-zoo-0.7.0.0/docs/src/Polysemy.ConstraintAbsorber.html#absorbWithSem and https://hackage.haskell.org/package/polysemy-zoo-0.7.0.0/docs/src/Polysemy.ConstraintAbsorber.MonadReader.html#ReaderDict
Haven't tested it thoughtfully yet, but it seems to work
the only thing left now is for NonDet to behave :P