[GHC] #12045: Visible kind application

GHC ghc-devs at haskell.org
Tue Jan 10 11:05:37 UTC 2017


#12045: Visible kind application
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  Iceland_jack
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:
                                     |  TypeApplications TypeInType
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  ​Phab:D2216
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 Here are some examples that are actually useful, used with a non-standard
 version of [https://github.com/ekmett/hask/ hask]:

 {{{#!hs
 type Fix f = (f -> f) -> f

 newtype Mu1 :: Fix Type where
   In1 :: f (Mu1 f) -> Mu1 f

 newtype Mu2 :: Fix (k -> Type) where
   In2 :: f (Mu2 f) a -> Mu2 f a
 }}}

 If you want to reference the kind variable `k` you can write

 {{{#!hs
 -- instance Functor (Mu :: ((k -> Type) -> (k -> Type)) -> (k -> Type))
 where
 instance Functor (Mu @k) where
   type Dom (Mu @k) = ...
   type Cod (Mu @k) = ...
 }}}

 instead of

 {{{#!hs
 instance Functor (Mu :: Fix (k -> Type)) where
   type Dom (Mu :: Fix (k -> Type)) = (Void :: Cat ((k -> Type) -> (k ->
 Type)))
   type Cod (Mu :: Fix (k -> Type)) = (Void :: Cat (k -> Type))
 }}}

 ----

 {{{#!hs
 instance Functor (Const @k a) where
   type Dom (Const @k a) = UNIT
   type Cod (Const @k a) = (->)

   fmap :: UNIT b b' -> (Const a b -> Const a b')
   fmap UNIT (Const a) = Const a
 }}}

 instead of

 {{{#!hs
 instance Functor (Const a :: k -> Type) where
   type Dom (Const a :: k -> Type) = UNIT
   type Cod (Const a :: k -> Type) = (->)
 }}}

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


More information about the ghc-tickets mailing list