{-# LANGUAGE DerivingVia #-}moduleCodeGenwhereimportControl.Monad.WriternewtypeName=NameStringderiving(Eq,Show)newtypeCodeGena=CodeGen(Writer[a]())derivingApplicativeviaWriter[a]
This is just some code I'm toying around with but I haven't encountered the "impossible" before. Neat! Anyone know what's happening here? Is it simple improper use of DerivingVia or should there be a type error here?
CodeGen a is coercible to Writer [a] (), but that doesn't mean CodeGen is coercible to Writer [a], it doesn't really make sense since there is not a in CodeGen.
This is just some code I'm toying around with but I haven't encountered the "impossible" before. Neat! Anyone know what's happening here? Is it simple improper use of
DerivingVia
or should there be a type error here?This is certainly a weird instance.
Applicative
onWriter [a]
would give youpure :: x -> Writer [a] x
but for
CodeGen
you needpure :: x -> Writer [x] ()
CodeGen a
is coercible toWriter [a] ()
, but that doesn't meanCodeGen
is coercible toWriter [a]
, it doesn't really make sense since there is nota
inCodeGen
.Thanks!
BTW, this should probably be filled as a bug on GHC repo - I don't think "impossible" can ever be considered to be a proper error