Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,255
    • Issues 5,255
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 563
    • Merge requests 563
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8851
Closed
Open
Issue created Mar 06, 2014 by Simon Peyton Jones@simonpjDeveloper

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking