Standalone deriving and GND behave differently
Sergey Tromimovich writes: Trying to build random packages with fresh ghc-7.8.1-rc2 I've come up with a strange bit:
https://github.com/trofi/Idris-dev/commit/9f93122ba1aa075c2fa1555fea68a6c403697e04
Is it an intended behaviour that standalone deriving (A)
deriving instance Parsing IdrisInnerParser
is capable of doing more, than a deriving clause (B)
newtype IdrisInnerParser a
= IdrisInnerParser { runInnerParser :: Parser a }
deriving (Parsing)
where the class is defined thus
class Alternative m => Parsing m where
....
notFollowedBy :: (Monad m, Show a) => m a -> m ()
notFollowedBy p = try ((try p >>= unexpected . show) <|> pure ())
The error message from the (B) is
[50 of 75] Compiling Idris.ParseHelpers ( src/Idris/ParseHelpers.hs, dist/build/Idris/ParseHelpers.o )
src/Idris/ParseHelpers.hs:40:97:
Could not coerce from ‘Monad Parser’ to ‘Monad IdrisInnerParser’
because the first type argument of ‘Monad’ has role Nominal,
but the arguments ‘Parser’ and ‘IdrisInnerParser’ differ
arising from the coercion of the method ‘notFollowedBy’ from type
‘forall a. (Monad Parser, Show a) => Parser a -> Parser ()’ to type
‘forall a.
(Monad IdrisInnerParser, Show a) =>
IdrisInnerParser a -> IdrisInnerParser ()’
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Parsing IdrisInnerParser)
Answer: no they should not behave differently.
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |