Does anyone know of a way to use QualifiedDo to guarantee that my do-block will desugar with Applicative instead? Or to replace ApplicativeDo instead?
I tried this:
{-# LANGUAGE TypeFamilies #-}moduleAdowhere(>>=)::Int~Char=>fa->(a->fb)->fb(>>=)=undefined(<*>)::Applicativef=>f(a->b)->fa->fb(<*>)=(Prelude.<*>)pure::Applicativef=>a->fapure=Prelude.purereturn::Applicativef=>a->fareturn=Prelude.purefmap::Functorf=>(a->b)->fa->fbfmap=Prelude.fmapjoin::Int~Char=>m(ma)->majoin=undefined----{-# LANGUAGE QualifiedDo #-}{-# LANGUAGE ApplicativeDo #-}{-# LANGUAGE DerivingStrategies #-}{-# LANGUAGE GeneralisedNewtypeDeriving #-}moduleAdotrywhereimportqualifiedAdoasAnewtypeLista=List[a]derivingnewtype(Show,Functor,Applicative)xs::ListIntxs=dox<-List[1,2,3]pure$x
and the second module compiles and works fine (using ApplicativeDo, as it's forced by the lack of a Monad on List)
however, if I switch the do with an A.do, suddenly it doesn't compile anymore - due to the unsatisafiable Int ~ Char, or in other words, the Applicative methods are no longer used
Does anyone know of a way to use
QualifiedDo
to guarantee that my do-block will desugar withApplicative
instead? Or to replaceApplicativeDo
instead?I tried this:
and the second module compiles and works fine (using
ApplicativeDo
, as it's forced by the lack of aMonad
onList
)however, if I switch the
do
with anA.do
, suddenly it doesn't compile anymore - due to the unsatisafiableInt ~ Char
, or in other words, theApplicative
methods are no longer usedis there reason to assume
QualifiedDo
should work withApplicative
?https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0216-qualified-do.rst#proposed-change-specification
the section mentions it
and thanks, I "saw the error of my ways"
the issue was I wasn't using a qualified
pure
orreturn