[GHC] #11974: `default` declaration doesn't allow higher-kinded types

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 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: -------------------------------------+------------------------------------- Since we now have #10971, I would expect the following to work: {{{ {-# LANGUAGE ExtendedDefaultRules #-} module Bug where default (Maybe, []) }}} But it doesn't. Sadly, the default default list contains `[]`, but the user can never set this. Fix on the way. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => patch * differential: => Phab:D2136 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Can this also let users default promoted datatypes? It would be very useful. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I have no idea what you mean here -- sorry. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Let's say you have {{{#!hs type Type₁ = Type type Num₁ = Num data Exp₁ (ty :: Type₁) where N₁ :: Num₁ n => Exp₁ n deriving instance Show (Exp₁ ty) }}} {{{ ghci> :set -fwarn-type-defaults ghci> N₁ ... warning: [-Wtype-defaults] • Defaulting the following constraint to type ‘Integer’ Num n0 arising from a use of ‘it’ ... N₁ }}} and you avoid writing `N₁ :: Exp₁ Integer` because of defaulting. If however one indexes it with a promoted data type {{{#!hs data Type₂ = Integer₂ | Int32₂ | Bool₂ class Num₂ (a :: Type₂) instance Num₂ 'Integer₂ instance Num₂ 'Int32₂ data Exp₂ (ty :: Type₂) where N₂ :: Num₂ n => Exp₂ n deriving instance Show (Exp₂ ty) }}} but showing it errors {{{ ghci> N₂ <interactive>:3:1: error: • Ambiguous type variable ‘n0’ arising from a use of ‘it’ prevents the constraint ‘(Num₂ n0)’ from being solved. Probable fix: use a type annotation to specify what ‘n0’ should be. These potential instances exist: instance Num₂ 'Int32₂ -- Defined at /tmp/tyGL.hs:11:10 instance Num₂ 'Integer₂ -- Defined at /tmp/tyGL.hs:10:10 • In the first argument of ‘print’, namely ‘it’ In a stmt of an interactive GHCi command: print it ghci> }}} I needed this and remembered this ticket. I want to write something like {{{#!hs default ('Integer₂) -- Using https://prime.haskell.org/wiki/Defaulting#Proposal1-nametheclass default Num₂ ('Integer₂) }}} Comment got to long, may split it -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): You're proposing a wholesale extension of the defaulting mechanism. Defaulting happens as per the Haskell Report or with a [https://downloads.haskell.org/~ghc/8.0.1-rc4/docs/html/users_guide/ghci.html #type-defaulting-in-ghci small extension]. In either case, the set of defaultable classes is fixed. You're proposing changing this, which is quite different than the purpose of this ticket. (This ticket is about letting `default` declarations include types that are already defaultable.) If you want this new behavior, I encourage you to write a specification of it (on a wiki page) and then submit a feature request. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2136
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: patch => merge * milestone: => 8.0.2 Comment: This is a proper bug and could well be merged. But if it causes trouble, no worries. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T11974, | typecheck/should_fail/T11974b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * testcase: => typecheck/should_compile/T11974, typecheck/should_fail/T11974b -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner:
Type: bug | Status: merge
Priority: normal | Milestone: 8.0.2
Component: Compiler | Version: 8.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| typecheck/should_compile/T11974,
| typecheck/should_fail/T11974b
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2136
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T11974, | typecheck/should_fail/T11974b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T11974, | typecheck/should_fail/T11974b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * version: 8.1 => 8.0.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11974: `default` declaration doesn't allow higher-kinded types -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T11974, | typecheck/should_fail/T11974b Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2136 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Fixing this seems to have (inadvertently?) changed the behavior of `ExtendedDefaultRules` in a subtle way in GHC 8.0.2. See #12907. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11974#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC