[GHC] #11105: Put the generic-default type in the Class
#11105: Put the generic-default type in the Class -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This is an internal GHC refactoring ticket. Consider {{{ {-# LANGUAGE DefaultSignatures #-} class C a where op :: a -> a -> Bool default op :: Ord a => a -> a -> Bool op x y = x < y }}} The `Class` object for `C` has a `ClassOpItem` that specifies * the name `op` * the type of the method `a -> a -> Bool` * that `op` has a generic-default signature BUT it does not contain the actual signature `Ord a => a -> a -> Bool`. That's really wrong; it is certainly part of the definition of the class, and we should print it out when we say `:info C` in ghci. Instead this type is kept solely in the top-level generic-default Id binding. But that means that default-method Ids and generic-default method Ids are treated differently; see `gen_dm_ids` in `tcTyClDecl1` in `TcTyClsDecls`, and `mkDefaultMethodIds` in `TcTyDecls`. We should treat them uniformly. I know how but have too much in flight to do it immediately. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11105> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11105: Put the generic-default type in the Class -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"924f851700ca9ba7e0e7483b7ca4de62a4a74e15/ghc" 924f8517/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="924f851700ca9ba7e0e7483b7ca4de62a4a74e15" Refactor default methods (Trac #11105) This patch does some signficant refactoring to the treatment of default methods in class declarations, and more generally to the type checking of type/class decls. Highlights: * When the class has a generic-default method, such as class C a where op :: a -> a -> Bool default op :: Ord a => a -> a -> a the ClassOpItem records the type of the generic-default, in this case the type (Ord a => a -> a -> a) * I killed off Class.DefMeth in favour of the very-similar BasicTypes.DefMethSpec. However it turned out to be better to use a Maybe, thus Maybe (DefMethSpec Type) with Nothing meaning "no default method". * In TcTyClsDecls.tcTyClGroup, we used to accumulate a [TyThing], but I found a way to make it much simpler, accumulating only a [TyCon]. Much less wrapping and unwrapping. * On the way I also fixed Trac #10896 in a better way. Instead of killing off all ambiguity checks whenever there are any type errors (the fix in commit 8e8b9ed), I instead recover in TcTyClsDecls.checkValidTyCl. There was a lot of associated simplification all round }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11105#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11105: Put the generic-default type in the Class -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11105#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC