[GHC] #13901: Lift the "Illegal polymorphic type" restriction on type families

#13901: Lift the "Illegal polymorphic type" restriction on type families -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 (Type checker) | Keywords: TypeFamilies | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: #11962 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Currently, I can do this: {{{#!hs type Foo = forall a. Maybe a }}} But if I try to refactor this to an equivalent type family: {{{#!hs type family Foo where Foo = forall a. Maybe a }}} Then GHC complains: {{{ • Illegal polymorphic type: forall a. Maybe a • In the equations for closed type family ‘Foo’ In the type family declaration for ‘Foo’ }}} We should lift this restriction. This would be necessary, for instance, to implement #11962. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13901 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13901: Lift the "Illegal polymorphic type" restriction on type families -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11962 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by Iceland_jack): * cc: Iceland_jack (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13901#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13901: Lift the "Illegal polymorphic type" restriction on type families -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11962 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): This isn't so easy. With type families, there are potentially many right- hand sides. Some may have polymorphism, and some may not. And we might not know which is chosen until we get to the constraint solver. When the constraint-generation algorithm looks at something with type `Foo`, does it add a wrapper for instantiating `forall a. Maybe a`? Or not? Impossible to know. This all smells a bit like impredicativity. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13901#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13901: Lift the "Illegal polymorphic type" restriction on type families -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11962 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-index): * cc: int-index (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13901#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13901: Lift the "Illegal polymorphic type" restriction on type families -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11962 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Artyom.Kazak):
does it add a wrapper for instantiating
What wrapper? (Just curious.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13901#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13901: Lift the "Illegal polymorphic type" restriction on type families -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11962 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): The reference to wrapper is more of an implementation detail. GHC uses a `HsWrapper` type to denote things that happen to expressions (instantiations, type abstractions, dictionary applications, etc.) that are invisible in user-written Haskell. That's all I was referring to there. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13901#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13901: Lift the "Illegal polymorphic type" restriction on type families -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: duplicate | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9269, #11962 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => duplicate * related: #11962 => #9269, #11962 Comment: This is a duplicate of #9269. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13901#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC