[GHC] #10039: Make Const (Control.Applicative) kind polymorphic in its second argument

GHC ghc-devs at haskell.org
Thu Jan 29 14:54:54 UTC 2015


#10039: Make Const (Control.Applicative) kind polymorphic in its second argument
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                   Owner:  ekmett
            Type:  feature request   |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Core Libraries    |                 Version:  7.8.4
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 That would be great, other types like `Data.Functor.Compose.Compose` and
 `Data.Functor.Reverse.Reverse` could also be generalised (Vinyl does this
 with [[http://hackage.haskell.org/package/vinyl-0.5.1/docs/Data-Vinyl-
 Functor.html#t:Compose|Compose]]):

 {{{#!hs
 newtype Compose (f :: j -> *) (g :: k -> j) (a :: k) = Compose {
 getCompose :: f (g a) }
 newtype Reverse (f :: k -> *)               (a :: k) = Reverse {
 getReverse :: f a     }
 }}}

 A more general `Compose` is definitely useful for composing dictionaries
 constraints (`Compose Dict Eq`,
 [[http://www.reddit.com/r/haskell/comments/2qwqf2/generate_list_of_dicts_from_type_level_list/|discussion]]),
 non-empty vectors:

 {{{#!hs
 data Exists :: (k -> *) -> * where
   Never :: p x -> Exists p

 more :: Compose (Vector Char) Suc (Suc Zero)
 more = Compose (Cons 'H' (Cons 'S' Nil))

 type NonEmpty a = Exists (Compose (Vector a) Suc)

 oh :: NonEmpty Char
 oh = Never more
 }}}

 working with typed lists and such (I also ran into
 [[http://lpaste.net/edit/75980|this]]). It's not clear to me that a
 generalised `Reverse` would be worth it.

 I wonder if any of this will break code though.

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


More information about the ghc-tickets mailing list