[GHC] #12369: data families shouldn't be required to have return kind *, data instances should

GHC ghc-devs at haskell.org
Sat Oct 15 07:24:11 UTC 2016


#12369: data families shouldn't be required to have return kind *, data instances
should
-------------------------------------+-------------------------------------
        Reporter:  ekmett            |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |
      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 Iceland_jack):

 Is this another example of this

 {{{#!hs

 type f  ~> g = forall a.   f a   -> g a
 type f ~~> g = forall a b. f a b -> g a b

 newtype Free0 :: Foo Type where
   Free0 :: (forall q. k q => (p  -> q) -> q) -> Free0 k p

 newtype Free1 :: ((k -> Type) -> Constraint) -> (k -> Type) -> (k -> Type)
 where
   Free1 :: (forall q. k q => (p  ~> q) -> q a) -> Free1 k p a

 newtype Free2 :: ((k1 -> k2 -> Type) -> Constraint) -> (k1 -> k2 -> Type)
 -> (k1 -> k2 -> Type) where
   Free2 :: (forall q. k q => (p ~~> q) -> q a b) -> Free2 k p a b
 }}}

 They all follow the pattern `type FREE ĸ = (ĸ -> Constraint) -> (ĸ -> ĸ)`

 {{{#!hs
 Free0 :: FREE Type
 Free1 :: FREE (k -> Type)
 Free2 :: FREE (k1 -> k2 -> Type)
 }}}

 Maybe you could write it as?

 {{{#!hs
 data    family   Free :: FREE k

 newtype instance Free :: FREE Type where
   Free0 :: (forall q. k q => (p -> q) -> q) -> Free k p

 newtype instance Free :: forall k. FREE (k -> Type) where
   Free1 :: (forall q. k q => (p  ~> q) -> q a) -> Free k p a

 newtype instance Free :: forall k1 k2. FREE (k1 -> k2 -> Type) where
   Free2 :: (forall q. k q => (p ~~> q) -> q a b) -> Free2 k p a b
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12369#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list